You can execute or run your PowerShell .Ps1 scripts from within PowerShell as well as from the Run command as in the example below:
Powershell C:\My_Script.Ps1
If you call the script this way the script will execute as requested however the command window close as soon as the script completes its task(s). To prevent this from happening you can use the -NoExit command to keep the window open until you manually close it as in the example here:
Powershell –NoExit C:\My_Script.Ps1
You can also modify your scripts to write their output to a file such as a Csv file by using the Export function as in the example below:
Gwmi –Class Win32_Service | Select-object Name | Export-Csv C:\ServicesList.Csv –NoTypeInformation
No Comments