コード例 #1
0
        public static string BuildCommandLine(PowerShellSessionInfo sessionInfo)
        {
            var command = $"-ExecutionPolicy {sessionInfo.ExecutionPolicy} {sessionInfo.AdditionalCommandLine}";

            if (sessionInfo.EnableRemoteConsole)
            {
                command += $" -NoExit -Command \"Enter-PSSession -ComputerName {sessionInfo.Host}\"";
            }

            return(command);
        }
コード例 #2
0
        public static PowerShellSessionInfo CreateSessionInfo(ProfileInfo profileInfo)
        {
            var info = new PowerShellSessionInfo
            {
                EnableRemoteConsole = profileInfo.PowerShell_EnableRemoteConsole,
                Host = profileInfo.Host,
                AdditionalCommandLine = profileInfo.PowerShell_OverrideAdditionalCommandLine ? profileInfo.PowerShell_AdditionalCommandLine : SettingsManager.Current.PowerShell_AdditionalCommandLine,
                ExecutionPolicy       = profileInfo.PowerShell_OverrideExecutionPolicy ? profileInfo.PowerShell_ExecutionPolicy : SettingsManager.Current.PowerShell_ExecutionPolicy
            };

            return(info);
        }