Esempio n. 1
0
        internal static Encoding Convert(Cmdlet cmdlet, string encoding)
        {
            switch (encoding)
            {
            case "":
            case null:
                return(Encoding.Unicode);

            default:
                if (string.Equals(encoding, "unicode", StringComparison.OrdinalIgnoreCase))
                {
                    return(Encoding.Unicode);
                }
                if (string.Equals(encoding, "bigendianunicode", StringComparison.OrdinalIgnoreCase))
                {
                    return(Encoding.BigEndianUnicode);
                }
                if (string.Equals(encoding, "ascii", StringComparison.OrdinalIgnoreCase))
                {
                    return(Encoding.ASCII);
                }
                if (string.Equals(encoding, "utf8", StringComparison.OrdinalIgnoreCase))
                {
                    return(Encoding.UTF8);
                }
                if (string.Equals(encoding, "utf7", StringComparison.OrdinalIgnoreCase))
                {
                    return(Encoding.UTF7);
                }
                if (string.Equals(encoding, "utf32", StringComparison.OrdinalIgnoreCase))
                {
                    return(Encoding.UTF32);
                }
                if (string.Equals(encoding, "default", StringComparison.OrdinalIgnoreCase))
                {
                    return(Encoding.Default);
                }
                if (string.Equals(encoding, "oem", StringComparison.OrdinalIgnoreCase))
                {
                    return(Encoding.GetEncoding((int)EncodingConversion.NativeMethods.GetOEMCP()));
                }
                string str = string.Join(", ", new string[8]
                {
                    "unicode",
                    "bigendianunicode",
                    "ascii",
                    "utf8",
                    "utf7",
                    "utf32",
                    "default",
                    "oem"
                });
                string message = ResourceManagerCache.FormatResourceString("PathUtils", "OutFile_WriteToFileEncodingUnknown", (object)encoding, (object)str);
                cmdlet.ThrowTerminatingError(new ErrorRecord((Exception)EncodingConversion.tracer.NewArgumentException("Encoding"), "WriteToFileEncodingUnknown", ErrorCategory.InvalidArgument, (object)null)
                {
                    ErrorDetails = new ErrorDetails(message)
                });
                return((Encoding)null);
            }
        }
 private string BuildMessage()
 {
     try
     {
         object[] array = new object[0];
         if (this.args != null)
         {
             array    = new object[this.args.Length + 6];
             array[0] = this.commandName;
             array[1] = this.parameterName;
             array[2] = this.parameterType;
             array[3] = this.typeSpecified;
             array[4] = this.line;
             array[5] = this.offset;
             this.args.CopyTo(array, 6);
         }
         string str = string.Empty;
         if (!string.IsNullOrEmpty(this.resourceBaseName) && !string.IsNullOrEmpty(this.resourceId))
         {
             str = ResourceManagerCache.FormatResourceString(this.resourceBaseName, this.resourceId, array);
         }
         return(str);
     }
     catch (MissingManifestResourceException exception)
     {
         return(ResourceManagerCache.FormatResourceString("ParameterBinderStrings", "ResourceStringLoadError", new object[] { this.args[0], this.resourceBaseName, this.resourceId, exception.Message }));
     }
     catch (FormatException exception2)
     {
         return(ResourceManagerCache.FormatResourceString("ParameterBinderStrings", "ResourceStringFormatError", new object[] { this.args[0], this.resourceBaseName, this.resourceId, exception2.Message }));
     }
 }
Esempio n. 3
0
        internal PSArgumentOutOfRangeException NewArgumentOutOfRangeException(
            string paramName,
            object actualValue,
            string baseName,
            string resourceId,
            params object[] args)
        {
            if (string.IsNullOrEmpty(paramName))
            {
                throw this.NewArgumentNullException(nameof(paramName));
            }
            if (string.IsNullOrEmpty(baseName))
            {
                throw this.NewArgumentNullException(nameof(baseName));
            }
            if (string.IsNullOrEmpty(resourceId))
            {
                throw this.NewArgumentNullException(nameof(resourceId));
            }
            string message = ResourceManagerCache.FormatResourceString(Assembly.GetCallingAssembly(), baseName, resourceId, args);
            PSArgumentOutOfRangeException ofRangeException = new PSArgumentOutOfRangeException(paramName, actualValue, message);

            this.TraceException((Exception)ofRangeException);
            return(ofRangeException);
        }
