I would like to create multiple Powershell sessions to my local machine to perform some operations on many files / folders at once, without slowing down my actual Powershell script. Therefore I was looking for possibilities to do multi-threading in Powershell.
The easiest approach appears to be the New-PSSession cmdlet. I created a test script to play around with it.
Write-Host "Creating session"
$NewSession = New-PSSession
Write-Host "Session created" #This line will not show up anymore...
Invoke-Command -Session $NewSession -ScriptBlock {$WSH = Create-Object -comObject WScript.Shell; $WSH.Popup("Some popup", 1) } -AsJob
Whenever I run it, it simply freezes when calling New-PSSession
What am I doing wrong?