Invoke-Command Array in ArgumentList
When dealing with multiple servers, you may often have to run a powershell command or script on many or all of them. This is where "Invoke-Command" comes into play. The Invoke-Command will execute a powershell command on a remote system and return the results to our powershell console. Let's take a look at a simple example. We are going to test whether or not a folder exists on multiple servers: $servers = @ ( "dc1" , "dc3" ) $servers | %{ Invoke-Command -ComputerName $_ ` -ScriptBlock { Write-Output "C:\Temp" } } The Write-Output cmdlet is executed on the dc1 and dc3 servers. But what if we have to pass parameters to the scriptblock? We will use the -ArgumentList parameter of the Invoke-Command as follows: $servers = @ ( "dc1" , "dc3" ) $path = "C:\Temp" $servers | %{ Invoke-...