xGroup fails with error "Server names cannot contain a space character”
This issue was recently raised and closed here https://github.com/PowerShell/xPSDesiredStateConfiguration/issues/288
This is still an issue in 6.3.0.0 Trying to add IIS APPPOOL\iHostWSAppPool user to the Administrator group.
Haven't had time to diagnose the full issue but seems to be thrown in the Get-PrincipalContext function.
Was able to get the desired result with this LocalGroupMember cmdlets:
Script AddPoolUserToAdministratorGroup {
GetScript = { @{ Result = '' } }
SetScript = { Add-LocalGroupMember -Group Administrators -Member 'IIS APPPOOL\p') }
TestScript = { [bool] ((Get-LocalGroupMember -Group Administrators).Name -eq ('IIS APPPOOL\p'))}
}
To add to the problem - We have quite a lot of groups with spaces in them - e.g. "IT ServiceX Admins" - these cannot be added using xGroup as they contain spaces. Issue 288 seems to just whitelist certain groups/users but the problemsolving should be a general fix :-)
Update: This was not a problem with spaces in the Identity part as I first thought. The problem is that UPN style members does not seem to be supported by the 'FindByIdentity' function.