0
//創建一個新的PowerShell驅動使用新PSDrive來名稱作爲msdeploy源參數源變量不起作用
$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驅動器與映射路徑...
我該如何解決呢?
我不想使用「淨使用X:\路徑」,因爲它在我的環境中的越野車。
你要罩住'$ sourcePath'值用引號括起來:'$ sourcePath =「ImportFolder:\ $ versionPath \ audio」'。這就是說,'msdeploy.exe'將無法解析psdrive(因爲msdeploy.exe不是PowerShell) –
我照你說的做了,但現在沒有幫助,我得到了另一個我明白的錯誤.. 。:錯誤代碼:ERROR_SITE_DOES_NOT_EXIST 更多信息:網站'ImportFolder:'不存在。它需要從字面上... – Elisabeth
這就是我所告訴你的 - 即使修復了'$ sourcePath'字符串,它也不起作用。 'msdeploy' **不是POWERSHELL **。 –