Remotely restart the IIS service

Source: Internet
Author: User

 

Method 1:

 1   $ Username = "  Administrator  "  2   $ Serverpass = "  Pass  "  3   $ Server ="  10.4.19.60  "  4   $ Password = Convertid-securestring $ Serverpass - Asplaintext-Force  5   $ Cred = New-Object System. Management. Automation. pscredential ( $ Username , $ Password  )  6   7 Invoke-command-computername$ Server -Scriptblock {iisreset}-credential $ Cred 

 

 

Method 2:

 

 
Iisreset.exe remotename/restart

# IIS components must be installed on both the local and remote computers. If IIS is not installed, the iisreset.exe command cannot be used.

 

Method 3:

 
1 (get-wmiobject win32_service-computername servername-filter "name = 'isadmin '"). invokemethod ("stopservice", $ null) 2 start-sleep-seconds 53 (get-wmiobject win32_service-computername servername-filter "name = 'isadmin '"). invokemethod ("startservice", $ null)

In addition, the WWW Service must be restarted and not tested.

Method 4:

For IIS v6

$ SRV = "server name or IP address"
$ APP = "Name of APP pool"
$ X = Get-wmiobject-namespace "Root \ microsoftiisv2"-class "iisapplicationpool"-computername $ SRV-Authentication packetprivacy | where-object {$ _. name-EQ "w3svc/apppools/$ app "}
$ X. Stop ()
$ X. Start ()

For IIS V7

$ SRV = "server name or IP address"
$ APP = "Name of APP pool"
$ X = Get-wmiobject-namespace "Root \ webadministration"-class "applicationpool"-computername $ SRV-Authentication packetprivacy | where-object {$ _. Name-EQ $ app}
$ X. Stop ()
$ X. Start ()

 

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.