# PowerShell Repair?

**URL:** <https://forums.powershell.org/t/powershell-repair/2581>\
**Category:** PowerShell Help\
**Created:** [May 18, 2014, 2:33pm UTC](https://forums.powershell.org/t/powershell-repair/2581 "2014-05-18T14:33:49Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![john-drake](https://avatars.discourse-cdn.com/v4/letter/j/74df32/32.png) [@john-drake](https://forums.powershell.org/u/john-drake)\
**Post date:** [May 18, 2014, 2:33pm UTC](https://forums.powershell.org/t/powershell-repair/2581/1 "2014-05-18T14:33:49Z")

</div>

Is there a way to repair (or uninstall and reinstall) PowerShell v4? I’m getting the error below when running get-command and would like to set PowerShell v4.0 back to its “factory defaults” so I can play with version 4 and in particular DSC. (.Net 4.5 Framework is installed.) Thanks.

PS Env:&gt; $psversiontable

Name Value

* * *

PSVersion 4.0  
WSManStackVersion 3.0  
SerializationVersion 1.1.0.1  
CLRVersion 4.0.30319.18444  
BuildVersion 6.3.9600.16406  
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0}  
PSRemotingProtocolVersion 2.2

PS Env:&gt; get-command  
get-command : Object reference not set to an instance of an object.  
At line:1 char:1

- get-command
- 

```auto
  + CategoryInfo : NotSpecified: (:) [Get-Command], NullReferenceException
  + FullyQualifiedErrorId : System.NullReferenceException,Microsoft.PowerShell.Commands.GetCommandCommand
```

---

<div class="post-metadata">

**Author:** ![daniel-krebs](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/daniel-krebs/32/484_2.png) [@daniel-krebs](https://forums.powershell.org/u/daniel-krebs)\
**Post date:** [May 18, 2014, 5:38pm UTC](https://forums.powershell.org/t/powershell-repair/2581/2 "2014-05-18T17:38:17Z")

</div>

John,

Uninstalling the Windows Management Framework 4.0 (KB2819745) and reinstalling it after a restart might work ([http://www.microsoft.com/en-gb/download/details.aspx?id=40855](http://www.microsoft.com/en-gb/download/details.aspx?id=40855)).

---

<div class="post-metadata">

**Author:** ![richard-siddaway](https://avatars.discourse-cdn.com/v4/letter/r/d78d45/32.png) [@richard-siddaway](https://forums.powershell.org/u/richard-siddaway)\
**Post date:** [May 18, 2014, 7:23pm UTC](https://forums.powershell.org/t/powershell-repair/2581/3 "2014-05-18T19:23:49Z")

</div>

What version of Windows are you using?

PowerShell 4.0 is installed by default on Windows 8.1 and Windows Server 2012 R2 - you can’t uninstall it from those machines.

---

<div class="post-metadata">

**Author:** ![john-drake](https://avatars.discourse-cdn.com/v4/letter/j/74df32/32.png) [@john-drake](https://forums.powershell.org/u/john-drake)\
**Post date:** [May 18, 2014, 9:00pm UTC](https://forums.powershell.org/t/powershell-repair/2581/4 "2014-05-18T21:00:04Z")

</div>

Thanks Richard, Windows 7 (x64) SP1. Until recently I had PowerShell v3, and had no issues with that. I installed WMF4 (after checking I had .Net Framework 4.5 first) and only found I had an issue with PowerShell v4 when “Get-DSCResource” errored. I’m minded to follow Daniel’s advice and uninstall then reinstall WMF4 (as I’ve no idea how to get get-command working).

---

<div class="post-metadata">

**Author:** ![richard-siddaway](https://avatars.discourse-cdn.com/v4/letter/r/d78d45/32.png) [@richard-siddaway](https://forums.powershell.org/u/richard-siddaway)\
**Post date:** [May 18, 2014, 9:40pm UTC](https://forums.powershell.org/t/powershell-repair/2581/5 "2014-05-18T21:40:05Z")

</div>

OK - you can uninstall/reinstall on that platform.

---

<div class="post-metadata">

**Author:** ![john-drake](https://avatars.discourse-cdn.com/v4/letter/j/74df32/32.png) [@john-drake](https://forums.powershell.org/u/john-drake)\
**Post date:** [May 18, 2014, 11:07pm UTC](https://forums.powershell.org/t/powershell-repair/2581/6 "2014-05-18T23:07:15Z")

</div>

I’m not confident this is going to work. I uninstalled WMF4 OK. Now I can open the ISE, and see PowerShell is back to v3. But get-command gives a similar error:

PS C:\Users\John\> $psversiontable  
get-command  
show-command

Name Value

* * *

PSVersion 3.0  
WSManStackVersion 3.0  
SerializationVersion 1.1.0.1  
CLRVersion 4.0.30319.18444  
BuildVersion 6.2.9200.16481  
PSCompatibleVersions {1.0, 2.0, 3.0}  
PSRemotingProtocolVersion 2.2  
get-command : Object reference not set to an instance of an object.  
At line:2 char:1

- get-command
- 

```auto
  + CategoryInfo : NotSpecified: (:) [Get-Command], NullReferenceException
  + FullyQualifiedErrorId : System.NullReferenceException,Microsoft.PowerShell.Commands.GetCommandCommand

```

get-command : Object reference not set to an instance of an object.  
At line:1 char:3

- @(get-command -CommandType Cmdlet,Function,Script,ExternalScript,Workflow),@(get …
- 

```auto
+ CategoryInfo : NotSpecified: (:) [Get-Command], NullReferenceException
+ FullyQualifiedErrorId : System.NullReferenceException,Microsoft.PowerShell.Commands.GetCommandCommand
```

---

<div class="post-metadata">

**Author:** ![john-drake](https://avatars.discourse-cdn.com/v4/letter/j/74df32/32.png) [@john-drake](https://forums.powershell.org/u/john-drake)\
**Post date:** [May 18, 2014, 11:42pm UTC](https://forums.powershell.org/t/powershell-repair/2581/7 "2014-05-18T23:42:39Z")

</div>

Uninstalling then reinstalling WMF4 did not fix get-command, which still errors, details below. Has anyone got any ideas what I may be doing wrong? This is on Windows 7 SP1 x64.

PS C:\Users\John\> $psversiontable

Name Value

* * *

PSVersion 4.0  
WSManStackVersion 3.0  
SerializationVersion 1.1.0.1  
CLRVersion 4.0.30319.18444  
BuildVersion 6.3.9600.16406  
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0}  
PSRemotingProtocolVersion 2.2

PS C:\Users\John\> get-command  
get-command : Object reference not set to an instance of an object.  
At line:1 char:1

- get-command
- 

```auto
  + CategoryInfo : NotSpecified: (:) [Get-Command], NullReferenceException
  + FullyQualifiedErrorId : System.NullReferenceException,Microsoft.PowerShell.Commands.GetCommandCommand
```

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex019/uploads/powershell/original/1X/385e4f9fe133561ad30a814262fe0e0ae6bc3ef0.png) [@system](https://forums.powershell.org/u/system)\
**Post date:** [May 19, 2014, 12:03am UTC](https://forums.powershell.org/t/powershell-repair/2581/8 "2014-05-19T00:03:06Z")

</div>

This bit looks odd in the error you posted last time:

```
@(get-command -CommandType Cmdlet,Function,Script,ExternalScript,Workflow),@(get …
```

That doesn’t match the command that you actually entered, according to your post. Just for giggles, try running PowerShell.exe with the -NoProfile switch, then run Get-Command again and see what happens.

---

<div class="post-metadata">

**Author:** ![john-drake](https://avatars.discourse-cdn.com/v4/letter/j/74df32/32.png) [@john-drake](https://forums.powershell.org/u/john-drake)\
**Post date:** [May 19, 2014, 8:51am UTC](https://forums.powershell.org/t/powershell-repair/2581/9 "2014-05-19T08:51:37Z")

</div>

Dave, thanks, I tried this (details below) but still had the issue. Any other ideas? I’d like to reset my PowerShell environment in case there is something like a profile issue, but don’t know of any way to do this. Simply uninstalling and reinstalling WMF4 did not fix it (and when WMF4 was uninstalled PS3 still had a similar issue running get-command). I feel like I’m missing something, but don’t know what.

C:&gt;powershell -noprofile  
Windows PowerShell  
Copyright (C) 2013 Microsoft Corporation. All rights reserved.

PS C:&gt; [Environment]::GetCommandLineArgs()  
powershell  
-noprofile  
PS C:&gt; get-command  
get-command : Object reference not set to an instance of an object.  
At line:1 char:1

- get-command
- 

```auto
  + CategoryInfo : NotSpecified: (:) [Get-Command], NullReferenceEx
 ception
  + FullyQualifiedErrorId : System.NullReferenceException,Microsoft.PowerShe
 ll.Commands.GetCommandCommand

```

PS C:&gt;

---

<div class="post-metadata">

**Author:** ![peter-jurgens](https://avatars.discourse-cdn.com/v4/letter/p/ac91a4/32.png) [@peter-jurgens](https://forums.powershell.org/u/peter-jurgens)\
**Post date:** [May 19, 2014, 1:14pm UTC](https://forums.powershell.org/t/powershell-repair/2581/10 "2014-05-19T13:14:21Z")

</div>

found an old thread with someone experiencing a similar issue.

[https://powershell.org/forums/topic/show-command-error-ise/](https://powershell.org/forums/topic/show-command-error-ise/)

Can’t help but think it is a profile issue. Do you have the same problem if you run Get-Command from the console? Also, try running powershell.exe -noprofile from the run dialog rather than from a commandline/ISE.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex019/uploads/powershell/original/1X/385e4f9fe133561ad30a814262fe0e0ae6bc3ef0.png) [@system](https://forums.powershell.org/u/system)\
**Post date:** [May 19, 2014, 1:27pm UTC](https://forums.powershell.org/t/powershell-repair/2581/11 "2014-05-19T13:27:31Z")

</div>

After you get the error, please run the following commands to dump more detailed information about it, and post the results here. Based on what I see so far, I’m still not sure what’s going on.

```
$error[0] | Format-List * -Force
$error[0].Exception | Format-List * -Force
```

---

<div class="post-metadata">

**Author:** ![john-drake](https://avatars.discourse-cdn.com/v4/letter/j/74df32/32.png) [@john-drake](https://forums.powershell.org/u/john-drake)\
**Post date:** [May 19, 2014, 8:55pm UTC](https://forums.powershell.org/t/powershell-repair/2581/12 "2014-05-19T20:55:46Z")

</div>

Thanks Peter and Dave, here’s the output (from a -noprofile session, Run “powershell.exe -noprofile”)

PS C:\Users\John\> get-command  
get-command : Object reference not set to an instance of an object.  
At line:1 char:1

- get-command
- 

```auto
  + CategoryInfo : NotSpecified: (:) [Get-Command], NullReferenceEx
 ception
  + FullyQualifiedErrorId : System.NullReferenceException,Microsoft.PowerShe
 ll.Commands.GetCommandCommand

```

PS C:\Users\John\> $error[0] | Format-List \* -Force

PSMessageDetails :  
Exception : System.NullReferenceException: Object reference not  
set to an instance of an object.  
at Microsoft.PowerShell.Commands.GetCommandCommand.I  
sCommandMatch(CommandInfo& current)  
at Microsoft.PowerShell.Commands.GetCommandCommand.A  
ccumulateMatchingCommands(IEnumerable`1 commandNames)  
at System.Management.Automation.CommandProcessor.Pro  
cessRecord()  
TargetObject :  
CategoryInfo : NotSpecified: (🙂 [Get-Command], NullReferenceException  
FullyQualifiedErrorId : System.NullReferenceException,Microsoft.PowerShell.Comm  
ands.GetCommandCommand  
ErrorDetails :  
InvocationInfo : System.Management.Automation.InvocationInfo  
ScriptStackTrace : at \<ScriptBlock\>, \<No file\>: line 1  
PipelineIterationInfo : {}

PS C:\Users\John\> $error[0].Exception | Format-List \* -Force

Message : Object reference not set to an instance of an object.  
Data : {}  
InnerException :  
TargetSite : Boolean  
IsCommandMatch(System.Management.Automation.CommandInfo ByRef)  
StackTrace : at Microsoft.PowerShell.Commands.GetCommandCommand.IsComman  
dMatch(CommandInfo& current)  
at Microsoft.PowerShell.Commands.GetCommandCommand.Accumula  
teMatchingCommands(IEnumerable`1 commandNames)  
at  
System.Management.Automation.CommandProcessor.ProcessRecord()  
HelpLink :  
Source : System.Management.Automation  
HResult : -2147467261

PS C:\Users\John\> [Environment]::GetCommandLineArgs()  
C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe  
-noprofile  
PS C:\Users\John\> $psversiontable

Name Value

* * *

PSVersion 4.0  
WSManStackVersion 3.0  
SerializationVersion 1.1.0.1  
CLRVersion 4.0.30319.18444  
BuildVersion 6.3.9600.16406  
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0}  
PSRemotingProtocolVersion 2.2

PS C:\Users\John\>

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex019/uploads/powershell/original/1X/385e4f9fe133561ad30a814262fe0e0ae6bc3ef0.png) [@system](https://forums.powershell.org/u/system)\
**Post date:** [May 20, 2014, 12:32am UTC](https://forums.powershell.org/t/powershell-repair/2581/13 "2014-05-20T00:32:09Z")

</div>

So weird… it looks like there may be a bug in Get-Command, but the problem is figuring out what’s triggering it. In the other post that Peter found, it was related to the Quest AD cmdlets in some way. It could be that one of the snapins or modules on your system is behaving the same way.

What do you get when you run these commands?

```
Get-Module -ListAvailable
Get-PSSnapin
Get-PSSnapin -Registered
```

---

<div class="post-metadata">

**Author:** ![daniel-krebs](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/daniel-krebs/32/484_2.png) [@daniel-krebs](https://forums.powershell.org/u/daniel-krebs)\
**Post date:** [May 20, 2014, 7:54am UTC](https://forums.powershell.org/t/powershell-repair/2581/14 "2014-05-20T07:54:46Z")

</div>

John,

Found an Microsoft KB article related to the Get-Command error. This one is about PowerShell v2 and SQL Server 2008/2008 R2. Do you have SQL Server 2008 components installed on your Win7 machine?

[http://support.microsoft.com/kb/2216478](http://support.microsoft.com/kb/2216478)

I think it is worth checking this out and upgrade your SQL Server 2008 components if installed to at least the Service Pack specified in the article.

Please let us know your progress and run Dave’s commands as well to gather more details.

Best,  
Daniel

---

<div class="post-metadata">

**Author:** ![john-drake](https://avatars.discourse-cdn.com/v4/letter/j/74df32/32.png) [@john-drake](https://forums.powershell.org/u/john-drake)\
**Post date:** [May 20, 2014, 8:08am UTC](https://forums.powershell.org/t/powershell-repair/2581/15 "2014-05-20T08:08:45Z")

</div>

Dave, thanks, output from those three gets is below

PS C:\Users\John\> Get-Module -ListAvailable

```
Directory: C:\Users\John\Documents\WindowsPowerShell\Modules

```

ModuleType Version Name ExportedCommands

* * *

Script 0.0 adoLib {New-Connection, new-sqlcommand, invoke-sql, invoke-query…}  
Script 1.0 Agent {Get-SqlConnection, Get-SqlServer, Get-AgentJobServer, Get…  
Script 0.0 ISECreamBasic {Add-IseMenu, Remove-IseMenu}  
Manifest 1.0.0.0 LogHelper {Get-LogFile, Get-LoggingPreference, Set-LogFile, Set-Logg…  
Script 0.0 mySQLLib {New-MySQLConnection, new-MySqlCommand, invoke-MySql, invo…  
Manifest 1.0 NetShell {ConvertFrom-HexIP, ConvertTo-BinaryIP, ConvertTo-Byte, Co…  
Manifest 1.0.1.0 NetworkScan {Find-IPv4Device, Find-SqlServerService}  
Script 0.0 OracleClient {new-oracle\_connection, invoke-oracle\_query, ConvertTo-ora…  
Script 0.0 OracleIse {Connect-Oracle, Disconnect-Oracle, Prompt, Get-FileName…}  
Script 0.0 PBM {Get-PolicyStore, Get-TargetServer, Write-PolicyEvalError,…  
Script 0.0 PerfCounters {Invoke-Sqlcmd2, Get-ProcessPerfcounter, Write-LogText, Ge…  
Script 0.0 RDS-Manager {Connect-RDSession, Disconnect-RDSession, Get-RDProcess, G…  
Script 1.0 Repl {Get-SqlConnection, Get-ReplServer, Get-ReplLightPublicati…  
Script 1.0 ShowMbrs {New-ShowMbrs, Set-ShowMbrs, Get-GroupUser, Get-ShowMbrs}  
Script 0.0 SQLIse {Test-SqlScript, Out-SqlScript, Invoke-ParseSql, Format-Sq…  
Script 1.0 SQLMaint {Invoke-DBMaint, Get-SqlConnection, Get-SqlServer, Get-Sql…  
Binary 1.0 SQLParser {Test-SqlScript, Out-SqlScript}  
Script 0.0 SQLProfiler {Invoke-Sqlcmd2, Save-InfoToSQLTable, Get-SQLProfiler}  
Script 0.0 SQLPSX  
Script 1.0 SQLServer {Get-SqlConnection, Get-SqlServer, Get-SqlDatabase, Get-Sq…  
Manifest 1.0.1.0 SqlServerDatabaseEngineInformation Get-SqlServerDatabaseEngineInformation  
Manifest 1.0.1.0 SqlServerInventory {Get-SqlServerInventory, Export-SqlServerInventoryToExcel,…  
Script 1.0 SSIS {New-ISApplication, Copy-ISItemSQLToSQL, Copy-ISItemSQLToF…  
Manifest 1.0.0.0 WindowsInventory {Get-WindowsInventory, Export-WindowsInventoryToExcel}  
Manifest 1.0.1.0 WindowsMachineInformation Get-WindowsMachineInformation  
Script 1.0 WPK {Add-CodeGenerationRule, ConvertFrom-TypeToScriptCmdlet, C…

```
Directory: C:\Program Files\WindowsPowerShell\Modules

```

ModuleType Version Name ExportedCommands

* * *

Manifest 1.0 xActiveDirectory  
Manifest 1.2 xComputerManagement  
Manifest 1.0 xDatabase  
Manifest 1.0 xDscDiagnostics {Trace-xDscOperation, Get-xDscOperation}  
Script 1.1 xDSCResourceDesigner {New-xDscResourceProperty, New-xDscResource, Update-xDscRe…  
Manifest 1.1 xFailOverCluster  
Manifest 2.1 xHyper-V  
Manifest 2.1 xNetworking  
Script 2.0.0.0 xPSDesiredStateConfiguration {New-PSWSEndpoint, Set-AppSettingsInWebconfig}  
Manifest 1.0 xRemoteDesktopSessionHost  
Manifest 1.0 xSmbShare  
Manifest 1.1.1 xSqlPs  
Manifest 1.0 xSystemSecurity  
Manifest 1.2 xWebAdministration

```
Directory: C:\Windows\system32\WindowsPowerShell\v1.0\Modules

```

ModuleType Version Name ExportedCommands

* * *

Manifest 1.0.0.0 AppLocker {Set-AppLockerPolicy, Get-AppLockerPolicy, Test-AppLockerP…  
Manifest 1.0.0.0 BitsTransfer {Add-BitsFile, Remove-BitsTransfer, Complete-BitsTransfer,…  
Manifest 1.0.0.0 CimCmdlets {Get-CimAssociatedInstance, Get-CimClass, Get-CimInstance,…  
Script 1.0.0.0 ISE {New-IseSnippet, Import-IseSnippet, Get-IseSnippet}  
Manifest 3.0.0.0 Microsoft.PowerShell.Diagnostics {Get-WinEvent, Get-Counter, Import-Counter, Export-Counter…  
Manifest 3.0.0.0 Microsoft.PowerShell.Host {Start-Transcript, Stop-Transcript}  
Manifest 3.1.0.0 Microsoft.PowerShell.Management {Add-Content, Clear-Content, Clear-ItemProperty, Join-Path…  
Manifest 3.0.0.0 Microsoft.PowerShell.Security {Get-Acl, Set-Acl, Get-PfxCertificate, Get-Credential…}  
Manifest 3.1.0.0 Microsoft.PowerShell.Utility {Format-List, Format-Custom, Format-Table, Format-Wide…}  
Manifest 3.0.0.0 Microsoft.WSMan.Management {Disable-WSManCredSSP, Enable-WSManCredSSP, Get-WSManCredS…  
Binary 1.0 PSDesiredStateConfiguration {Set-DscLocalConfigurationManager, Start-DscConfiguration,…  
Script 1.0.0.0 PSDiagnostics {Disable-PSTrace, Disable-PSWSManCombinedTrace, Disable-WS…  
Binary 1.1.0.0 PSScheduledJob {New-JobTrigger, Add-JobTrigger, Remove-JobTrigger, Get-Jo…  
Manifest 2.0.0.0 PSWorkflow {New-PSWorkflowExecutionOption, New-PSWorkflowSession, nwsn}  
Manifest 1.0.0.0 PSWorkflowUtility Invoke-AsWorkflow  
Manifest 1.0.0.0 TroubleshootingPack {Get-TroubleshootingPack, Invoke-TroubleshootingPack}

PS C:\Users\John\> Get-PSSnapin

Name : Microsoft.PowerShell.Core  
PSVersion : 4.0  
Description : This Windows PowerShell snap-in contains cmdlets used to manage components of Windows PowerShell.

PS C:\Users\John\> Get-PSSnapin -Registered

Name : SqlServerCmdletSnapin100  
PSVersion : 2.0  
Description : This is a PowerShell snap-in that includes various SQL Server cmdlets.

Name : SqlServerProviderSnapin100  
PSVersion : 2.0  
Description : SQL Server Provider

PS C:\Users\John\>

---

<div class="post-metadata">

**Author:** ![john-drake](https://avatars.discourse-cdn.com/v4/letter/j/74df32/32.png) [@john-drake](https://forums.powershell.org/u/john-drake)\
**Post date:** [May 20, 2014, 8:23am UTC](https://forums.powershell.org/t/powershell-repair/2581/16 "2014-05-20T08:23:08Z")

</div>

Daniel, thanks, I do have SQL 2008 R2 (and SQL 2012) instances on this machine. The SQL 2008 R2 instance is patched to Service Pack 1 (version 10.50.2550, SP1 is 10.50.2500) which is remedy suggested by the article.

---

<div class="post-metadata">

**Author:** ![daniel-krebs](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/daniel-krebs/32/484_2.png) [@daniel-krebs](https://forums.powershell.org/u/daniel-krebs)\
**Post date:** [May 20, 2014, 8:33am UTC](https://forums.powershell.org/t/powershell-repair/2581/17 "2014-05-20T08:33:43Z")

</div>

Hmm. Please attempt to uninstall the SQL 2008 PowerShell Snap-in, if required for your work make sure you’ve the new SqlPs module of SQL 2012 installed and try again to run Get-Command.

Thanks  
Daniel

---

<div class="post-metadata">

**Author:** ![john-drake](https://avatars.discourse-cdn.com/v4/letter/j/74df32/32.png) [@john-drake](https://forums.powershell.org/u/john-drake)\
**Post date:** [May 20, 2014, 9:43pm UTC](https://forums.powershell.org/t/powershell-repair/2581/18 "2014-05-20T21:43:09Z")

</div>

Daniel, thanks, this is my first attempt at removing a PowerShell snap-in, and I’m not having any success. The snap-in shows in the “get” command but is ignored by the remove command. Am I missing a prefix?

PS Env:&gt; Get-PSSnapin -Registered

Name : SqlServerCmdletSnapin100  
PSVersion : 2.0  
Description : This is a PowerShell snap-in that includes various SQL Server cmdlets.

Name : SqlServerProviderSnapin100  
PSVersion : 2.0  
Description : SQL Server Provider

PS Env:&gt; remove-pssnapin -name SqlServerCmdletSnapin100  
remove-pssnapin : No Windows PowerShell snap-ins matching the pattern ‘SqlServerCmdletSnapin100’ were found. Check the  
pattern and then try the command again.  
At line:1 char:1

- remove-pssnapin -name SqlServerCmdletSnapin100
- 

```auto
  + CategoryInfo : InvalidArgument: (SqlServerCmdletSnapin100:String) [Remove-PSSnapin], PSArgumentExceptio
 n
  + FullyQualifiedErrorId : NoPSSnapInsFound,Microsoft.PowerShell.Commands.RemovePSSnapinCommand

```

PS Env:&gt; **Get-PSSnapin -Registered | remove-pssnapin -whatif**  
remove-pssnapin : No Windows PowerShell snap-ins matching the pattern ‘SqlServerCmdletSnapin100’ were found. Check the  
pattern and then try the command again.  
At line:1 char:28

- Get-PSSnapin -Registered | remove-pssnapin -whatif
- 

```
                       ~~~~~~~~~~~~~~~~~~~~~~~

```

  - CategoryInfo : InvalidArgument: (SqlServerCmdletSnapin100:String) [Remove-PSSnapin], PSArgumentExceptio  
n
  - FullyQualifiedErrorId : NoPSSnapInsFound,Microsoft.PowerShell.Commands.RemovePSSnapinCommand

remove-pssnapin : No Windows PowerShell snap-ins matching the pattern ‘SqlServerProviderSnapin100’ were found. Check  
the pattern and then try the command again.  
At line:1 char:28

- Get-PSSnapin -Registered | remove-pssnapin -whatif
- 

```
                       ~~~~~~~~~~~~~~~~~~~~~~~

```

  - CategoryInfo : InvalidArgument: (SqlServerProviderSnapin100:String) [Remove-PSSnapin], PSArgumentExcept  
ion
  - FullyQualifiedErrorId : NoPSSnapInsFound,Microsoft.PowerShell.Commands.RemovePSSnapinCommand

PS Env:&gt;

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex019/uploads/powershell/original/1X/385e4f9fe133561ad30a814262fe0e0ae6bc3ef0.png) [@system](https://forums.powershell.org/u/system)\
**Post date:** [May 20, 2014, 9:56pm UTC](https://forums.powershell.org/t/powershell-repair/2581/19 "2014-05-20T21:56:48Z")

</div>

This isn’t something I’ve done before either, but it looks like the list of registered Snapins is stored in the registry (under HKLM:\SOFTWARE\Microsoft\PowerShell\1\PowerShellSnapIns\ ), and there are apparently no PowerShell cmdlets for registering or unregistering them. I’d recommend exporting a backup of that key first, then deleting one or both of the SQL snapin keys from that location.

---

<div class="post-metadata">

**Author:** ![john-drake](https://avatars.discourse-cdn.com/v4/letter/j/74df32/32.png) [@john-drake](https://forums.powershell.org/u/john-drake)\
**Post date:** [May 21, 2014, 11:49am UTC](https://forums.powershell.org/t/powershell-repair/2581/20 "2014-05-21T11:49:58Z")

</div>

Dave, thanks, those keys were there. After deleting them and restarting the machine this (below) is what happens. Any other ideas?

PS C:\Users\John\> get-pssnapin

Name : Microsoft.PowerShell.Core  
PSVersion : 4.0  
Description : This Windows PowerShell snap-in contains cmdlets used to manage components of Windows PowerShell.

PS C:\Users\John\> get-pssnapin -registered  
PS C:\Users\John\> get-command  
get-command : Object reference not set to an instance of an object.  
At line:1 char:1

- get-command
- 

```auto
  + CategoryInfo : NotSpecified: (:) [Get-Command], NullReferenceException
  + FullyQualifiedErrorId : System.NullReferenceException,Microsoft.PowerShell.Commands.GetCommandCommand

```

PS C:\Users\John\>

[Next page](https://forums.powershell.org/t/powershell-repair/2581.md?page=2)
