src/Microsoft.PowerShell.Workflow.ServiceCore/ServiceCore/WorkflowCore/PSRemotingActivitiesBase.cs
// Prepare the commands
/// <summary>
/// Prepare commands that use PSRP for remoting...
/// </summary>
/// <param name="context">The activity context to use</param>
Prepare commands that use PSRP for remoting
Prepare commands that use PSRP for remoting
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Reliability", "CA2000:Dispose objects before losing scope")]
        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>();
            RemotingBehavior remotingBehavior = PSRemotingBehavior.Get(context);
            if (PSRemotingBehavior.Expression == null)
            {
                remotingBehavior = RemotingBehavior.PowerShell; 
            }
            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);
            }
            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);
                }
            }            
            else
            {
                CreatePowerShellInstance(context, null, commands);
            }
            return commands;
        }
[ System . Diagnostics . CodeAnalysis . SuppressMessage ( " " , " " ) ] 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 > ( ) ; RemotingBehavior remotingBehavior = PSRemotingBehavior . Get ( context ) ; if ( PSRemotingBehavior . Expression == null ) { remotingBehavior = RemotingBehavior . PowerShell ; } 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 ) ; } 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 ) ; } } else { CreatePowerShellInstance ( context , null , commands ) ; } return commands ; }
Prepare commands that use PSRP for remoting...
Prepare commands that use PSRP for remoting ...
// Configure the remote connectivity options // If they've specified the 'Custom' remoting behavior, ensure the activity // supports it. // 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 // Configure the local invocation options
context
NativeActivityContext
The activity context to use
The activity context to use