Powershell用变量(美元符号)插入双黑斜线



我想将变量替换为计算机路径。。

Write-Host \$store.storeIp$Global:config.dest

预期

\127.0.0.1D$foo

实际

\@{storeNumber=1111; storeName=CAT; storeIp=127.0.0.1; status=FAILED}.storeIp@{inputFile=./store-deployment-inp
ut.csv; src=.foo; dest=D$foo; destDir=D:; installerFileName=xxx.exe; po=; serviceName=xxx; forceDeploy=False; legacyScript=}.dest

不知怎的,当与\$结合时,看起来像是powershell输出所有对象,而不是输出select值。

您可以这样做:

Write-Host ("\{0}{1}" -f $store.storeIp, $Global:config.dest)

或者因为这是一条路径:

Join-Path $store.storeIp $Global:config.dest

最新更新