简体   繁体   English

使用Powershell在远程计算机上重新启动IIS

[英]Restart IIS on remote machine using Powershell

I have a TFSserver and a QAserver. 我有一个TFSserver和QAserver。 I am using autodeployment using TFS and have a powershell script that do the requirement. 我正在使用通过TFS进行的自动部署,并且具有满足要求的Powershell脚本。 But I have a issue in restarting the QA server IIS from the same power shell script. 但是我在从相同的电源Shell脚本重新启动QA服务器IIS时遇到问题。 i am doing the following set of commands for restarting the IIS. 我正在执行以下命令来重新启动IIS。

/*struser is in the administrator group of the QAserver / * struser在QAserver的管理员组中

$cred = New-Object System.Management.Automation.PSCredential ("$QAserver$struser", $password ) $session = new-pssession $oceane_server -Auth Negotiate -Credential $cred $ cred =新对象System.Management.Automation.PSCredential(“ $ QAserver $ struser”,$ password)$ session = new-pssession $ oceane_server -Auth Negotiate -Credential $ cred

/* Some deployment script */ / *一些部署脚本* /

invoke-command -session $session -ScriptBlock {iisreset /stop} invoke-command -session $ session -ScriptBlock {iisreset / stop}

Following error appears : 出现以下错误:

Access denied, you must be an administrator of the remote computer to use this 拒绝访问,您必须是远程计算机的管理员才能使用此功能

command. 命令。 Either have your account added to the administrator local group of 将您的帐户添加到的管理员本地组中

the remote computer or to the domain administrator global group. 远程计算机或域管理员全局组。

I could not find the solution for this. 我找不到解决方案。 Any help would be appreciable. 任何帮助将是可观的。

The quick work around is to open all the ports of your server and run iisreset [MACHINENAME] /stop. 解决方法是打开服务器的所有端口并运行iisreset [MACHINENAME] / stop。

For powershell remoting, I use credssp because it allows the double-hop. 对于Powershell远程处理,我使用credssp,因为它允许双跳。 Also, did you set your execution policy to bypass? 另外,您是否将执行策略设置为绕过?

Set-ExecutionPolicy Bypass

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM