Now that you have a server (the Master side ) in your hand, you intend to remotely manage multiple servers (the controlled side ) via the host terminal. This process can be done through Windows PowerShell.
First Open PowerShell on the console with administrator privileges, enter the following command (where xxx is the field in IP, trustedhosts is the IP address of the host terminal. ):
' @{trustedhosts= "XXX.XXX.XXX.XXX"} '
Then, on the host side, open PowerShell with administrator privileges, enter the following command (where "XXX.XXX.XXX.XXX" is the IP address of the controlled end, "DOMAIN\username" is the logged-on user of the computer being controlled.) ):
XXX.XXX.XXX.XXX -credential DOMAIN\username
After entering this command, press ENTER, will let you verify the login user's password, enter and then press ENTER--session to create the success.
We can then manipulate the remote computer (the controlled side) with the $session variable.
For example: We want to restart this computer remotely, just continue typing in the PowerShell window on the console:
1}
When the input is finished press ENTER, the machine at the end of the control has been restarted.
I encapsulated the process of the above-mentioned master side, which is encapsulated in the following way:
function shutdownremotecomputers{param ($ip, $userName) #winrm s winrm /con Fig/client " @{trustedhosts=10.1.23.60"} " $sen = " ' @{trustedhosts= ' " " + $ip + ' " ' WinRM s winrm /config/client $sen $session = new-pssession $ip-credential $userName ICM $session {C Md.exe /C shutdown/r/f/t 1
From this control side, the control side only needs the following statement:
Shutdownremotecomputers-ip Xxx.xxx.xxx.xxx-username DOMAIN\username
The only trouble is that after executing the above statement, you need to verify the corresponding "DOMAIN\username" Password:
Do not know what method can cross or automatically complete the process of password verification, I hope to master PowerShell you can give guidance! O (∩_∩) o Thank you ~
Remote management of computers via Windows PowerShell (Lite version)