스크립트를 계속 진행하기 전에 현재 세션으로 설정하고 가져와야하는 두 개의 PSSession이 있습니다. 두 단계 모두 직렬로 실행할 때 약 20 - 30 초 동안 각각 약 10 - 15 초가 필요합니다.New-PSSession Parellel 실행
New-PSSession을 별도의 runspace에서 실행 한 다음 설정된 세션을 부모 프로세스로 가져올 수 있습니까?
New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri ("https://$($service)/PowerShell/") -Credential $Credential -Authentication Basic -AllowRedirection -ErrorAction Stop
New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri "https://outlook.office365.com/powershell-liveid/" -Credential $Credential -Authentication Basic -AllowRedirection -ErrorAction Stop
아마도 이런 일이 (이 작동하지 않는 경고)하려면 :
이$credential = Get-Credential
$scriptblock =
{
param ([string]$Credential)
$session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri "https://outlook.office365.com/powershell-liveid/" -Credential $Credential -Authentication Basic -AllowRedirection -ErrorAction Stop
return $session
}
$shell = [PowerShell]::Create().AddScript($scriptblock).AddParameter($credential)
$job = $shell.BeginInvoke()
$result = $shell.EndInvoke($job)
Import-PSSession $result
궁극적 인 목표는이 시간이 덜 걸릴 수 있도록하는 것입니다이에서 예를 변화 들어
우리가 New-PSSession을 병렬로 사용한다면 20 ~ 30 초가 아닌 10 ~ 15 초가 걸릴 것입니다. 나는 이것을 달성하는 어떤 대답이라도 행복 할 것이고, 그것은 runspaces를 사용할 필요가 없다.
편집 :
봐 :
그래서 귀하의 경우, 당신은 아마 뭔가를 실행하여 당신이 원하는 것을 수행 할 수 있습니다. https://technet.microsoft.com/en-us/library/hh849717.aspx 여러 개의 ConnectionURI를 만들고 다른 개체에 할당 한 다음 실행을 계속할 수 있습니다. –또는 다른 당신은 Invoke-Command 스크립트 블록을 사용할 수 있습니다 –
안녕하세요 @ ShankarShastri, 내가 완전히 당신의 제안을 이해하고 있는지 모르겠다. –