Esempio n. 4
0
        private ActionPreference InquireForActionPreference(
            string message,
            ExecutionContext context)
        {
            InternalHostUserInterface      ui      = (InternalHostUserInterface)context.EngineHostInterface.UI;
            Collection <ChoiceDescription> choices = new Collection <ChoiceDescription>();
            string resourceString1 = ResourceManagerCache.GetResourceString("Parser", "ContinueLabel");
            string resourceString2 = ResourceManagerCache.GetResourceString("Parser", "ContinueHelpMessage");
            string resourceString3 = ResourceManagerCache.GetResourceString("Parser", "SilentlyContinueLabel");
            string resourceString4 = ResourceManagerCache.GetResourceString("Parser", "SilentlyContinueHelpMessage");
            string resourceString5 = ResourceManagerCache.GetResourceString("Parser", "BreakLabel");
            string resourceString6 = ResourceManagerCache.GetResourceString("Parser", "BreakHelpMessage");
            string resourceString7 = ResourceManagerCache.GetResourceString("Parser", "SuspendLabel");
            string helpMessage     = ResourceManagerCache.FormatResourceString("Parser", "SuspendHelpMessage");

            choices.Add(new ChoiceDescription(resourceString1, resourceString2));
            choices.Add(new ChoiceDescription(resourceString3, resourceString4));
            choices.Add(new ChoiceDescription(resourceString5, resourceString6));
            choices.Add(new ChoiceDescription(resourceString7, helpMessage));
            string resourceString8 = ResourceManagerCache.GetResourceString("Parser", "ExceptionActionPromptCaption");
            int    num;

            while ((num = ui.PromptForChoice(resourceString8, message, choices, 0)) == 3)
            {
                context.EngineHostInterface.EnterNestedPrompt();
            }
            if (num == 0)
            {
                return(ActionPreference.Continue);
            }
            return(num == 1 ? ActionPreference.SilentlyContinue : ActionPreference.Stop);
        }
        private static string BuildMessage(string commandName, Collection <string> missingPSSnapIns)
        {
            string        resourceId    = "RequiresMissingPSSnapIns";
            StringBuilder stringBuilder = new StringBuilder();

            if (missingPSSnapIns == null)
            {
                throw ScriptRequiresException.tracer.NewArgumentNullException(nameof(missingPSSnapIns));
            }
            foreach (string missingPsSnapIn in missingPSSnapIns)
            {
                stringBuilder.Append(missingPsSnapIn).Append(", ");
            }
            if (stringBuilder.Length > 1)
            {
                stringBuilder.Remove(stringBuilder.Length - 2, 2);
            }
            try
            {
                return(ResourceManagerCache.FormatResourceString("DiscoveryExceptions", resourceId, (object)commandName, (object)stringBuilder.ToString()));
            }
            catch (MissingManifestResourceException ex)
            {
                ScriptRequiresException.tracer.TraceException((Exception)ex);
                return(ResourceManagerCache.FormatResourceString("SessionStateStrings", "ResourceStringLoadError", (object)commandName, (object)"DiscoveryExceptions", (object)resourceId, (object)ex.Message));
            }
            catch (FormatException ex)
            {
                ScriptRequiresException.tracer.TraceException((Exception)ex);
                return(ResourceManagerCache.FormatResourceString("SessionStateStrings", "ResourceStringFormatError", (object)commandName, (object)"DiscoveryExceptions", (object)resourceId, (object)ex.Message));
            }
        }
