Skip to content

Instantly share code, notes, and snippets.

@rjt
Created July 25, 2014 00:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rjt/de70984dbfa0781e6d83 to your computer and use it in GitHub Desktop.
Save rjt/de70984dbfa0781e6d83 to your computer and use it in GitHub Desktop.
$ReservationsFile = "P:\DOCS\TECH\DataComm Infrastructure\DHCP-NetMan-20140721000436-NewLayout.XML"
[xml] $xml = Get-Content $ReservationsFile
$Reservations = $xml.DHCPServer.IPV4.Scopes.Scope.Reservations.Reservation;
#/DHCPServer/IPv4/Scopes/Scope/Reservations/Reservation"
foreach ($Reservation in $Reservations)
{
if("YES" -eq $Reservation.UpdateServer)
{
$dhcpEntry =
@{
ClientID=$Reservation.ClientId;
Name=$Reservation.Name;
IPAddress=[System.Net.IPAddress] $Reservation.IPAddress;
Description=$Reservation.Description;
Type='BOTH';
ComputerName='domain01';
};
#$dhcpEntry
<#Get-DhcpServerv4Reservation
[-ScopeId] <IPAddress>
[-ClientId] <String[]>
[-AsJob]
[-CimSession <CimSession[]> ]
[-ComputerName <String> ]
[-ThrottleLimit <Int32> ]
[ <CommonParameters>]
#>
[string]$Mac1='00-16-d4-08-3b-e7';
[string]$Mac2='da-f3-1b-1d-b2-9a'; #DOES NOT EXIST.
[string]$Mac3='00-16-d4-08-3c-0c';
""
$dhcpEntry.Item("ClientId")
'dhcpEntry.Item("ClientId").GetType() = ' + $dhcpEntry.Item("ClientId").getType()
""
'Mac1.GetType() ' + $Mac1.GetType()
""
'Mac1.GetTypeCode() ' + $Mac1.GetTypeCode()
""
#$MacAlreadyHasReservation = Get-DhcpServerv4Reservation -ClientID $($dhcpEntry.Item("ClientId")) -ScopeID 10.0.100.0 -ComputerName "domain01.network.corp.eceo.us" -Verbose
#$MacAlreadyHasReservation
$MacAlreadyHasReservation = Get-DhcpServerv4Reservation -ClientId '$Mac1' -ScopeId 10.0.100.0 -ErrorVariable $err
if($err) { ERROR: $err }
$MacAlreadyHasReservation
$MacAlreadyHasReservation = Get-DhcpServerv4Reservation -ClientId '$Mac2' -ScopeId 10.0.100.0 -ErrorVariable $err
if($err) { ERROR: $err }
'err= ' + $err
'Error= ' + $Error
'ErrorView = ' + $ErrorView
$MacAlreadyHasReservation
<#$MacAlreadyHasReservation = Get-DhcpServerv4Reservation -ClientId '$Mac3' -ScopeId 10.0.100.0 -ErrorVariable $err
if($err) { ERROR: $err }
$MacAlreadyHasReservation #><#| Get-Member #>
#Get-DhcpServerv4Reservation.ps1 $dhcpEntry.Keys("ClientID")
#Add-DhcpServerv4Reservation -ComputerName dhcpserver.contoso.com -ScopeId 10.10.10.0 -IPAddress $freeip -ClientId F0-DE-F1-7A-00-5E -Description "Reservation for Printer"
#Set-DhcpServerv4Reservation @dhcpEntry -Confirm;
<#
Set-DhcpServerv4Reservation
-ComputerName dhcpserver.contoso.com
-Name printer.contoso.com
-IPAddress 10.10.10.5
-Description "Fourth Floor Printer"
#>
Write-Output "";
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment