-ScriptBlock is an Invoke-Command parameter that places executable PowerShell statements inside curly braces for remote computers. The same command can run across multiple hosts, while a separate parameter can send an entire script file instead. section 13.6
Run a process query remotely
Invoke-Command -ComputerName SRV2,DC3,SRV4 -ScriptBlock { Get-Process pwsh } -UserName tylerl The statements inside the braces are sent to each specified computer. A pipeline can be included inside the block to filter the remote results. section 13.6
Invoke-Command -ComputerName SRV2,DC3,SRV4
-ScriptBlock { Get-Process pwsh } -UserName tylerl
Compare the parameter with -HostName and observe how the script block is combined with a computer list. section 13.6
With -AsJob, -ScriptBlock sends the command to remote computers in parallel and stores returned results until they are reviewed. The remote-job approach supports up to 32 simultaneous computers by default. section 14.5
