PowerShell / JEA

Just Enough Administration
http://aka.ms/JEAdocs
MIT License
257 stars 60 forks source link

Register-PSSessionConfiguration continues even when error is reported #51

Open johlju opened 6 years ago

johlju commented 6 years ago

For example when running this on a node not part of the CONTOSO domain.

Invoke-DscResource -ModuleName JustEnoughAdministration -Name JeaEndpoint -Method Set -Verbose -Property @{
            EndpointName        = 'Microsoft.PowerShell'
            RoleDefinitions     = "@{ 'CONTOSO\DnsAdmins' = @{ RoleCapabilities = 'DnsAdmin' } }"
            TranscriptDirectory = 'C:\ProgramData\JeaEndpoint\Transcripts'
            ScriptsToProcess    = @('C:\ProgramData\JeaEndpoint\startup.ps1')
            VisibleCmdlets      = "'DnsServer\*',
                @{
                    'Name'       = 'Restart-Service'
                    'Parameters' = @{
                        'Name'        = 'Name'
                        'ValidateSet' = 'Dns'
                    }
                }"
}

It's reporting this error, but continue to process without failing.

'Could not grant remote access to 'CONTOSO\DnsAdmins': 'Some or all identity references could not be translated.'

I suggest adding -ErrorAction to the calls to Register-PSSessionConfiguration, and maybe also Unregister-PSSessionConfiguration.