0
votes

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.

1
my understanding is that the $Profile lists the one that would be loaded, not the one that is loaded. remember that it will list a file that does not exist. [grin]Lee_Dailey

1 Answers

2
votes

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