Author Posts

June 23, 2014 at 1:07 pm

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?

June 23, 2014 at 2:58 pm

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
       }

June 23, 2014 at 6:26 pm

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!