Esempio n. 6
0
        internal PSNotSupportedException NewNotSupportedException()
        {
            PSNotSupportedException supportedException = new PSNotSupportedException(ResourceManagerCache.FormatResourceString(Assembly.GetAssembly(typeof(PSObject)), "AutomationExceptions", "NotSupported", (object)new StackTrace().GetFrame(0).ToString()));

            this.TraceException((Exception)supportedException);
            return(supportedException);
        }
        private void VerifyValue(object value)
        {
            if (value == null)
            {
                return;
            }
            value = PSObject.Base(value);
            Type type = value.GetType();

            foreach (Type handshakeFriendlyType in PSPrimitiveDictionary.handshakeFriendlyTypes)
            {
                if (type == handshakeFriendlyType)
                {
                    return;
                }
            }
            if (type.IsArray || type.Equals(typeof(ArrayList)))
            {
                foreach (object obj in (IEnumerable)value)
                {
                    this.VerifyValue(obj);
                }
            }
            else
            {
                throw new ArgumentException(ResourceManagerCache.FormatResourceString("Serialization", "PrimitiveHashtableInvalidValue", (object)value.GetType().FullName));
            }
        }
Esempio n. 8
0
        private void ProcessNewSubscriber(
            PSEventSubscriber subscriber,
            object source,
            string eventName,
            string sourceIdentifier,
            PSObject data,
            bool supportEvent,
            bool forwardEvent)
        {
            Delegate handler = (Delegate)null;

            if (this.eventAssembly == null)
            {
                this.debugMode     = new StackFrame(0, true).GetFileName() != null;
                this.eventAssembly = AppDomain.CurrentDomain.DefineDynamicAssembly(new AssemblyName("PSEventHandler"), AssemblyBuilderAccess.Run);
            }
            if (this.eventModule == null)
            {
                this.eventModule = this.eventAssembly.DefineDynamicModule("PSGenericEventModule", this.debugMode);
            }
            if (source != null)
            {
                if (!(source is Type type))
                {
                    type = source.GetType();
                }
                BindingFlags bindingAttr = BindingFlags.IgnoreCase | BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public;
                EventInfo    eventInfo   = type.GetEvent(eventName, bindingAttr);
                if (eventInfo == null)
                {
                    throw new ArgumentException(ResourceManagerCache.FormatResourceString("EventingResources", "CouldNotFindEvent", (object)eventName), nameof(eventName));
                }
                if (sourceIdentifier != null && sourceIdentifier.StartsWith("PowerShell.", StringComparison.OrdinalIgnoreCase))
                {
                    throw new ArgumentException(ResourceManagerCache.FormatResourceString("EventingResources", "ReservedIdentifier", (object)sourceIdentifier), nameof(sourceIdentifier));
                }
                if (type.GetProperty("EnableRaisingEvents") != null)
                {
                    type.InvokeMember("EnableRaisingEvents", BindingFlags.SetProperty, (Binder)null, source, new object[1]
                    {
                        (object)true
                    }, CultureInfo.CurrentCulture);
                }
                if (source is ManagementEventWatcher managementEventWatcher)
                {
                    managementEventWatcher.Start();
                }
                MethodInfo method = eventInfo.EventHandlerType.GetMethod("Invoke");
                if (method.ReturnType != typeof(void))
                {
                    throw new ArgumentException(ResourceManagerCache.GetResourceString("EventingResources", "NonVoidDelegateNotSupported"), nameof(eventName));
                }
                object eventHandler = this.GenerateEventHandler((PSEventManager)this, source, sourceIdentifier, data, method);
                handler = Delegate.CreateDelegate(eventInfo.EventHandlerType, eventHandler, "EventDelegate");
                eventInfo.AddEventHandler(source, handler);
            }
            lock (this.eventSubscribers)
                this.eventSubscribers[subscriber] = handler;
        }
Esempio n. 9
0
 private static string BuildPSSnapInDisplayName(PSSnapInNameVersionPair PSSnapin)
 {
     if (PSSnapin.Version == (Version)null)
     {
         return(PSSnapin.PSSnapInName);
     }
     return(ResourceManagerCache.FormatResourceString("DiscoveryExceptions", "PSSnapInNameVersion", (object)PSSnapin.PSSnapInName, (object)PSSnapin.Version));
 }
Esempio n. 10
0
        internal PSArgumentNullException NewArgumentNullException(
            string paramName)
        {
            string message = !string.IsNullOrEmpty(paramName) ? ResourceManagerCache.FormatResourceString(Assembly.GetAssembly(typeof(PSObject)), "AutomationExceptions", "ArgumentNull", (object)paramName) : throw new ArgumentNullException(nameof(paramName));
            PSArgumentNullException argumentNullException = new PSArgumentNullException(paramName, message);

            this.TraceException((Exception)argumentNullException);
            return(argumentNullException);
        }
