private/start/Start-SessionManagerPlugin.ps1
function Start-SessionManagerPlugin { [CmdletBinding(PositionalBinding = $true)] [OutputType([System.Diagnostics.Process])] param( [Parameter(Mandatory = $true)] [psobject] $Session, [Parameter(Mandatory = $true)] [ValidatePattern('^(af|il|ap|ca|eu|me|sa|us|cn|us-gov|us-iso|us-isob)-(central|north|(north(?:east|west))|south|south(?:east|west)|east|west)-\d{1}$')] [string] $Region ) Write-Host 'Starting session-manager-plugin..' -ForegroundColor DarkMagenta $ssmPluginFilePath = Get-SessionManagerPluginFilePath $ssmPluginArguments = ConvertTo-SessionManagerPluginArgument -Region $Region -SsmSession $session.Response -SsmCommand $session.Parameters try { $params = @{ FilePath = $ssmPluginFilePath ArgumentList = $ssmPluginArguments NoNewWindow = $true Wait = $false PassThru = $true } $process = Start-Process @params Start-Sleep -Milliseconds 650 if ($process.HasExited) { throw 'The session-manager-plugin has exited unexpectedly.' } return $process } catch { Write-Error "An error occurred starting the session-manager-plugin. $_" throw } } |