在继续之前,我对Powershell的体验仅为2天。cmd call to powershell“您必须在' - '运算符的右侧提供值表达式
我想从命令行中添加四个参数来调用PowerShell脚本。 powershell脚本只是清理一个CSV文件,并在每个清理阶段制作一份文件的副本。
的变量在脚本a
,b
,c
和d
涉及到新的文件名(包括完整的地址)。
PowerShell脚本
param(
[string]$a,
[string]$b,
[string]$c,
[string]$d
)
Get-Content $a | ForEach-Object { $_ -replace """""""""""","""""" } | Set-Content $b -Force
Get-Content $b | ForEach-Object { $_ -replace """""""","""" } | Set-Content $c -Force
Get-Content $c | ForEach-Object { $_ -replace """""","" } | Set-Content $d -Force
命令脚本
命令下面的脚本是什么,我想在cmd
运行(注:我已经采取了真正的地址)。
powershell.exe '\\somefileaddress\CleanData.ps1'
-a "\\someaddress\DrFA-C.csv"
-b "\\someaddress\DrFA-C_2.csv"
-c "\\someaddress\DrFA-C_3.csv"
-d "\\someaddress\DrFA-C_4.csv"
错误消息我得到的是:
你必须提供在右手侧的值表达式“ - ”操作。