PowerShell Remote restart/shutdown server

Source: Internet
Author: User

PowerShell Remote restart/shutdown server

#启动winrm

WinRM quickconfig-q

#设置信任主机

Set-item wsman:\localhost\client\trustedhosts-value    192.168.1.2

#登录验证

#设置要关闭的服务器的名称

"192.168.1.2"

#建立一个连接

PS c:\windows\system32> $ser 1=new-pssession-computername $cname-credential $c

#重起服务器

{shutdown-r-T 0}

After merging the above commands: (not tested)

Full command, interested to try

Invoke-command-session new-pssession-computername "192.168.1.2"-credential get-credential-scriptblock {shutdown-r- T 0}

You can do what you want in {},

{net start W32Time} #启动时间服务

{dir} #查看当前文件

{net stop W32Time} #停止时间服务

PowerShell Remote restart/shutdown server

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.