something exciting

Some information about the exciting thing

Table of contents generated with markdown-toc


function Get-AuthorizedDHCPServers {
    # The configNC is replicated to all DCs in a forest, similar
    # to the schema, so this function will get all authorized
    # DHCP servers in the forest.
    $adsi = [ADSI]( "LDAP://RootDSE" )
    $configNC = $adsi.configurationNamingContext.Item( 0 )
    $names = @()
    $cn = [ADSI]("LDAP://CN=NetServices,CN=Services," + $configNC )
    foreach ( $object in $cn.children ) {
        if ( $null -ne $object.Properties[ 'dhcpIdentification' ] ) {
            if ( $object.dhcpIdentification -eq 'DHCP Server Object' ) {
                $names += $object.Name

$Servers = Get-AuthorizedDHCPServers

#$ComputerName = "PTHADDS03.FMG.local"
#$ServiceName = "DHCPServer"
#$serviceObj = Get-Service -ComputerName $ComputerName | ?{ $_.ServiceName -eq $serviceName } | Select-Object Name, @{Name="Jeremy";Expression={$._Status}}, Status


$sessions = New-PSSession -ComputerName $Servers
$serviceObj = Invoke-Command -Session $sessions -ScriptBlock {
    $ServiceName = "DHCPServer"
    Get-Service | Where-Object { $_.ServiceName -eq $serviceName } | Select-Object -Property Name, @{Name = "State"; Expression = { $_.Status } }


Remove-PSSession $sessions

Back to Top


Please feel free to copy parts of the script or if you would like to download the entire script, simple click the download button. You can download the complete repository in a zip file by clicking the Download link in the menu bar on the left hand side of the page.

Report Issues

You can report an issue or contribute to this site on GitHub. Simply click the button below and add any relevant notes. I will attempt to respond to all issues as soon as possible.


Back to Top