So i have lets say a powershell script called 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
? 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'
Should be this:
$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
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.