PowerShell Repair?

Bummer, I was hoping it would be one of those snapins, based on earlier hints of SQL causing the same problem for other people.

Next, I’d try the modules. A quick way of seeing if this will be helpful is to rename your My Documents\WindowsPowerShell\Modules folder, launch PowerShell, and try Get-Command again. If it works, then you can try creating a new Modules folder and moving them in a few at a time. Hopefully, you’ll be able to identify one or more modules that are triggering this problem with Get-Command.

Brilliant, Dave, renaming that modules directory (and I created a fresh empty one) has fixed both get-command and get-dscresource (which was where I started).

I’ve put in a Connect suggestion (ID 878376) for PowerShell Repair as it seems to me it would be good if there was a simple way to say “take me back to a clean working default installation of PowerShell (and please discard profiles, snap-ins, modules, etc)”.

Many thanks for all the help.

PS Env:> get-command

CommandType Name ModuleName

Function A:
Function B:
Function C:
Function cd…
Function cd

PS Env:> get-dscresource

ImplementedAs Name Module Properties

Binary File {DestinationPath, Attributes, Checksum, Con…
PowerShell Archive PSDesiredStateConfiguration {Destination, Path, Checksum, DependsOn…}
PowerShell Environment PSDesiredStateConfiguration {Name, DependsOn, Ensure, Path…}
PowerShell Group PSDesiredStateConfiguration {GroupName, Credential, DependsOn, Descript…
Binary Log PSDesiredStateConfiguration {Message, DependsOn}
PowerShell Package PSDesiredStateConfiguration {Name, Path, ProductId, Arguments…}
PowerShell Registry PSDesiredStateConfiguration {Key, ValueName, DependsOn, Ensure…}
PowerShell Script PSDesiredStateConfiguration {GetScript, SetScript, TestScript, Credenti…
PowerShell Service PSDesiredStateConfiguration {Name, BuiltInAccount, Credential, DependsO…
PowerShell User PSDesiredStateConfiguration {UserName, DependsOn, Description, Disabled…
PowerShell WindowsFeature PSDesiredStateConfiguration {Name, Credential, DependsOn, Ensure…}
PowerShell WindowsProcess PSDesiredStateConfiguration {Arguments, Path, Credential, DependsOn…}
PowerShell xADDomain xActiveDirectory {DomainAdministratorCredential, DomainName,…

I just discovered that I had the same problem with Get-Command. I didn’t realize I had the issue because I rarely run Get-Command without parameters. With the help of this article I tracked it down to the Module “RDS-Manager”. Once I removed the module from my modules directory(C:\Program Files\WindowsPowerShell\Modules), Get-Command started working again.

I had the same problem myself. It was caused by setting StrictMode inside of a module. Once I removed the line, I no longer received the error which incidentally was triggered inside of the PSDesiredStateConfiguration module.