Esempio n. 11
0
        internal static void ReportWrongProviderType(Cmdlet cmdlet, string providerId)
        {
            string message = ResourceManagerCache.FormatResourceString(nameof(PathUtils), "OutFile_ReadWriteFileNotFileSystemProvider", (object)providerId);

            cmdlet.ThrowTerminatingError(new ErrorRecord((Exception)PathUtils.tracer.NewInvalidOperationException(), "ReadWriteFileNotFileSystemProvider", ErrorCategory.InvalidArgument, (object)null)
            {
                ErrorDetails = new ErrorDetails(message)
            });
        }
Esempio n. 12
0
        internal static void ReportMultipleFilesNotSupported(Cmdlet cmdlet)
        {
            string message = ResourceManagerCache.FormatResourceString(nameof(PathUtils), "OutFile_MultipleFilesNotSupported");

            cmdlet.ThrowTerminatingError(new ErrorRecord((Exception)PathUtils.tracer.NewInvalidOperationException(), "ReadWriteMultipleFilesNotSupported", ErrorCategory.InvalidArgument, (object)null)
            {
                ErrorDetails = new ErrorDetails(message)
            });
        }
Esempio n. 13
0
        internal static void ReportWildcardingFailure(Cmdlet cmdlet, string filePath)
        {
            string message = ResourceManagerCache.FormatResourceString(nameof(PathUtils), "OutFile_DidNotResolveFile", (object)filePath);

            cmdlet.ThrowTerminatingError(new ErrorRecord((Exception) new FileNotFoundException(), "FileOpenFailure", ErrorCategory.OpenError, (object)filePath)
            {
                ErrorDetails = new ErrorDetails(message)
            });
        }
Esempio n. 14
0
        internal PSObjectDisposedException NewObjectDisposedException(
            string objectName)
        {
            string message = !string.IsNullOrEmpty(objectName) ? ResourceManagerCache.FormatResourceString(Assembly.GetAssembly(typeof(PSObject)), "AutomationExceptions", "ObjectDisposed", (object)objectName) : throw this.NewArgumentNullException(nameof(objectName));
            PSObjectDisposedException disposedException = new PSObjectDisposedException(objectName, message);

            this.TraceException((Exception)disposedException);
            return(disposedException);
        }
Esempio n. 15
0
 internal ScriptBlockToPowerShellNotSupportedException(
     string errorId,
     Exception innerException,
     string baseName,
     string resourceId,
     params object[] arguments)
     : base(ResourceManagerCache.FormatResourceString(baseName, resourceId, arguments), innerException)
 {
     this.SetErrorId(errorId);
     ScriptBlockToPowerShellNotSupportedException.tracer.TraceException((Exception)this);
 }
Esempio n. 16
0
        internal void RegisterJobSourceAdapter(Type jobSourceAdapterType)
        {
            object obj2 = null;

            if ((jobSourceAdapterType.FullName != null) && jobSourceAdapterType.FullName.EndsWith("WorkflowJobSourceAdapter", StringComparison.OrdinalIgnoreCase))
            {
                obj2 = jobSourceAdapterType.GetMethod("GetInstance").Invoke(null, null);
            }
            else
            {
                ConstructorInfo constructor = jobSourceAdapterType.GetConstructor(Type.EmptyTypes);
                if (!constructor.IsPublic)
                {
                    throw new InvalidOperationException(ResourceManagerCache.FormatResourceString("RemotingErrorIdStrings", "JobManagerRegistrationConstructorError", new object[] { jobSourceAdapterType.FullName }));
                }
                try
                {
                    obj2 = constructor.Invoke(null);
                }
                catch (MemberAccessException exception)
                {
                    this.Tracer.TraceException(exception);
                    throw;
                }
                catch (TargetInvocationException exception2)
                {
                    this.Tracer.TraceException(exception2);
                    throw;
                }
                catch (TargetParameterCountException exception3)
                {
                    this.Tracer.TraceException(exception3);
                    throw;
                }
                catch (NotSupportedException exception4)
                {
                    this.Tracer.TraceException(exception4);
                    throw;
                }
                catch (SecurityException exception5)
                {
                    this.Tracer.TraceException(exception5);
                    throw;
                }
            }
            if (obj2 != null)
            {
                lock (this._syncObject)
                {
                    this._sourceAdapters.Add(jobSourceAdapterType.Name, (JobSourceAdapter)obj2);
                }
            }
        }
Esempio n. 17
0
 internal static PSInvalidOperationException NewInvalidOperationException(Exception innerException, string baseName, string resourceId, params object[] args)
 {
     if (string.IsNullOrEmpty(baseName))
     {
         throw NewArgumentNullException("baseName");
     }
     if (string.IsNullOrEmpty(resourceId))
     {
         throw NewArgumentNullException("resourceId");
     }
     return(new PSInvalidOperationException(ResourceManagerCache.FormatResourceString(Assembly.GetCallingAssembly(), baseName, resourceId, args), innerException));
 }
Esempio n. 18
0
 internal static PSNotSupportedException NewNotSupportedException(string baseName, string resourceId, params object[] args)
 {
     if (string.IsNullOrEmpty(baseName))
     {
         throw NewArgumentNullException("baseName");
     }
     if (string.IsNullOrEmpty(resourceId))
     {
         throw NewArgumentNullException("resourceId");
     }
     return(new PSNotSupportedException(ResourceManagerCache.FormatResourceString(Assembly.GetCallingAssembly(), baseName, resourceId, args)));
 }
Esempio n. 19
0
 internal MetadataException(
     string errorId,
     Exception innerException,
     string baseName,
     string resourceId,
     params object[] arguments)
     : base(ResourceManagerCache.FormatResourceString(baseName, resourceId, arguments), innerException)
 {
     this.SetErrorCategory(ErrorCategory.MetadataError);
     this.SetErrorId(errorId);
     MetadataException.tracer.TraceException((Exception)this);
 }
Esempio n. 20
0
 internal static PSArgumentOutOfRangeException NewArgumentOutOfRangeException(string paramName, object actualValue, string baseName, string resourceId, params object[] args)
 {
     if (string.IsNullOrEmpty(paramName))
     {
         throw NewArgumentNullException("paramName");
     }
     if (string.IsNullOrEmpty(baseName))
     {
         throw NewArgumentNullException("baseName");
     }
     if (string.IsNullOrEmpty(resourceId))
     {
         throw NewArgumentNullException("resourceId");
     }
     return(new PSArgumentOutOfRangeException(paramName, actualValue, ResourceManagerCache.FormatResourceString(Assembly.GetCallingAssembly(), baseName, resourceId, args)));
 }
Esempio n. 21
0
 private static void WriteErrorOrWarning(bool writeErrorOnException, Cmdlet cmdlet, Exception exception, string identifier, JobSourceAdapter sourceAdapter)
 {
     try
     {
         if (writeErrorOnException)
         {
             cmdlet.WriteError(new ErrorRecord(exception, identifier, ErrorCategory.OpenError, sourceAdapter));
         }
         else
         {
             cmdlet.WriteWarning(ResourceManagerCache.FormatResourceString("RemotingErrorIdStrings", "JobSourceAdapterError", new object[] { exception.Message, sourceAdapter.Name }));
         }
     }
     catch (Exception)
     {
     }
 }
Esempio n. 22
0
        internal RemoteHelpInfo GetRemoteHelpInfo(
            ExecutionContext context,
            CommandInfo commandInfo)
        {
            if (string.IsNullOrEmpty(this.sections.forwardHelpTargetName) || string.IsNullOrEmpty(this.sections.remoteHelpRunspace))
            {
                return((RemoteHelpInfo)null);
            }
            object    valueToConvert = ((IScriptCommandInfo)commandInfo).ScriptBlock.SessionState.PSVariable.GetValue(this.sections.remoteHelpRunspace);
            PSSession result;

            if (valueToConvert == null || !LanguagePrimitives.TryConvertTo <PSSession>(valueToConvert, out result))
            {
                throw new InvalidOperationException(ResourceManagerCache.FormatResourceString("HelpErrors", "RemoteRunspaceNotAvailable"));
            }
            return(new RemoteHelpInfo(context, (RemoteRunspace)result.Runspace, this.sections.forwardHelpTargetName, this.sections.fowardHelpCategory, commandInfo.HelpCategory));
        }
