PowerShell DSC Group Resource - "Could not find a principal with the provided name"
You have to specify the credentials:
Example:
Way to get the credentials:
$securedstring = ConvertTo-SecureString -String $Password -AsPlainText -Force
[PSCredential]$cred = New-Object System.Management.Automation.PSCredential ($UserName, $securedstring)
And this is the code u need to configure the DSC resource
$ConfigurationData = @{
AllNodes = @(
@{
NodeName="*"
PSDscAllowPlainTextPassword=$true
}
@{
NodeName="SRV2-WS2012R2"
}
@{
NodeName="SRV3-WS2012R2"
}
)
}
Node $AllNodes.NodeName
{
LocalConfigurationManager
{
RebootNodeIfNeeded = $false
}
Group $group.Name
{
GroupName = $group.Name
Ensure = $group.Ensure
Members = $group.Members
Credential = $cred
}
}
Then simply execute
ProcessDscResources -ConfigurationData $ConfigurationData -OutputPath $folderPathTmp
Start-DscConfiguration -Wait -Force -Path $folderPathTmp