PowerShell / PSDscResources

MIT License
129 stars 53 forks source link

setGroup: Error when I try to exclude a user from Users builtin group #186

Closed PlekyNeed closed 4 years ago

PlekyNeed commented 4 years ago

Hello,

I'm trying to remove a user from builtin "Users" local group.

$NO_ACCESS_USERS = @('myUser') GroupSet GroupUsersCleaningNO_ACCESS { GroupName = @("Users") Ensure = "Present" MembersToExclude = $NO_ACCESS_USERS

Credential = Get-Credential

        }

I've got a : Exception calling ".ctor" with "2" argument(s): "Server names cannot contain a space character."

it looks similar to issue : https://github.com/PowerShell/PSDscResources/issues/26

"Users" contains Authenticated Users and Interactive

Thanks for your help

DimaGepard commented 4 years ago

I've got similar issue when trying to include user to "Users" group

 Group ManageUsersGroup {
            GroupName='Users'          
            DependsOn= '[User]OperatotUser'    
            Ensure= 'Present'                   
            MembersToInclude= 'operator'     
        }
Exception calling ".ctor" with "2" argument(s): "Server names cannot contain a space character."
    + CategoryInfo          : InvalidOperation: (:) [], CimException
    + FullyQualifiedErrorId : ConstructorInvokedThrowException,Microsoft.PowerShell.Commands.NewObjectCommand
    + PSComputerName        : DESKTOP-V20KT15

Using

Major  Minor  Build  Revision
-----  -----  -----  --------
5      1      17763  1007

Have we got any solution for this?

DimaGepard commented 4 years ago

I've got similar issue when trying to include user to "Users" group

 Group ManageUsersGroup {
            GroupName='Users'          
            DependsOn= '[User]OperatotUser'    
            Ensure= 'Present'                   
            MembersToInclude= 'operator'     
        }
Exception calling ".ctor" with "2" argument(s): "Server names cannot contain a space character."
    + CategoryInfo          : InvalidOperation: (:) [], CimException
    + FullyQualifiedErrorId : ConstructorInvokedThrowException,Microsoft.PowerShell.Commands.NewObjectCommand
    + PSComputerName        : DESKTOP-V20KT15

Using

Major  Minor  Build  Revision
-----  -----  -----  --------
5      1      17763  1007

Have we got any solution for this?

Ok, the devil is in the detail

if you import right module everything works fine

Import-DscResource -ModuleName 'PSDscResources'
# Import-DscResource -ModuleName 'PSDesiredStateConfiguration'
PlagueHO commented 4 years ago

Hi @PlekyNeed and @DimaGepard - you are right: PSDesiredStateConfiguration is the built in resources, so you want to use PSDscResources. Alternately you can also use xPSDesiredStateConfiguration (https://github.com/dsccommunity/xPSDesiredStateConfiguration)- this is the community maintained one. However, that one is not guaranteed to be 100% feature compatible with PSDscResources. Note: xPSDesiredStateConfiguration is not supported by Microsoft - it is community supported.