How To start/stop IIS 6.0/7.0 remotely using PowerShell Scripts?

后端 未结 6 2647
一向
一向 2021-02-20 04:42

I have two servers Server A and Server B. I want to stop server A from Server B remotely using Powershell script.

6条回答
  •  眼角桃花
    2021-02-20 04:54

    $service = Get-WmiObject -computer 'ServerA' Win32_Service -Filter "Name='IISAdmin'"
    $service
    $service.InvokeMethod('StopService',$Null)
    start-sleep -s 5
    $service.InvokeMethod('StartService',$Null)
    start-sleep -s 5
    $service.State
    
    $service = Get-WmiObject -computer 'ServerB' Win32_Service -Filter "Name='IISAdmin'"
    $service
    $service.InvokeMethod('StopService',$Null)
    start-sleep -s 5
    $service.InvokeMethod('StartService',$Null)
    start-sleep -s 5
    $service.State
    

提交回复
热议问题