[英]Manage IIS Remotely through TFS2015
Currently using TFS 2015 update 3 for deployments and I have added "PowerShell on target machine" task, which calls for PowerShell script saved on IIS server to stop website before deployments: 当前使用TFS 2015 Update 3进行部署,我添加了“目标计算机上的PowerShell”任务,该任务要求将IIS服务器上保存的PowerShell脚本在部署前停止网站:
icm -ComputerName $server -ScriptBlock {Import-Module WebAdministration; Stop-Website -Name $app}
with session variables as: $server = abc.xyz.com
, $app = DefaultWebSite
会话变量为:
$server = abc.xyz.com
, $app = DefaultWebSite
The error I get is: 我得到的错误是:
The running command stopped because the preference variable "ErrorActionPreference" or common parameter is set to Stop: Cannot validate argument on parameter 'Name'.
正在运行的命令已停止,因为首选项变量“ ErrorActionPreference”或公共参数设置为“停止”:无法验证参数“名称”上的参数。 The argument is null.
参数为空。 Provide a valid value for the argument, and then try running the command again.”
为参数提供有效的值,然后尝试再次运行命令。”
The same script works if I hard code the server & application name. 如果我对服务器和应用程序名称进行硬编码,则可以使用相同的脚本。
使用脚本块时,除非将param
与参数列表一起使用,或者将PowerShell与3+版本一起使用using:
scope修饰符,否则无法使用脚本作用域中的变量。
icm -ComputerName $server -ScriptBlock {Import-Module WebAdministration; Stop-Website -Name $using:app}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.