Esempio n. 23
0
        internal PSNotSupportedException NewNotSupportedException(
            string baseName,
            string resourceId,
            params object[] args)
        {
            if (string.IsNullOrEmpty(baseName))
            {
                throw this.NewArgumentNullException(nameof(baseName));
            }
            if (string.IsNullOrEmpty(resourceId))
            {
                throw this.NewArgumentNullException(nameof(resourceId));
            }
            PSNotSupportedException supportedException = new PSNotSupportedException(ResourceManagerCache.FormatResourceString(Assembly.GetCallingAssembly(), baseName, resourceId, args));

            this.TraceException((Exception)supportedException);
            return(supportedException);
        }
Esempio n. 24
0
        private static RuntimeException NewBackupInterpreterException(
            Type exceptionType,
            Token errToken,
            string errorId,
            Exception innerException)
        {
            string message;

            if (innerException == null)
            {
                message = ResourceManagerCache.FormatResourceString("Parser", "BackupParserMessage", (object)errorId);
            }
            else
            {
                message = ResourceManagerCache.FormatResourceString("Parser", "BackupParserMessageWithException", (object)errorId, (object)innerException.Message);
            }
            return(InterpreterError.NewInterpreterExceptionByMessage(exceptionType, errToken, message, errorId, innerException));
        }
        private static string BuildMessage(
            string commandName,
            uint lineNumber,
            string first,
            string second,
            bool forShellId)
        {
            string resourceId = !forShellId ? "RequiresPSVersionNotCompatible" : (!string.IsNullOrEmpty(first) ? (string.IsNullOrEmpty(second) ? "RequiresInterpreterNotCompatibleNoPath" : "RequiresInterpreterNotCompatible") : "RequiresShellIDInvalidForSingleShell");

            try
            {
                return(ResourceManagerCache.FormatResourceString("DiscoveryExceptions", resourceId, (object)commandName, (object)lineNumber, (object)first, (object)second));
            }
            catch (MissingManifestResourceException ex)
            {
                ScriptRequiresException.tracer.TraceException((Exception)ex);
                return(ResourceManagerCache.FormatResourceString("SessionStateStrings", "ResourceStringLoadError", (object)commandName, (object)"DiscoveryExceptions", (object)resourceId, (object)ex.Message));
            }
            catch (FormatException ex)
            {
                ScriptRequiresException.tracer.TraceException((Exception)ex);
                return(ResourceManagerCache.FormatResourceString("SessionStateStrings", "ResourceStringFormatError", (object)commandName, (object)"DiscoveryExceptions", (object)resourceId, (object)ex.Message));
            }
        }
Esempio n. 26
0
        public override string ToString()
        {
            Assembly assembly = Assembly.GetAssembly(this.GetType());

            return(this.Type == Breakpoint.BreakpointType.Line ? ResourceManagerCache.FormatResourceString(assembly, "DebuggerStrings", "LineBreakpointString", (object)this.Script, (object)this.Line) : ResourceManagerCache.FormatResourceString(assembly, "DebuggerStrings", "StatementBreakpointString", (object)this.Script, (object)this.Line, (object)this.Column));
        }
