Skip to content

Instantly share code, notes, and snippets.

@JohnL4
Last active June 8, 2023 18:46
Show Gist options
  • Save JohnL4/2b4636b68cc26e2041df2dd439ff87df to your computer and use it in GitHub Desktop.
Save JohnL4/2b4636b68cc26e2041df2dd439ff87df to your computer and use it in GitHub Desktop.
How to send arguments to Invoke-Command (using a parameterized script block) to invoke a command on a remote server (PS Remoting)
# The key is a parameterized script block.
$expected = Invoke-Command -ComputerName $Machine -script {
param($path) Get-ChildItem $path -rec | Measure-Object -prop length -sum } -args $CubePath
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment