# Class Requires Value of type MSFT\_Credential

**URL:** <https://forums.powershell.org/t/class-requires-value-of-type-msft-credential/2739>\
**Category:** DSC\
**Created:** [June 23, 2014, 7:37am UTC](https://forums.powershell.org/t/class-requires-value-of-type-msft-credential/2739 "2014-06-23T07:37:19Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![jacob-benson](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/jacob-benson/32/801_2.png) [@jacob-benson](https://forums.powershell.org/u/jacob-benson)\
**Post date:** [June 23, 2014, 7:37am UTC](https://forums.powershell.org/t/class-requires-value-of-type-msft-credential/2739/1 "2014-06-23T07:37:19Z")

</div>

I am writing (or trying) to write a Custom Resource that uses a Credential parameter. The Test-Schema and Test-Resource cmdlets all return true. However, when I go to invoke the Configuration, I get this error:

```
cSCVMM\cSCVMM_Hardware : Class 'cSCVMM_Hardware' requires that a value of type 'MSFT_Credential' be provided for property 'Credential'.
At line:13 char:9
+ cSCVMM_Hardware MyHardwareProfile
+ ~~~~~~~~~~~~~~~
    + CategoryInfo : InvalidOperation: (:) [Write-Error], ParentContainsErrorRecordException
    + FullyQualifiedErrorId : MissingValueForMandatoryProperty,cSCVMM\cSCVMM_Hardware
 
Errors occurred while processing configuration 'TestSCVMMHardware'.
At C:\WINDOWS\system32\WindowsPowerShell\v1.0\Modules\PSDesiredStateConfiguration\PSDesiredStateConfiguration.psm1:2203 char:5
+ throw $errorRecord
+ ~~~~~~~~~~~~~~~~~~
    + CategoryInfo : InvalidOperation: (TestSCVMMHardware:String) [], InvalidOperationException
    + FullyQualifiedErrorId : FailToProcessConfiguration
```

My schema.mof contains this line:

```
[Required, EmbeddedInstance("MSFT_Credential"), Description("Valid credential for connecting to VMM Server")] String Credential;
```

Comparing the schema and .psm1 file to those of the ADDomain resource, I can’t see what the issue is. I looked to see if any of Steve Murawski’s Stack Exchange Resources use a credential parameter, and the Scheduled Task one does. I tried changing my Credential parameter in all 3 functions to what his is in that resource, but I still got the same error. He has his credential set like this:

```
$Credential = [System.Management.Automation.PSCredential]::Empty
```

Here is what my Configuration looks like.

```
Configuration TestSCVMMHardware
{

    param
    (
        [PSCredential]$Credential
    )

    Import-DscResource -Module cSCVMM

    node localhost
    {
        cSCVMM_Hardware MyHardwareProfile
        {
            VMMServer = "MY-VMM-SERVER1"
            CPUCount = 2
            DVDDrive = $True
            Ensure = "Present"
            Name = "Jacobs Profile"
            VMNetwork = "Server Traffic"
       }

    }

}

TestSCVMMHardware -Credential (Get-Credential domain\name)
```

I have tried using 2 different domain credentials, and don’t have any more ideas. What am I doing wrong?

---

<div class="post-metadata">

**Author:** ![jhofferle](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/jhofferle/32/804_2.png) [@jhofferle](https://forums.powershell.org/u/jhofferle)\
**Post date:** [June 23, 2014, 9:28am UTC](https://forums.powershell.org/t/class-requires-value-of-type-msft-credential/2739/2 "2014-06-23T09:28:28Z")

</div>

I was just messing around with this same exact thing today. It looks like you’re passing the credential to your configuration, but not to the resource that needs the credential. Have you tried:

```
cSCVMM_Hardware MyHardwareProfile
        {
            VMMServer = "MY-VMM-SERVER1″
            CPUCount = 2
            DVDDrive = $True
            Ensure = "Present"
            Name = "Jacobs Profile"
            VMNetwork = "Server Traffic"
            Credential = $Credential
       }
```

---

<div class="post-metadata">

**Author:** ![jacob-benson](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/jacob-benson/32/801_2.png) [@jacob-benson](https://forums.powershell.org/u/jacob-benson)\
**Post date:** [June 23, 2014, 12:56pm UTC](https://forums.powershell.org/t/class-requires-value-of-type-msft-credential/2739/3 "2014-06-23T12:56:15Z")

</div>

Ah hell. You are absolutely correct. I was so convinced I had screwed up something with the Resource that I failed to see the obvious. Thanks Jason!

---

<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/class-requires-value-of-type-msft-credential/2739/4 "2024-05-16T21:17:34Z")

</div>

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


