Нераспознанный аргумент 'ComputerName'. Все аргументы должны начинаться с "-" - PullRequest
0 голосов
/ 14 апреля 2019
msdeploy.exe : Error: Unrecognized argument 'ComputerName='https://QMX-STG-WEB2:8172/msdeploy.axd''. All arguments must begin with "-".
At C:\Users\scheluka\Desktop\copy.ps1:11 char:1
+ & 'C:\Program Files\IIS\Microsoft Web Deploy V3\msdeploy.exe' `
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (Error: Unrecogn...begin with "-".:String) [], RemoteException
    + FullyQualifiedErrorId : NativeCommandError

Error count: 1.
& 'C:\Program Files\IIS\Microsoft Web Deploy V3\msdeploy.exe' `
-source:iisApp=`'C:\Work\US17830_Latest\webapps\orchestration_snwatchlist\apps`' `
-dest:iisApp=`'Default Web Site/test/vmes`' ,ComputerName=`'https://QMX-STG-WEB2:8172/msdeploy.axd`',UserName=$username,Password=$password,IncludeAcls=`'False`',AuthType=`'Basic`' `
-verb:sync `
-verbose `
-disableLink:AppPoolExtension `
-disableLink:ContentExtension `
-disableLink:CertificateExtension `
-allowUntrusted `
-retryAttempts=2 `
-skip:objectName=filePath,absolutePath=.bin

1 Ответ

0 голосов
/ 15 апреля 2019

За использование backtick.Запятая - это естественный разрыв в PowerShell, как и другие символы операций.

Если вы стремитесь к удобочитаемости и хотите избежать этих длинных строк (я понимаю - но бывают случаи, когда они неизбежны), тогда вы можетепопробуйте эти варианты ...

# 1 
& 'C:\Program Files\IIS\Microsoft Web Deploy V3\msdeploy.exe' "-source:iisApp='C:\Work\US17830_Latest\webapps\orchestration_snwatchlist\apps' -dest:iisApp='Default Web Site/test/vmes',
ComputerName='https://QMX-STG-WEB2:8172/msdeploy.axd',
UserName=$username,
Password=$password,
IncludeAcls='False',
AuthType='Basic' -verb:sync -verbose -disableLink:AppPoolExtension -disableLink:ContentExtension -disableLink:CertificateExtension -allowUntrusted -retryAttempts=2 -skip:objectName=filePath,
absolutePath=.bin"



# 2
$Arguments = "-source:iisApp='C:\Work\US17830_Latest\webapps\orchestration_snwatchlist\apps' 
-dest:iisApp='Default Web Site/test/vmes',
ComputerName='https://QMX-STG-WEB2:8172/msdeploy.axd',
UserName=$username,
Password=$password,
IncludeAcls='False',
AuthType='Basic' 
-verb:sync 
-verbose 
-disableLink:AppPoolExtension 
-disableLink:ContentExtension 
-disableLink:CertificateExtension 
-allowUntrusted 
-retryAttempts=2 
-skip:objectName=filePath,absolutePath=.bin" 

# If you view the variable content it will show as it looks, but it's really a single line
$Arguments
$Arguments.Count
$Arguments.Length


& 'C:\Program Files\IIS\Microsoft Web Deploy V3\msdeploy.exe' """$Arguments"""


# 3 - if the exe does not see the above as a single line. You can make it one on the fly
$Arguments = "-source:iisApp='C:\Work\US17830_Latest\webapps\orchestration_snwatchlist\apps' 
-dest:iisApp='Default Web Site/test/vmes',
ComputerName='https://QMX-STG-WEB2:8172/msdeploy.axd',
UserName=$username,
Password=$password,
IncludeAcls='False',
AuthType='Basic' 
-verb:sync 
-verbose 
-disableLink:AppPoolExtension 
-disableLink:ContentExtension 
-disableLink:CertificateExtension 
-allowUntrusted 
-retryAttempts=2 
-skip:objectName=filePath,absolutePath=.bin" -replace "`n|`r"

# this makes sure it see a line
"""$Arguments""" | clip # Just paste in to notepad to see the line. Well as long as notepad is not set to word wrap

& 'C:\Program Files\IIS\Microsoft Web Deploy V3\msdeploy.exe' """$Arguments"""
...