# Get-DSCResource Error

**URL:** <https://forums.powershell.org/t/get-dscresource-error/2580>\
**Category:** DSC\
**Created:** [May 18, 2014, 11:32am UTC](https://forums.powershell.org/t/get-dscresource-error/2580 "2014-05-18T11:32:02Z")\
**Posts on this page:** 10\
**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, 11:32am UTC](https://forums.powershell.org/t/get-dscresource-error/2580/1 "2014-05-18T11:32:02Z")

</div>

If I get an error mentioning v1.0 when running Get-DSCResource for the first time in PowerShell v4 (as shown below) can you tell me what I am doing wrong? (This is on x64 Windows 7 and I’m working through the DSC eBook.) Thanks.

PS C:\Program Files\WindowsPowerShell\modules\> get-dscresource  
Get-Command : Object reference not set to an instance of an object.  
At  
C:\windows\system32\windowspowershell\v1.0\Modules\PSDesiredStateConfiguration\PSDesiredStateConfiguration.psm1:2261  
char:27

- 

```
        $resources += Get-Command -CommandType Configuration | ForEach-Objec ...

```

- 

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

```

  - CategoryInfo : NotSpecified: (🙂 [Get-Command], NullReferenceException
  - FullyQualifiedErrorId : System.NullReferenceException,Microsoft.PowerShell.Commands.GetCommandCommand

PS C:\Program Files\WindowsPowerShell\modules\> $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

---

<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 18, 2014, 11:53am UTC](https://forums.powershell.org/t/get-dscresource-error/2580/2 "2014-05-18T11:53:36Z")

</div>

Microsoft included “v1.0” in the default path to PowerShell’s installation directory originally, and now they’re sort of stuck with it. You can ignore that part.

That said, I’m not sure what’s causing the actual error here. I don’t see anything there that looks like it should be able to produce a null reference exception.

---

<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, 12:43pm UTC](https://forums.powershell.org/t/get-dscresource-error/2580/3 "2014-05-18T12:43:48Z")

</div>

Thanks Dave. It looks like it is an issue running get-command rather than an issue running get-dscresource. I’ve only recently upgraded to v4. I do have SQL Server on this machine, which may have some bearing on this.

PS C:\Program Files\WindowsPowerShell\Modules\> 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:** ![donj](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/donj/32/137_2.png) [@donj](https://forums.powershell.org/u/donj)\
**Post date:** [May 18, 2014, 2:35pm UTC](https://forums.powershell.org/t/get-dscresource-error/2580/4 "2014-05-18T14:35:00Z")

</div>

Is KB2883200 installed?

---

<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, 3:33pm UTC](https://forums.powershell.org/t/get-dscresource-error/2580/5 "2014-05-18T15:33:06Z")

</div>

Don, thanks, no I don’t see it. I’m on Windows 7 (x64) not Windows 8.1. BTW, I don’t think this is a DSC issue, I need to get get-command working.

---

<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:51pm UTC](https://forums.powershell.org/t/get-dscresource-error/2580/6 "2014-05-18T17:51:10Z")

</div>

John,

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

---

<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:15pm UTC](https://forums.powershell.org/t/get-dscresource-error/2580/7 "2014-05-18T23:15:19Z")

</div>

Daniel, thanks, I’m trying this now. I’m not feeling very confident, because when WMF4 was uninstalled I could bring up the v3 ISE but get-command gave 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:49pm UTC](https://forums.powershell.org/t/get-dscresource-error/2580/8 "2014-05-18T23:49:30Z")

</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. We can probably close this topic, as I’ve raised another under “PowerShell Repair?” in the Q&A forum. [The issue is with get-command erroring, which is why Get-DSCResource is not working.]

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:** ![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, 4:45pm UTC](https://forums.powershell.org/t/get-dscresource-error/2580/9 "2014-05-21T16:45:53Z")

</div>

This advice from Dave Wyatt fixed both get-command and Get-DSCResource on my machine, thank you all for your help

“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.”

---

<div class="post-metadata">

**Author:** ![dotnVo](https://avatars.discourse-cdn.com/v4/letter/d/4af34b/32.png) [@dotnVo](https://forums.powershell.org/u/dotnVo)\
**Post date:** [May 16, 2024, 9:17pm UTC](https://forums.powershell.org/t/get-dscresource-error/2580/10 "2024-05-16T21:17:37Z")

</div>

Closed on May 16, 2024, 9:17pm UTC


