如何在PowerShell中将长命令拆分为多行
如何在PowerShell中将长命令拆分为多行
如何在PowerShell中将以下命令拆分成多行?
&"C:\Program Files\IIS\Microsoft Web Deploy\msdeploy.exe" -verb:sync -source:contentPath="c:\workspace\xxx\master\Build\_PublishedWebsites\xxx.Web" -dest:contentPath="c:\websites\xxx\wwwroot\,computerName=192.168.1.1,username=administrator,password=xxx"
admin 更改状态以发布 2023年5月23日
另一种更清洁的参数传递方式是使用splatting(展开)。
将参数和值定义为哈希表,例如:
$params = @{ 'class' = 'Win32_BIOS'; 'computername'='SERVER-R2'; 'filter'='drivetype=3'; 'credential'='Administrator' }
然后像这样调用您的命令:
Get-WmiObject @params
Microsoft Docs: 了解 Splatting
TechNet Magazine 2011: Windows PowerShell: Splatting