Skip to content

Instantly share code, notes, and snippets.

@milesgratz
Last active June 12, 2017 16:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save milesgratz/d848710cd67d398c5245e8b472accb56 to your computer and use it in GitHub Desktop.
Save milesgratz/d848710cd67d398c5245e8b472accb56 to your computer and use it in GitHub Desktop.
Custom function to start Invoke-Command "jobs" on remote systems
Function Run-CustomFunction {
param($ComputerName)
# Create a job for tracking results
Start-Job -Name $ComputerName -ScriptBlock {
# Run the command on the remote Computer
Invoke-Command -ComputerName $args[0] -ScriptBlock {
Get-ChildItem "C:\Temp"
}
} -ArgumentList $ComputerName
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment