0
votes

Question WRT Powershell ISE on Windows 10 pro. I recently noticed that when I start powershell ISE, I get an error: "The term 'set-variable' is not recognized as the name of a cmdlet......."

However, if I type set-variable once the powershell prompt shows up, it gives me the usual "Supply values for the following parameters:".....

I have also noticed that modules don't seem to 'autoload' anymore. I am manually having to do an import-module these data for things that use to work fine.

So figuring something is fouled up with my profile, I went to edit my profile only to notice $profile doesn't have a value in ISE. So I am wondering if that error I am seeing when ISE starts is it failing to set the value of $profile initially. (Is there any way to trace this?)

I am not sure of any way to 'repair' powershell ISE and am somewhat stuck as to why it can't find set-variable on start up, which is the reason (I think) that $profile is blank

Version info (it seems to set this properly):

C:\WINDOWS\system32> $PSVersionTable Name Value


PSVersion 5.1.19041.1
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.19041.1
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1

PSHome value: C:\WINDOWS\system32> $PSHOME C:\Windows\System32\WindowsPowerShell\v1.0

$env:PSModulePath value: C:\WINDOWS\system32> $env:PSModulePath C:\Users\craig\OneDrive - Red Dog Systems\Documents\WindowsPowerShell\Modules;C:\Program Files\WindowsPowerShell\Modules;C:\WINDOWS\system32\WindowsPowerShell\v1.0\Modules

-- All paths in the above exist.

I am hoping someone out there might have some suggestions on how to sort out what is going on?

Thanks in advance..

cmb..

1

1 Answers

0
votes

There are multiple profiles for PowerShell despending on what you have installed.

Microsoft.PowerShell_profile.ps1
Microsoft.PowerShellISE_profile.ps1
Microsoft.VSCode_profile.ps1

As well as several locations for them:

https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_profiles?view=powershell-7

Description Path All Users, All Hosts
$PSHOME\Profile.ps1 All Users, Current Host
$PSHOME\Microsoft.PowerShell_profile.ps1 Current User, All Hosts
$Home[My ]Documents\PowerShell\Profile.ps1 Current user, Current Host $Home[My ]Documents\PowerShell\
Microsoft.PowerShell_profile.ps1

For PowerShell they are not created by default, for say VSCode it is once you, you have to create them. You have to be in the instance you want to create them.

Start powershell.exe or powershell_ise and do this...

New-item –type file –force $profile