how to execute powershell commmand stored inside variable
i've searched previous threads, , net, resolution problem. not sure why mine seems unique.
i want add path script name, execute script, , store results in variable.
this works great. need results (an array). but, not "way" need accomplish it.
i need place script in folder other whatever current is.
$results = @(.\scriptname.ps1 -debug)
this fails:
$results = @( ($scripts_path + "\" + scriptname).ps1 -debug)
i'd sure obliged if can indicate correct syntax accomplish this.
i know invoke-expression , call operator (&). neither 1 works.
i'm sure i've missed fundamental rule here.
if directions go straight, turn left, right: still there?
cancel....found answer....
$result = invoke-expression "& $($scripts_path + "\scriptname").ps1 -debug"
if directions go straight, turn left, right: still there?
Windows Server > Windows PowerShell
Comments
Post a Comment