Remote management of computers via Windows PowerShell (Lite version)

Source: Internet
Author: User

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)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.