Default powershell commands not getting executed , getting command not recognized.

I was working on some weird cases that some of the basic powershell commands are not getting  executed in the machine and i came to know that the powershell modules are not getting loaded due to which default modules are not getting loaded in the psmodule path.

Resolution would be to run the below commands:

$PSModulePath = Get-ItemProperty -Path "HKLM:SYSTEM\CurrentControlSet\Control\Session Manager\Environment" -Name "PSModulePath"
$newPSModulePath = $PSModulePath.PSModulePath + ";C:\Windows\System32\WindowsPowerShell\v1.0\Modules"
Set-ItemProperty -Path "HKLM:SYSTEM\CurrentControlSet\Control\Session Manager\Environment" -Name "PSModulePath" -value $newPSModulePath

Else you need to create a PSModulePath value under the below path :

HKLM:SYSTEM\CurrentControlSet\Control\Session Manager\Environment

and need to enter the value of path mentioned below in the PSModulePath key :
%SystemRoot%\system32\WindowsPowerShell\v1.0\Modules\


Once the value is entered you can be able to execute the basic commands, this kind of error mostly occurs if any customization is done by the any application in powershell scripts.


Comment below in case of any further queries

Popular posts from this blog

How to reset the IE settings Through command Line (CMD)

Running CLI Commands in ESXi using plink software