PowerShell inside script.
Posted: 20 Dec 2017 23:02
I am a completely newbie when learning scripting in XY
I am working on running powershell code from within XY and having it spit back data. Here is something i came up with.
The powershell code doesnt really matter as it can be replaced but i am wondering if this is the best way to handle doing this.
I am working on running powershell code from within XY and having it spit back data. Here is something i came up with.
Code: Select all
$cmd = """powershell.exe"" -ExecutionPolicy Bypass -Command ""mkdir c:\temp -ErrorAction SilentlyContinue;((ipconfig /all | Select-String IPv4) -replace ' IPv4 Address. . . . . . . . . . . : ','') -replace '\(Preferred\) ','' | Out-File C:\temp\IP.txt""";
run $cmd,,1;
echo readfile("C:\temp\IP.txt")