internal RemoteRunspace(TypeTable typeTable, RunspaceConnectionInfo connectionInfo, PSHost host, PSPrimitiveDictionary applicationArguments, string name = null, int id = -1) { this._runningPipelines = new ArrayList(); this._syncRoot = new object(); this._runspaceStateInfo = new System.Management.Automation.Runspaces.RunspaceStateInfo(RunspaceState.BeforeOpen); this._version = PSVersionInfo.PSVersion; this._runspaceEventQueue = new Queue<RunspaceEventQueueItem>(); this.id = -1; PSEtwLog.SetActivityIdForCurrentThread(base.InstanceId); this._applicationArguments = applicationArguments; PSEtwLog.LogOperationalVerbose(PSEventId.RunspaceConstructor, PSOpcode.Constructor, PSTask.CreateRunspace, PSKeyword.UseAlwaysOperational, new object[] { base.InstanceId.ToString() }); if (connectionInfo is WSManConnectionInfo) { this._connectionInfo = ((WSManConnectionInfo) connectionInfo).Copy(); this._originalConnectionInfo = ((WSManConnectionInfo) connectionInfo).Copy(); } else if (connectionInfo is NewProcessConnectionInfo) { this._connectionInfo = ((NewProcessConnectionInfo) connectionInfo).Copy(); this._originalConnectionInfo = ((NewProcessConnectionInfo) connectionInfo).Copy(); } this._runspacePool = new System.Management.Automation.Runspaces.RunspacePool(1, 1, typeTable, host, applicationArguments, connectionInfo, name); this.Id = id; this.SetEventHandlers(); }
/// <summary> /// Constructor which creates a RunspacePool using the /// supplied <paramref name="connectionInfo"/>, <paramref name="minRunspaces"/> /// and <paramref name="maxRunspaces"/> /// </summary> /// <param name="maxRunspaces"> /// The maximum number of Runspaces that can exist in this pool. /// Should be greater than or equal to 1. /// </param> /// <param name="minRunspaces"> /// The minimum number of Runspaces that can exist in this pool. /// Should be greater than or equal to 1. /// </param> /// <param name="typeTable"> /// The TypeTable to use while deserializing/serializing remote objects. /// TypeTable has the following information used by serializer: /// 1. SerializationMethod /// 2. SerializationDepth /// 3. SpecificSerializationProperties /// TypeTable has the following information used by deserializer: /// 1. TargetTypeForDeserialization /// 2. TypeConverter /// </param> /// <param name="host">Host associated with this runspacepool</param> /// <param name="applicationArguments"> /// Application arguments the server can see in <see cref="System.Management.Automation.Remoting.PSSenderInfo.ApplicationArguments"/> /// </param> /// <param name="connectionInfo">The RunspaceConnectionInfo object /// which identifies this runspace pools connection to the server /// </param> /// <param name="name">Session name.</param> /// <exception cref="ArgumentException"> /// Maximum runspaces is less than 1. /// Minimum runspaces is less than 1. /// </exception> /// <exception cref="ArgumentException"> /// ConnectionInfo specified is null /// </exception> internal RemoteRunspacePoolInternal(int minRunspaces, int maxRunspaces, TypeTable typeTable, PSHost host, PSPrimitiveDictionary applicationArguments, RunspaceConnectionInfo connectionInfo, string name = null) : base(minRunspaces, maxRunspaces) { if (connectionInfo == null) { throw PSTraceSource.NewArgumentNullException("WSManConnectionInfo"); } PSEtwLog.LogOperationalVerbose(PSEventId.RunspacePoolConstructor, PSOpcode.Constructor, PSTask.CreateRunspace, PSKeyword.UseAlwaysOperational, instanceId.ToString(), minPoolSz.ToString(CultureInfo.InvariantCulture), maxPoolSz.ToString(CultureInfo.InvariantCulture)); _connectionInfo = connectionInfo.InternalCopy(); this.host = host; ApplicationArguments = applicationArguments; AvailableForConnection = false; DispatchTable = new DispatchTable<object>(); _runningPowerShells = new System.Collections.Concurrent.ConcurrentStack<PowerShell>(); if (!string.IsNullOrEmpty(name)) { this.Name = name; } CreateDSHandler(typeTable); }
internal RemoteRunspacePoolInternal(int minRunspaces, int maxRunspaces, TypeTable typeTable, PSHost host, PSPrimitiveDictionary applicationArguments, RunspaceConnectionInfo connectionInfo, string name = null) : base(minRunspaces, maxRunspaces) { this.applicationPrivateDataReceived = new ManualResetEvent(false); this.friendlyName = string.Empty; if (connectionInfo == null) { throw PSTraceSource.NewArgumentNullException("WSManConnectionInfo"); } PSEtwLog.LogOperationalVerbose(PSEventId.RunspacePoolConstructor, PSOpcode.Constructor, PSTask.CreateRunspace, PSKeyword.UseAlwaysOperational, new object[] { this.instanceId.ToString(), this.minPoolSz.ToString(CultureInfo.InvariantCulture), this.maxPoolSz.ToString(CultureInfo.InvariantCulture) }); if (connectionInfo is WSManConnectionInfo) { this.connectionInfo = ((WSManConnectionInfo) connectionInfo).Copy(); } else if (connectionInfo is NewProcessConnectionInfo) { this.connectionInfo = ((NewProcessConnectionInfo) connectionInfo).Copy(); } base.host = host; this.applicationArguments = applicationArguments; this.availableForConnection = false; this.dispatchTable = new DispatchTable<object>(); if (!string.IsNullOrEmpty(name)) { this.Name = name; } this.CreateDSHandler(typeTable); }
internal static void Dispatch(BaseClientTransportManager transportManager, PSHost clientHost, PSDataCollectionStream<ErrorRecord> errorStream, ObjectStream methodExecutorStream, bool isMethodExecutorStreamEnabled, RemoteRunspacePoolInternal runspacePool, Guid clientPowerShellId, System.Management.Automation.Remoting.RemoteHostCall remoteHostCall) { ClientMethodExecutor executor = new ClientMethodExecutor(transportManager, clientHost, runspacePool.InstanceId, clientPowerShellId, remoteHostCall); if (clientPowerShellId == Guid.Empty) { executor.Execute(errorStream); } else { bool flag = false; if (clientHost != null) { PSObject privateData = clientHost.PrivateData; if (privateData != null) { PSNoteProperty property = privateData.Properties["AllowSetShouldExitFromRemote"] as PSNoteProperty; flag = ((property != null) && (property.Value is bool)) ? ((bool) property.Value) : false; } } if ((remoteHostCall.IsSetShouldExit && isMethodExecutorStreamEnabled) && !flag) { runspacePool.Close(); } else if (isMethodExecutorStreamEnabled) { methodExecutorStream.Write(executor); } else { executor.Execute(errorStream); } } }
internal RemoteRunspacePoolInternal(Guid instanceId, string name, bool isDisconnected, ConnectCommandInfo[] connectCommands, RunspaceConnectionInfo connectionInfo, PSHost host, TypeTable typeTable) : base(1, 1) { this.applicationPrivateDataReceived = new ManualResetEvent(false); this.friendlyName = string.Empty; if (connectCommands == null) { throw PSTraceSource.NewArgumentNullException("ConnectCommandInfo[]"); } if (connectionInfo == null) { throw PSTraceSource.NewArgumentNullException("WSManConnectionInfo"); } if (connectionInfo is WSManConnectionInfo) { this.connectionInfo = ((WSManConnectionInfo) connectionInfo).Copy(); } base.instanceId = instanceId; base.minPoolSz = -1; base.maxPoolSz = -1; PSEtwLog.LogOperationalVerbose(PSEventId.RunspacePoolConstructor, PSOpcode.Constructor, PSTask.CreateRunspace, PSKeyword.UseAlwaysOperational, new object[] { instanceId.ToString(), this.minPoolSz.ToString(CultureInfo.InvariantCulture), this.maxPoolSz.ToString(CultureInfo.InvariantCulture) }); this.connectCommands = connectCommands; this.Name = name; base.host = host; this.dispatchTable = new DispatchTable<object>(); this.SetRunspacePoolState(new RunspacePoolStateInfo(RunspacePoolState.Disconnected, null)); this.CreateDSHandler(typeTable); this.availableForConnection = isDisconnected; }
public void Restore(PSHost host = null) { // Delete environment variables that are in the current // environment but not in the one being restored. var currentVars = Environment.GetEnvironmentVariables(); foreach (DictionaryEntry entry in currentVars) { if (!Variables.Contains(entry.Key)) { Environment.SetEnvironmentVariable((string)entry.Key, null); } } // Now set all the environment variables defined in this frame foreach (DictionaryEntry entry in Variables) { var name = (string)entry.Key; var value = (string)entry.Value; Environment.SetEnvironmentVariable(name, value); } if (host != null) { host.UI.RawUI.WindowTitle = WindowTitle; host.UI.RawUI.BackgroundColor = BackgroundColor; host.UI.RawUI.ForegroundColor = ForegroundColor; } }
internal static SPOnlineConnection InstantiateSPOnlineConnection(Uri url, string realm, string clientId, string clientSecret, PSHost host, int minimalHealthScore, int retryCount, int retryWait, int requestTimeout, bool skipAdminCheck = false) { Core.AuthenticationManager authManager = new Core.AuthenticationManager(); if (realm == null) { realm = GetRealmFromTargetUrl(url); } var context = authManager.GetAppOnlyAuthenticatedContext(url.ToString(), realm, clientId, clientSecret); context.ApplicationName = Properties.Resources.ApplicationName; context.RequestTimeout = requestTimeout; var connectionType = ConnectionType.OnPrem; if (url.Host.ToUpperInvariant().EndsWith("SHAREPOINT.COM")) { connectionType = ConnectionType.O365; } if (skipAdminCheck == false) { if (IsTenantAdminSite(context)) { connectionType = ConnectionType.TenantAdmin; } } return new SPOnlineConnection(context, connectionType, minimalHealthScore, retryCount, retryWait, null, url.ToString()); }
internal TypeInfoDataBaseManager(IEnumerable<string> formatFiles, bool isShared, AuthorizationManager authorizationManager, PSHost host) { this.databaseLock = new object(); this.updateDatabaseLock = new object(); this.formatFileList = new List<string>(); Collection<PSSnapInTypeAndFormatErrors> files = new Collection<PSSnapInTypeAndFormatErrors>(); Collection<string> loadErrors = new Collection<string>(); foreach (string str in formatFiles) { if (string.IsNullOrEmpty(str) || !Path.IsPathRooted(str)) { throw PSTraceSource.NewArgumentException("formatFiles", "FormatAndOutXmlLoadingStrings", "FormatFileNotRooted", new object[] { str }); } PSSnapInTypeAndFormatErrors item = new PSSnapInTypeAndFormatErrors(string.Empty, str) { Errors = loadErrors }; files.Add(item); this.formatFileList.Add(str); } MshExpressionFactory expressionFactory = new MshExpressionFactory(); List<XmlLoaderLoggerEntry> logEntries = null; this.LoadFromFile(files, expressionFactory, true, authorizationManager, host, false, out logEntries); this.isShared = isShared; if (loadErrors.Count > 0) { throw new FormatTableLoadException(loadErrors); } }
/// <summary> /// The principal constructor that most hosts will use when creating /// an instance of the automation engine. It allows you to pass in an /// instance of PSHost that provides the host-specific I/O routines, etc. /// </summary> internal AutomationEngine(PSHost hostInterface, RunspaceConfiguration runspaceConfiguration, InitialSessionState iss) { #if !CORECLR// There is no control panel items in CSS // Update the env variable PathEXT to contain .CPL var pathext = Environment.GetEnvironmentVariable("PathEXT"); pathext = pathext ?? string.Empty; bool cplExist = false; if (pathext != string.Empty) { string[] entries = pathext.Split(Utils.Separators.Semicolon); foreach (string entry in entries) { string ext = entry.Trim(); if (ext.Equals(".CPL", StringComparison.OrdinalIgnoreCase)) { cplExist = true; break; } } } if (!cplExist) { pathext = (pathext == string.Empty) ? ".CPL" : pathext.EndsWith(";", StringComparison.OrdinalIgnoreCase) ? (pathext + ".CPL") : (pathext + ";.CPL"); Environment.SetEnvironmentVariable("PathEXT", pathext); } #endif if (runspaceConfiguration != null) { Context = new ExecutionContext(this, hostInterface, runspaceConfiguration); } else { Context = new ExecutionContext(this, hostInterface, iss); } EngineParser = new Language.Parser(); CommandDiscovery = new CommandDiscovery(Context); // Initialize providers before loading types so that any ScriptBlocks in the // types.ps1xml file can be parsed. // Bind the execution context with RunspaceConfiguration. // This has the side effect of initializing cmdlet cache and providers from runspace configuration. if (runspaceConfiguration != null) { runspaceConfiguration.Bind(Context); } else { // Load the iss, resetting everything to it's defaults... iss.Bind(Context, /*updateOnly*/ false); } InitialSessionState.SetSessionStateDrive(Context, true); InitialSessionState.CreateQuestionVariable(Context); }
public ExecutionContext(PSHost host, RunspaceConfiguration config) : this() { RunspaceConfiguration = config; LocalHost = host; SessionStateGlobal = new SessionStateGlobal(this); SessionState = new SessionState(SessionStateGlobal); }
internal FormatTable(IEnumerable<string> formatFiles, AuthorizationManager authorizationManager, PSHost host) { if (formatFiles == null) { throw PSTraceSource.NewArgumentNullException("formatFiles"); } this.formatDBMgr = new TypeInfoDataBaseManager(formatFiles, true, authorizationManager, host); }
private HostIOInterceptor() { externalUI = null; subscribers = new List<WeakReference>(); writeCache = new StringBuilder(); paused = false; host = null; }
// TODO: make sure to implement a Singleton DefaultRunspace pattern //internal static LocalRunspace DefaultRunspace { get; private set; } public LocalRunspace(PSHost host, RunspaceConfiguration configuration) { DefaultRunspace = this; PSHost = host; _runspaceConfiguration = configuration; ExecutionContext = new ExecutionContext(host, configuration); ExecutionContext.CurrentRunspace = this; }
public static Runspace CreateRunspace(PSHost host) { if (host == null) { throw PSTraceSource.NewArgumentNullException("host"); } return CreateRunspace(host, RunspaceConfiguration.Create()); }
private ClientMethodExecutor(BaseClientTransportManager transportManager, PSHost clientHost, Guid clientRunspacePoolId, Guid clientPowerShellId, System.Management.Automation.Remoting.RemoteHostCall remoteHostCall) { this._transportManager = transportManager; this._remoteHostCall = remoteHostCall; this._clientHost = clientHost; this._clientRunspacePoolId = clientRunspacePoolId; this._clientPowerShellId = clientPowerShellId; }
internal HostInfo(PSHost host) { CheckHostChain(host, ref this._isHostNull, ref this._isHostUINull, ref this._isHostRawUINull); if (!this._isHostUINull && !this._isHostRawUINull) { this._hostDefaultData = System.Management.Automation.Remoting.HostDefaultData.Create(host.UI.RawUI); } }
internal EngineIntrinsics(ExecutionContext context) { if (context == null) { throw new ArgumentNullException("context"); } this._context = context; this._host = context.EngineHostInterface; }
internal RunspacePool ToPool(PSHost Host) { RunspacePool pool = RunspaceFactory.CreateRunspacePool(1, this.PoolSize, this.InitialSessionState, Host); //RunspacePool pool = RunspaceFactory.CreateRunspacePool(1, this.PoolSize); pool.ApartmentState = this.ApartmentState; pool.CleanupInterval = this.CleanupInterval; pool.ThreadOptions = this.ThreadOptions; return pool; }
internal MshCommandRuntime(System.Management.Automation.ExecutionContext context, CommandInfo commandInfo, InternalCommand thisCommand) { this.context = context; this.host = context.EngineHostInterface; this.CBhost = context.EngineHostInterface; this.commandInfo = commandInfo; this.thisCommand = thisCommand; this.shouldLogPipelineExecutionDetail = this.InitShouldLogPipelineExecutionDetail(); }
internal RemoteHostResponse ExecuteNonVoidMethod(PSHost clientHost) { if (clientHost == null) { throw RemoteHostExceptions.NewNullClientHostException(); } object instance = this.SelectTargetObject(clientHost); return this.ExecuteNonVoidMethodOnObject(instance); }
internal InternalHost(PSHost externalHost, ExecutionContext executionContext) { this.externalHostRef = new ObjectRef<PSHost>(externalHost); this.executionContext = executionContext; PSHostUserInterface uI = externalHost.UI; this.internalUIRef = new ObjectRef<InternalHostUserInterface>(new InternalHostUserInterface(uI, this)); this.zeroGuid = new Guid(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); this.idResult = this.zeroGuid; }
/// <summary> /// Constructor for ClientMethodExecutor. /// </summary> private ClientMethodExecutor(BaseClientTransportManager transportManager, PSHost clientHost, Guid clientRunspacePoolId, Guid clientPowerShellId, RemoteHostCall remoteHostCall) { Dbg.Assert(transportManager != null, "Expected transportManager != null"); Dbg.Assert(remoteHostCall != null, "Expected remoteHostCall != null"); _transportManager = transportManager; _remoteHostCall = remoteHostCall; _clientHost = clientHost; _clientRunspacePoolId = clientRunspacePoolId; _clientPowerShellId = clientPowerShellId; }
internal static ExecutionContextForStepping PrepareExecutionContext(ExecutionContext ctxt, PSInformationalBuffers newBuffers, PSHost newHost) { ExecutionContextForStepping stepping = new ExecutionContextForStepping(ctxt) { originalInformationalBuffers = ctxt.InternalHost.InternalUI.GetInformationalMessageBuffers(), originalHost = ctxt.InternalHost.ExternalHost }; ctxt.InternalHost.InternalUI.SetInformationalMessageBuffers(newBuffers); ctxt.InternalHost.SetHostRef(newHost); return stepping; }
// void ContinueCommand(RemoteRunspace remoteRunspace, Pipeline cmd, PSHost host, bool inDebugMode, ExecutionContext context) public static void ContinueCommand(Runspace remoteRunspace, Pipeline cmd, PSHost host, bool inDebugMode, Runspace oldRunspace) { var remoteRunspaceType = typeof(EnterPSSessionCommand).Assembly.GetType("System.Management.Automation.RemoteRunspace"); var executionContextType = typeof(EnterPSSessionCommand).Assembly.GetType("System.Management.Automation.ExecutionContext"); var executionContext = typeof (Runspace).GetProperty("ExecutionContext", BindingFlags.Instance | BindingFlags.NonPublic).GetGetMethod(true).Invoke(remoteRunspace, new object[]{}); var method = typeof(EnterPSSessionCommand).GetMethod("ContinueCommand", BindingFlags.NonPublic | BindingFlags.Static, null, new[] { remoteRunspaceType, typeof(Pipeline), typeof(PSHost), typeof(bool), executionContextType }, null); method.Invoke(null, new[] { remoteRunspace, cmd, host, inDebugMode, executionContext}); }
internal LocalRunspace(PSHost host, RunspaceConfiguration configuration, InitialSessionState initialSessionState) { DefaultRunspace = this; PSHost = host; if (configuration == null) _runspaceConfiguration = RunspaceFactory.DefaultRunspaceConfiguration; else _runspaceConfiguration = configuration; ExecutionContext = new ExecutionContext(host, configuration); ExecutionContext.CurrentRunspace = this; _initialSessionState = initialSessionState; }
public static Runspace CreateRunspace(PSHost host, InitialSessionState initialSessionState) { if (host == null) { throw PSTraceSource.NewArgumentNullException("host"); } if (initialSessionState == null) { throw PSTraceSource.NewArgumentNullException("initialSessionState"); } return new LocalRunspace(host, initialSessionState); }
public HostOutputWriter(PSHost host) : base() { try { Rows = host.UI.RawUI.BufferSize.Height; Columns = host.UI.RawUI.BufferSize.Width; } catch (IOException) { // this could occur if Pash is used in a process and the I/O is redirected. We just use the default values then } _host = host; }
private static bool IsUIAllowed(PSHost host) { uint num = 0; if (!DetectUIHelper.IsRemoteCommand(host)) { int id = Process.GetCurrentProcess().Id; if (NativeMethods.ProcessIdToSessionId(id, out num)) { if (num != 0) { if (Environment.UserInteractive) { string[] commandLineArgs = Environment.GetCommandLineArgs(); bool flag = true; string[] strArrays = commandLineArgs; int num1 = 0; while (num1 < (int)strArrays.Length) { string str = strArrays[num1]; if (str.Length < 4 || !"-noninteractive".StartsWith(str, StringComparison.OrdinalIgnoreCase)) { num1++; } else { flag = false; break; } } return flag; } else { return false; } } else { return false; } } else { return false; } } else { return false; } }
public EnvironmentFrame(string description = "", PSHost host = null) { WindowTitle = host == null ? "" : host.UI.RawUI.WindowTitle; BackgroundColor = host == null ? ConsoleColor.DarkBlue : host.UI.RawUI.BackgroundColor; ForegroundColor = host == null ? ConsoleColor.White : host.UI.RawUI.ForegroundColor; Timestamp = DateTime.Now; Description = description ?? String.Empty; var envvars = Environment.GetEnvironmentVariables(); _variables = new SortedDictionary<string, string>(); foreach (DictionaryEntry entry in envvars) { _variables.Add(entry.Key, entry.Value); } }
internal void Bind(ExecutionContext executionContext) { this._host = executionContext.EngineHostInterface; this.Initialize(executionContext); this.Assemblies.OnUpdate += new RunspaceConfigurationEntryUpdateEventHandler(executionContext.UpdateAssemblyCache); runspaceInitTracer.WriteLine("initializing assembly list", new object[0]); try { this.Assemblies.Update(true); } catch (RuntimeException exception) { runspaceInitTracer.WriteLine("assembly list initialization failed", new object[0]); MshLog.LogEngineHealthEvent(executionContext, 0x67, exception, Severity.Error); executionContext.ReportEngineStartupError(exception.Message); throw; } if (executionContext.CommandDiscovery != null) { this.Cmdlets.OnUpdate += new RunspaceConfigurationEntryUpdateEventHandler(executionContext.CommandDiscovery.UpdateCmdletCache); runspaceInitTracer.WriteLine("initializing cmdlet list", new object[0]); try { this.Cmdlets.Update(true); } catch (PSNotSupportedException exception2) { runspaceInitTracer.WriteLine("cmdlet list initialization failed", new object[0]); MshLog.LogEngineHealthEvent(executionContext, 0x67, exception2, Severity.Error); executionContext.ReportEngineStartupError(exception2.Message); throw; } } if (executionContext.EngineSessionState != null) { this.Providers.OnUpdate += new RunspaceConfigurationEntryUpdateEventHandler(executionContext.EngineSessionState.UpdateProviders); runspaceInitTracer.WriteLine("initializing provider list", new object[0]); try { this.Providers.Update(true); } catch (PSNotSupportedException exception3) { runspaceInitTracer.WriteLine("provider list initialization failed", new object[0]); MshLog.LogEngineHealthEvent(executionContext, 0x67, exception3, Severity.Error); executionContext.ReportEngineStartupError(exception3.Message); throw; } } }
/// <summary> /// Validates the external script info. /// </summary> /// <param name="host"></param> public void ValidateScriptInfo(Host.PSHost host) { if (!_signatureChecked) { ExecutionContext context = Context ?? LocalPipeline.GetExecutionContextFromTLS(); ReadScriptContents(); // We have no way to check the signature w/o context because we don't have // an AuthorizationManager. This can happen during initialization when trying // to get the CommandMetadata for a script (either to prepopulate the metadata // or creating a proxy). If context can be null under any other circumstances, // we need to make sure it's acceptable if the parser is invoked on unsigned scripts. if (context != null) { CommandDiscovery.ShouldRun(context, host, this, CommandOrigin.Internal); _signatureChecked = true; } } }
internal SPOnlineConnection(ClientContext context, ConnectionType connectionType, int minimalHealthScore, int retryCount, int retryWait, PSCredential credential, string clientId, string clientSecret, string url, string tenantAdminUrl, string pnpVersionTag, System.Management.Automation.Host.PSHost host, bool disableTelemetry, InitializationType initializationType) : this(context, connectionType, minimalHealthScore, retryCount, retryWait, credential, url, tenantAdminUrl, pnpVersionTag, host, disableTelemetry, initializationType) { this.ClientId = clientId; this.ClientSecret = clientSecret; }
internal SPOnlineConnection(ClientContext context, ConnectionType connectionType, int minimalHealthScore, int retryCount, int retryWait, PSCredential credential, string url, string tenantAdminUrl, string pnpVersionTag, System.Management.Automation.Host.PSHost host, bool disableTelemetry, InitializationType initializationType) { if (!disableTelemetry) { InitializeTelemetry(context, host, initializationType); } var coreAssembly = Assembly.GetExecutingAssembly(); userAgent = $"NONISV|SharePointPnP|PnPPS/{((AssemblyFileVersionAttribute)coreAssembly.GetCustomAttribute(typeof(AssemblyFileVersionAttribute))).Version}"; if (context == null) { throw new ArgumentNullException(nameof(context)); } Context = context; Context.ExecutingWebRequest += Context_ExecutingWebRequest; ConnectionType = connectionType; MinimalHealthScore = minimalHealthScore; RetryCount = retryCount; RetryWait = retryWait; PSCredential = credential; TenantAdminUrl = tenantAdminUrl; ContextCache = new List <ClientContext> { context }; PnPVersionTag = pnpVersionTag; Url = (new Uri(url)).AbsoluteUri; ConnectionMethod = ConnectionMethod.Credentials; }