Powershell Best Practice #15: Execute scripts with -NoProfile parameter

By | July 26, 2015

Best Practice: It is recommended to use -NoProfile parameter when executing scripts.

powershell.exe -NoProfile File "C:\scripts\Get-DiskSpace.ps1"

Explanation: When you run a script via scheduled task or via a shortcut, Powershell will first load profiles and then run the script.

You never know what contains these profiles, so it can be dangereous and you can have unexpected behaviours.

NoProfile : Does not load the Windows Powershell profile.

Note: To see all the available parameters : powershell.exe /?


previous-buttonnext-button

Leave a Reply

Your email address will not be published. Required fields are marked *