Created
May 7, 2020 17:07
-
-
Save kbbgl/4288574a02dcecb65bf8da6754650174 to your computer and use it in GitHub Desktop.
[Windows | run remote commands] #windows #remote
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Enable remoting on server where RPC will run in | |
| Enable-PSRemoting -Force | |
| # Check if WinRM is running on remote server | |
| Test-WsMan QUERY_NODE1_HOSTNAME | |
| $username = "corp\myuser" | |
| $password = ConvertTo-SecureString -String "mypswd" -AsPlainText -Force | |
| $cred = [pscredential]::new($username,$password) | |
| $args = "-t", "list_only" | |
| $parameters = @{ | |
| ComputerName = "s1", "s2" | |
| ScriptBlock = { & "C:\scripts\elasticube_data_cleaner_11Feb2019 Update\elasticube_data_cleaner.exe" -t "list_only" } | |
| Credential = $cred | |
| } | |
| Invoke-Command @parameters |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment