protected override List <ActivityImplementationContext> GetImplementation(NativeActivityContext context) { bool hasValue; string[] strArrays = this.PSComputerName.Get(context); string[] strArrays1 = this.PSConnectionUri.Get(context); PSSessionOption pSSessionOption = this.PSSessionOption.Get(context); List <ActivityImplementationContext> activityImplementationContexts = new List <ActivityImplementationContext>(); RemotingBehavior remotingBehavior = this.PSRemotingBehavior.Get(context); if (this.PSRemotingBehavior.Expression == null) { remotingBehavior = RemotingBehavior.PowerShell; } if (remotingBehavior != RemotingBehavior.Custom || this.SupportsCustomRemoting) { if (this.PSCredential.Get(context) != null) { AuthenticationMechanism?nullable = this.PSAuthentication.Get(context); if (nullable.GetValueOrDefault() != AuthenticationMechanism.NegotiateWithImplicitCredential) { hasValue = false; } else { hasValue = nullable.HasValue; } if (hasValue) { throw new ArgumentException(Resources.CredentialParameterCannotBeSpecifiedWithNegotiateWithImplicitAuthentication); } } if ((remotingBehavior == RemotingBehavior.PowerShell || PSActivity.IsActivityInlineScript(this) && base.RunWithCustomRemoting(context)) && (this.GetIsComputerNameSpecified(context) || strArrays1 != null && (int)strArrays1.Length > 0)) { AuthenticationMechanism?nullable1 = this.PSAuthentication.Get(context); bool?nullable2 = this.PSAllowRedirection.Get(context); List <WSManConnectionInfo> connectionInfo = ActivityUtils.GetConnectionInfo(strArrays, strArrays1, this.PSCertificateThumbprint.Get(context), this.PSConfigurationName.Get(context), this.PSUseSsl.Get(context), this.PSPort.Get(context), this.PSApplicationName.Get(context), this.PSCredential.Get(context), nullable1.GetValueOrDefault(AuthenticationMechanism.Default), nullable2.GetValueOrDefault(false), pSSessionOption); foreach (WSManConnectionInfo wSManConnectionInfo in connectionInfo) { this.CreatePowerShellInstance(context, wSManConnectionInfo, activityImplementationContexts); } } else { this.CreatePowerShellInstance(context, null, activityImplementationContexts); } return(activityImplementationContexts); } else { throw new ArgumentException(Resources.CustomRemotingNotSupported); } }
protected override List <ActivityImplementationContext> GetImplementation(NativeActivityContext context) { string[] computernames = PSComputerName.Get(context); string[] connectionUris = PSConnectionUri.Get(context); PSSessionOption sessionOptions = PSSessionOption.Get(context); List <ActivityImplementationContext> commands = new List <ActivityImplementationContext>(); // Configure the remote connectivity options RemotingBehavior remotingBehavior = PSRemotingBehavior.Get(context); if (PSRemotingBehavior.Expression == null) { remotingBehavior = RemotingBehavior.PowerShell; } // If they've specified the 'Custom' remoting behavior, ensure the activity // supports it. if ((remotingBehavior == RemotingBehavior.Custom) && (!SupportsCustomRemoting)) { throw new ArgumentException(Resources.CustomRemotingNotSupported); } if (PSCredential.Get(context) != null && PSAuthentication.Get(context) == AuthenticationMechanism.NegotiateWithImplicitCredential) { throw new ArgumentException(Resources.CredentialParameterCannotBeSpecifiedWithNegotiateWithImplicitAuthentication); } // we need connection info to be populated even for the custom remoting case. // This is because the ComputerName is picked up from the connection info field if ((remotingBehavior == RemotingBehavior.PowerShell || (IsActivityInlineScript(this) && RunWithCustomRemoting(context))) && (GetIsComputerNameSpecified(context) || (connectionUris != null && connectionUris.Length > 0))) { List <WSManConnectionInfo> connectionInfo = ActivityUtils.GetConnectionInfo( computernames, connectionUris, PSCertificateThumbprint.Get(context), PSConfigurationName.Get(context), PSUseSsl.Get(context), PSPort.Get(context), PSApplicationName.Get(context), PSCredential.Get(context), PSAuthentication.Get(context).GetValueOrDefault(AuthenticationMechanism.Default), PSAllowRedirection.Get(context).GetValueOrDefault(false), sessionOptions); foreach (WSManConnectionInfo connection in connectionInfo) { CreatePowerShellInstance(context, connection, commands); } } // Configure the local invocation options else { CreatePowerShellInstance(context, null, commands); } return(commands); }