远程重启IIS服务
2014-08-20 22:24
120 查看
方法一:
该方法在重启Windows Server 2003上的IIS服务时,会出现如下错误信息:
但是在重启Windows Server 2012 R2上的IIS服务时,可以成功,应该是与PS版本有关
方法二:
#需要本地和远程计算机上都安装有IIS组件,如果不安装IIS,则无法使用 iisreset.exe 命令
方法三:
除此应该还需要重启www服务,未测试。
方法四:
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()
$UserName = "administrator" $serverpass = "pass" $server = "10.4.19.60" $Password = ConvertTo-SecureString $serverpass -AsPlainText –Force $cred = New-Object System.Management.Automation.PSCredential($UserName,$Password) Invoke-Command -ComputerName $server -ScriptBlock { iisreset } -Credential $cred
该方法在重启Windows Server 2003上的IIS服务时,会出现如下错误信息:
但是在重启Windows Server 2012 R2上的IIS服务时,可以成功,应该是与PS版本有关
方法二:
IISRESET.exe remotename /restart
#需要本地和远程计算机上都安装有IIS组件,如果不安装IIS,则无法使用 iisreset.exe 命令
方法三:
1 (Get-WmiObject Win32_Service -ComputerName ServerName -Filter "Name='iisadmin'").InvokeMethod("StopService", $null) 2 Start-Sleep -Seconds 5 3 (Get-WmiObject Win32_Service -ComputerName ServerName -Filter "Name='iisadmin'").InvokeMethod("StartService", $null)
除此应该还需要重启www服务,未测试。
方法四:
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()
相关文章推荐
- 用命令实现Win7远程桌面关机和重启
- 群晖NAS用迅雷远程下载Xware 1.xxx的进程监视和掉线自动重启
- windows 远程控制关机和重启命令
- LAN远程重启server安全方法
- 无法进入远程桌面,有什么办法远程重启WIN2003服务器?
- 远程服务器监控重启方案
- windows 7远程重启和远程关机
- 远程控制数据库实用SQL重启功能
- 用命令实现Win7远程桌面关机和重启
- 如何在远程桌面无响应的情况下完成远程电脑重启
- 远程重启服务器的DOS命令
- 在知道对方机器的IP(局域网内)用户 密码,实现远程重启
- 用C#重启远程计算机
- 远程重启计算机(C#)
- 远程关闭和重启 Windows 系统
- C#实现远程关闭计算机或重启计算机的方法
- Shutdown远程重启机器
- Shutdown远程重启windows机器
- java远程操控linux,windows,三层交换机。对其进行关机和重启
- mstsc 远程重启~!~