サーバー A とサーバー B の 2 つのサーバーがあります。Powershell スクリプトを使用して、サーバー B からサーバー A をリモートで停止したいと考えています。
48764 次
6 に答える
13
オプション1:
iisreset remotepcname /restart
オプション 2:
(Get-Service -ComputerName remotepc -Name 'IISAdmin').stop()
オプション 3:
Invoke-Command -ComputerName remotepc -ScriptBlock {iisreset}
于 2013-02-22T10:34:09.903 に答える
10
Powershell を要求したため:
(Get-WmiObject Win32_Service -ComputerName ServerA -Filter "Name='iisadmin'").InvokeMethod("StopService", $null)
この質問は ServerFault に移動する必要があることに同意しました。
于 2009-09-09T20:03:42.943 に答える
3
$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
于 2012-01-06T17:55:26.630 に答える
2
PowerShell 2.0 では、cmd プロンプトから次を実行します。
invoke-command -computername <yourremoteservername> -scriptblock {iisreset}
于 2012-06-22T21:00:34.457 に答える
0
IIS v6 または v7 のさまざまなバージョンに対して、さまざまな名前空間で get-wmiobject コマンドレットを使用できます。以下のパイプライン コマンドは、IIS でローカルまたはリモートでこのような操作に使用できます。
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()
これらの操作には十分なアカウント権限が必要ですが、私の Web サイトでは $x.Recycle() を実行することを好みます。
于 2013-05-16T07:39:59.843 に答える