|
|
|
@ -142,7 +142,7 @@ function wsh {
|
|
|
|
|
if (!($session = Get-PSSession -ComputerName $ComputerName -Name 'wsh*' -ErrorAction SilentlyContinue | Where-Object Availability -eq 'Available' | Select-Object -First 1)) {
|
|
|
|
|
$session = New-PSSession -ComputerName $ComputerName -Name ('wsh'+(Get-Random))
|
|
|
|
|
Invoke-Command -Session $session -Command $scriptBlock
|
|
|
|
|
Invoke-Command -Session $session -Command {Set-Location ~}
|
|
|
|
|
Invoke-Command -Session $session -Command {Set-Location $env:USERPROFILE}
|
|
|
|
|
}
|
|
|
|
|
Enter-PSSession $session
|
|
|
|
|
}
|
|
|
|
|