Geo V
Geo V

Reputation: 151

Running a powershell .ps1 script without loading any profile

I am trying to run powershell script version 5.1 in windows 2012R2

powershell.exe -NoProfile D:\test2.ps1 on the powershell command console (I do not the script session using any profile on the system)

Now I am checking in the test.ps1 script what profile is loaded in test.ps1 script

$profile


I get output C:\Users\XXXXX\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1

Any thought why any profile start up in my session.

Upvotes: 0

Views: 2471

Answers (1)

codewario
codewario

Reputation: 21408

The profile isn't loading, because you specified -NoProfile on powershell.exe. However, the $profile variable is still defined.

Upvotes: 2

Related Questions