Step-by-Step Guide: Just Enough Administration PowerShell

Here are the step-by-step instructions for creating a Just Enough Administration PowerShell session for a DNS server:

  1. Define the Role Capabilities: The first step is to define the role capabilities for the DNS server. This can be done using a PowerShell script that defines the commands and parameters that the role can run. For example:




$RoleCapabilities = @{
    RoleName = "DNSAdmin"
    VisibleCmdlets = "Get-DnsServerZone","Get-DnsServerResourceRecord","Get-DnsServerStatistics","Add-DnsServerResourceRecord","Remove-DnsServerResourceRecord"
    } 
New-PSRoleCapabilityFile @RoleCapabilities -Path "C:\JEA\DNSAdmin.psrc"

This script defines a role called “DNSAdmin” and lists the PowerShell cmdlets that are allowed to be used by this role. The output of the script is a file called “DNSAdmin.psrc” that will be used in the next step.

  1. Create the Session Configuration File: The next step is to create a session configuration file that defines the role capabilities and other settings for the JEA session. This can be done using a PowerShell script that defines the configuration settings. For example:




$SessionConfiguration = @{
    SessionType = 'RestrictedRemoteServer'
    LanguageMode = 'FullLanguage'
    Name = 'DNSAdminSession'
    RunAsVirtualAccount = $true
    RoleDefinitions = @{
        'DNSAdmin' = @{
            RoleCapabilities = @{
                'DNSAdmin' = $true
            }
        }
    }
}
New-PSSessionConfigurationFile @SessionConfiguration -Path "C:\JEA\DNSAdminSession.pssc" -Force

This script creates a session configuration file called “DNSAdminSession.pssc” that defines the session type, language mode, and other settings. It also includes the role definition for the “DNSAdmin” role and the path to the role capability file created in the previous step.

  1. Register the Session Configuration: The next step is to register the session configuration with PowerShell. This can be done using the following PowerShell command:




Register-PSSessionConfiguration -Path "C:\JEA\DNSAdminSession.pssc" -Name "DNSAdminSession"

This command registers the session configuration file and assigns it the name “DNSAdminSession”. This makes the session configuration available for use in PowerShell.

  1. Test the Session: The final step is to test the JEA session configuration by connecting to the DNS server using the JEA session. This can be done using the following PowerShell command:




Enter-PSSession -ComputerName <DNS_Server_Name> -ConfigurationName DNSAdminSession -Credential (Get-Credential)

This command connects to the DNS server using the JEA session configuration and prompts for credentials to authenticate. Once authenticated, the user will only have access to the commands and parameters defined in the role capabilities for the “DNSAdmin” role.

In summary, creating a Just Enough Administration PowerShell session for a DNS server involves defining the role capabilities, creating the session configuration file, registering the session configuration, and testing the session. By following these steps, you can create a secure and granular way to delegate administrative tasks for a DNS server.

Author: tonyhughes