Esempio n. 27
0
        private static string GetSignatureStatusMessage(
            SignatureStatus status,
            uint error,
            string filePath)
        {
            using (Signature.tracer.TraceMethod())
            {
                string str1       = (string)null;
                string resourceId = (string)null;
                string str2       = (string)null;
                switch (status)
                {
                case SignatureStatus.Valid:
                    resourceId = "MshSignature_Valid";
                    break;

                case SignatureStatus.UnknownError:
                    str1 = new Win32Exception(SecuritySupport.GetIntFromDWORD(error)).Message;
                    break;

                case SignatureStatus.NotSigned:
                    resourceId = "MshSignature_NotSigned";
                    str2       = filePath;
                    break;

                case SignatureStatus.HashMismatch:
                    resourceId = "MshSignature_HashMismatch";
                    str2       = filePath;
                    break;

                case SignatureStatus.NotTrusted:
                    resourceId = "MshSignature_NotTrusted";
                    str2       = filePath;
                    break;

                case SignatureStatus.NotSupportedFileFormat:
                    resourceId = "MshSignature_NotSupportedFileFormat";
                    str2       = System.IO.Path.GetExtension(filePath);
                    if (string.IsNullOrEmpty(str2))
                    {
                        resourceId = "MshSignature_NotSupportedFileFormat_NoExtension";
                        str2       = (string)null;
                        break;
                    }
                    break;

                case SignatureStatus.Incompatible:
                    resourceId = error != 2148073480U ? "MshSignature_Incompatible" : "MshSignature_Incompatible_HashAlgorithm";
                    str2       = filePath;
                    break;
                }
                if (str1 == null)
                {
                    if (str2 == null)
                    {
                        str1 = ResourceManagerCache.GetResourceString("MshSignature", resourceId);
                    }
                    else
                    {
                        str1 = ResourceManagerCache.FormatResourceString("MshSignature", resourceId, (object)str2);
                    }
                }
                return(str1);
            }
        }
Esempio n. 28
0
 private void InitPowerShell(bool syncCall)
 {
     if (this._commands == null || this._commands.Count == 0)
     {
         throw RemotePipeline._trace.NewInvalidOperationException("Runspace", "NoCommandInPipeline");
     }
     if (this._pipelineStateInfo.State != PipelineState.NotStarted)
     {
         InvalidPipelineStateException pipelineStateException = new InvalidPipelineStateException(ResourceManagerCache.FormatResourceString("Runspace", "PipelineReInvokeNotAllowed"), this._pipelineStateInfo.State, PipelineState.NotStarted);
         RemotePipeline._trace.TraceException((Exception)pipelineStateException);
         throw pipelineStateException;
     }
     ((RemoteRunspace)this._runspace).DoConcurrentCheckAndAddToRunningPipelines(this, syncCall);
     this._powershell.InitForRemotePipeline(this._commands, (ObjectStreamBase)this._inputStream, (ObjectStreamBase)this._outputStream, (ObjectStreamBase)this._errorStream, new PSInvocationSettings()
     {
         AddToHistory = this._addToHistory
     }, this.RedirectShellErrorOutputPipe);
     this._powershell.RemotePowerShell.HostCallReceived += new EventHandler <RemoteDataEventArgs <RemoteHostCall> >(this.HandleHostCallReceived);
 }
Esempio n. 29
0
 public override Collection <PSObject> Invoke(IEnumerable input)
 {
     if (input == null)
     {
         this.InputStream.Close();
     }
     this.InitPowerShell(true);
     try
     {
         return(this._powershell.Invoke(input));
     }
     catch (InvalidRunspacePoolStateException ex)
     {
         InvalidRunspaceStateException runspaceStateException = new InvalidRunspaceStateException(ResourceManagerCache.FormatResourceString("Runspace", "RunspaceNotOpenForPipeline", (object)this._runspace.RunspaceStateInfo.State.ToString()), this._runspace.RunspaceStateInfo.State, RunspaceState.Opened);
         RemotePipeline._trace.TraceException((Exception)runspaceStateException);
         throw runspaceStateException;
     }
 }
Esempio n. 30
0
 public override void InvokeAsync()
 {
     this.InitPowerShell(false);
     try
     {
         this._powershell.BeginInvoke();
     }
     catch (InvalidRunspacePoolStateException ex)
     {
         InvalidRunspaceStateException runspaceStateException = new InvalidRunspaceStateException(ResourceManagerCache.FormatResourceString("Runspace", "RunspaceNotOpenForPipeline", (object)this._runspace.RunspaceStateInfo.State.ToString()), this._runspace.RunspaceStateInfo.State, RunspaceState.Opened);
         RemotePipeline._trace.TraceException((Exception)runspaceStateException);
         throw runspaceStateException;
     }
 }