Skip to content

Commit 061527f

Browse files
committed
Fix
1 parent 7bc1253 commit 061527f

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

DDI/Get-DhcpOptionUsed.ps1

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
Check for the usage of specific DHCP option IDs in any context on a DHCP server.
55
66
.DESCRIPTION
7-
Check for the usage of specific DHCP option IDs in any context on a DHCP server, including DHCP server options, scope options, and reservation options. Check all DHCP options used on a server, including server options, scope options, and reservation options.
7+
Check for the usage of specific DHCP option IDs in any context on a DHCP server, including DHCP server options, scope options, and reservation options.
88
99
.PARAMETER Server
1010
The hostname of a DHCP server to inspect.
@@ -23,7 +23,7 @@
2323
[Parameter(Position = 0)]
2424
[ValidateNotNullOrEmpty()]
2525
[string]
26-
$Server = 'localhost'
26+
$Server = $env:COMPUTERNAME
2727
)
2828

2929
begin {
@@ -32,9 +32,19 @@
3232
$Server = $env:COMPUTERNAME
3333
}
3434

35+
# Define the options to check
36+
$DhcpOptionList = [ordered]@{
37+
6 = 'DNS Servers'
38+
42 = 'NTP Servers'
39+
44 = 'WINS/NBNS Servers'
40+
}
41+
$OptionsToCheck = $DhcpOptionList.Keys
42+
} # end begin block
43+
44+
process {
3545
# Check if the $Server is listed in the objects returned by Get-DhcpServerInDC.
3646
$DhcpServers = Get-DhcpServerInDC
37-
if ($DhcpServers.ServerName -notcontains $Server) {
47+
if ($DhcpServers.DnsName -notmatch $Server) {
3848
Write-Warning -Message "The server `'$Server`' is not an authorized DHCP server in the domain."
3949
return
4050
}
@@ -47,16 +57,6 @@
4757
return
4858
}
4959

50-
# Define the options to check
51-
$DhcpOptionList = [ordered]@{
52-
6 = 'DNS Servers'
53-
42 = 'NTP Servers'
54-
44 = 'WINS/NBNS Servers'
55-
}
56-
$OptionsToCheck = $DhcpOptionList.Keys
57-
} # end begin block
58-
59-
process {
6060
# Get all IPv4 DHCP server options and check the options set on each.
6161
Write-Host 'Checking DHCP Server Options....' -ForegroundColor Green -BackgroundColor Black
6262
$ServerOptions = Get-DhcpServerv4OptionValue

0 commit comments

Comments
 (0)