[英]I want to make a powershell script that call another powershell script
So i have lets say a powershell script called CallMePlease.ps1
所以我可以说一个称为
CallMePlease.ps1
脚本
This script will take parameters / arguments and then does some a process. 该脚本将接受参数/参数,然后执行一些过程。 How do I append the arguments to the call when I call this script from
MAIN.ps1
? 从
MAIN.ps1
调用此脚本时,如何将参数附加到调用中? Code I have so far: 我到目前为止的代码:
$ScriptPath = C:\Tmp\PAL\PAL\PAL\PAL.ps1
$Log 'C:\Users\k0530196\Documents\log.csv'
$ThresholdFile 'C:\Program Files\PAL\PAL\template.xml'
$Interval 'AUTO'
$IsOutputHtml $True
$HtmlOutputFileName '[LogFileName]_PAL_ANALYSIS_[DateTimeStamp].htm'
$IsOutputXml $True
$XmlOutputFileName '[LogFileName]_PAL_ANALYSIS_[DateTimeStamp].xml'
$AllCounterStats $False
$NumberOfThreads 1
$IsLowPriority $False
$cmd = "$ScriptPath\.\PAL.ps1"
Invoke-Expression "$cmd $Log $ThresholdFile $Interval $IsOutputHtml $HtmlOutputFileName $IsOutputXml $XmlOutputFileName $AllCounterStats $NumberOfThreads"
In the code that you posted you are missing several =s in your assignment statements. 在您发布的代码中,您的赋值语句中缺少几个=。 For instance this line:
例如这行:
$Log 'C:\\Users\\k0530196\\Documents\\log.csv' $ Log'C:\\ Users \\ k0530196 \\ Documents \\ log.csv'
Should be this: 应该是这样的:
$Log = 'C:\\Users\\k0530196\\Documents\\log.csv' $ Log = 'C:\\ Users \\ k0530196 \\ Documents \\ log.csv'
You will need to do that in all the instances where you are trying to assign a value to a variable. 您将在尝试为变量分配值的所有实例中执行此操作。
I would do it like this: 我会这样做:
. $cmd $Log $ThresholdFile $Interval $IsOutputHtml $HtmlOutputFileName $IsOutputXml $XmlOutputFileName $AllCounterStats $NumberOfThreads
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.