远程重启IIS服务
方法一:
- $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()
远程重启IIS服务的更多相关文章
- Windows服务器Pyton辅助运维--02.远程重启IIS服务器
Windows服务器Pyton辅助运维 02.远程重启IIS服务器 开发环境: u Web服务器: Windows Server 2008 R2 SP1 IIS 7.5 u 运维服务器: Pyth ...
- Windows 远程停止iis服务
最近遇到一个小需求,需要重启远程计算机的iis服务. 需求背景是这样的,用jenkins 做ci的时候, 由于项目是有单独的web服务器,项目虽然是一套, 但是分为A,B,C三个web系统,其中A,B ...
- bat文件重启SQL服务和IIS服务
sqlserver有自动备份功能,所以要重启两个服务器,下面是重启脚本,脚本名称:sql_restart.bat net stop sqlserveragent net stop mssqlse ...
- ASP.NET C# 如何在程序中控制IIS服务或应用程序池重启?
停止IIS服务ServiceController sc = new ServiceController("iisadmin");if(sc.Status==ServiceContr ...
- C# 在程序中控制IIS服务或应用程序池关闭重启
//停止IIS服务 ServiceController sc = new ServiceController("iisadmin"); if(sc.Status=ServiceCo ...
- IIS服务的命令行方式重启命令
打开IIS配置窗口的CMD命令:开始---运行---CMD----输入inetmgr 直接使用CMD我们可以操作很多事情,比如启动IIS,重启IIS,停止IIS 重启IIS服务器,开始->运行- ...
- Power shell 重启IIS
最近根据项目需要写了一段power shell的代码 ,主要功能是批量重启IIS 具体的 Power shell 服务如下: write-output 'Restarting IIS servers ...
- 最完整的dos命令字典,IIS服务命令,FTP命令
https://www.cnblogs.com/accumulater/p/10670051.html(优秀博文) 一.最完整的dos命令字典net use ipipc$ " " ...
- 在Windows Server 2008 R2上安装IIS服务
一.Windows Server 2008 R2 介绍 1.Windows Server 2008 R2 基本概念 2.Windows Server 2008 R2 家族系列 二.VMware虚拟机安 ...
随机推荐
- 【HDOJ】4351 Digital root
digital root = n==0 ? 0 : n%9==0 ? 9:n%9;可以简单证明一下n = a0*n^0 + a1*n^1 + ... + ak * n^kn%9 = a0+a1+..+ ...
- 手机3D游戏开发:自定义Joystick的相关设置和脚本源码
Joystick在手游开发中非常常见,也就是在手机屏幕上的虚拟操纵杆,但是Unity3D自带的Joystick贴图比较原始,所以经常有使用自定义贴图的需求. 下面就来演示一下如何实现自定义JoySti ...
- Archlinux里面安装VMware Tools
用虚拟机学习linux确实很方便,但是和主机的文件共享是个大问题,VMWARE TOOLS可以很好的解决这个问题,但是在ARCH里却不能向大多数linux那样方便的安装,在查了很多帖子试了无数遍之后, ...
- 临时禁用Resharper
Visual Studio 菜单 –> 工具 –> 选项 –> ReSharper –> Suspend按钮
- jQuery基础知识— 获得内容和属性
jQuery拥有可操作HTML元素和属性的方法. 获得内容: text()--设置或返回所选元素的文本内容 html()--设置或返回所选元素的内容(包括HTML标记) val()--设置或返回表 ...
- Algorithm for Maximum Subsequence Sum z
MSS(Array[],N)//Where N is the number of elements in array { sum=; //current sum max-sum=;//Maximum ...
- Failed to lunch test error when run with Appium (已解决)
[2015-08-10 15:09:07 - androidtest1] Performing android.test.InstrumentationTestRunner JUnit launch[ ...
- [selenium webdriver Java]检查元素状态
许多测试失败是因为点击一个元素失败或者在一个不可见的字段中输入文字,或者是在不可输入的文本中输入文字. 我们可以在具体操作之前,检查一下元素的状态.WebElement类提供了这样的方法. 方法 目的 ...
- WebDriver打开浏览器-java
环境:配置jdk.使用Eclipse(个人爱好),导入selenium-java-2.42.2.jar.selenium-java-2.42.2-srcs.jar.selenium-server-st ...
- I2c串行总线组成及其工作原理
采用串行总线技术可以使系统的硬件设计大大简化,系统的体积减小,可靠性提高,同时系统更容易更改和扩充 常用的串行扩展总线有:I2c总线,单总线,SPI总线,以及microwire.Plus等等 I2c总 ...