【发布时间】:2016-04-04 19:32:12
【问题描述】:
// 创建一个新的powershell驱动
$psw = ConvertTo-SecureString %deployment.password% -AsPlainText -force
$cred = new-object -TypeName System.Management.Automation.PSCredential -ArgumentList "MyUser, $psw
New-PSDrive -Credential $cred -Name ImportFolder -PSProvider FileSystem -Root \\MyShare\Exchange\MyFolder
// 创建完整的源路径
$sourcePath = ImportFolder:\$versionPath\audio
// 使用 msdeploy 和 $sourcePath 进行部署
$path = "C:\Program Files\IIS\Microsoft Web Deploy V3\msdeploy.exe";
$verb = "-verb:sync";
$src = "-source:contentPath=`"$sourcePath`"";
$dest = "-dest:contentPath=%TargetIISPath%,wmsvc='%Computername%:%deployment.iis.port%/msdeploy.axd',username=%system.Username%,password=%system.Password%";
Invoke-Expression "&'$path' --% $verb $src $dest -verbose -allowUntrusted";
Remove-PSDrive ImportFolder
我得到错误:
The term 'ImportFolder:\$versionPath\audio' is not recognized as the name of a
[21:07:32][Step 6/7] cmdlet, function, script file, or operable program. Check the spelling of the
[21:07:32][Step 6/7] name, or if a path was included, verify that the path is correct and try
[21:07:32][Step 6/7] again.At
问题在于 msdeploy 假定 sourcePath ImportFolder 的字面意思是“ImportFolder”,但实际上它是一个带有映射路径的 powershell 驱动器...
我该如何解决这个问题?
我不想使用“net use X:\ path”,因为它在我的环境中存在问题。
【问题讨论】:
-
您需要将
$sourcePath值括在引号中:$sourcePath = "ImportFolder:\$versionPath\audio"。话虽如此,msdeploy.exe将无法解析 psdrive(因为msdeploy.exe不是 PowerShell) -
我按照你说的做了,但它没有帮助现在我得到另一个我理解的错误...:错误代码:ERROR_SITE_DOES_NOT_EXIST 更多信息:站点“ImportFolder:”不存在。从字面上看...
-
这就是我告诉你的——即使你修复了
$sourcePath字符串,它也不起作用。msdeploy不是 POWERSHELL。 -
那我误会你了。我以为你给了我双引号 sourcePath 的提示...
-
@Elisabeth 你可以完成你想要的,甚至不用碰 PSDrives。只需像创建 PSDrive 一样使用目标文件夹的 UNC 路径。 PSDrives 仅在您创建它们的主机中可用,因此它对 msdeploy 可执行文件不可用。如果您需要能够在远程驱动器上执行操作而不需要提升当前的交互式用户令牌(登录),您可以破解注册表以允许提升的令牌这样做。
标签: powershell msdeploy webdeploy