尝试在PowerShell中运行Add-DhcpServerv4Reservation
命令时,我一直收到以下错误:
+ CategoryInfo : NotSpecified: (xxx.xxx.42.234:root/Microsoft/...erv4Reservation) [Add-DhcpServerv4Reservation], CimException + FullyQualifiedErrorId : WIN32 1753,Add-DhcpServerv4Reservation
(xxx具有IP地址的实际数量)
当我尝试单独运行命令时出现此错误:
Add-DhcpServerv4Reservation -Name test -ScopeId xxx.xxx.40.0 -IPAddress xxx.xxx.42.234 -ClientId 01-01-01-01-01-01 -Description computer -Type DHCP
以及以下脚本:
Import-Module DHCPServer
clear
$IP = Read-Host "Please type in the IP Address of the computer you would like to add"
clear
try {
$ReservationObj = Get-DhcpServerv4Reservation -ComputerName xxx.xxx.40.4 -IPAddress $IP -ErrorAction Stop
$Person = New-Object PSOBJECT
$Person | Add-Member "Device Name" $ReservationObj.GetCimSessionComputerName
$Person | Add-Member User $ReservationObj.Description
$MAC = $ReservationObj.ClientId
$MAC = $MAC -replace "-", ":"
$Person | Add-Member "MAC Address" $MAC
$Person | Add-Member "IP Address" $IP
Write-Output $Person | Format-List
} catch {
Write-Host "This IP address is not currently reserved and is available for use."
$Response = Read-Host "Would you like to add a new reservation for this IP address (yes)/(no)?"
if ($Response -eq "yes") {
$Description = Read-Host "Please enter the Manufacturer and Model of the device as well as it's owner (i.e its description)"
$MAC = Read-Host "Enter the computers MAC address (xx-xx-xx-xx-xx-xx)"
$Computer = Read-Host "Enter in the computer name."
Add-DhcpServerv4Reservation -Name $Computer -ScopeId xxx.xxx.40.0 -IPAddress $IP -ClientId $MAC -Description $Description -Type DHCP
Write-Host $Computer "has been added"
} else {
Write-Host "Nothing has been added"
}
}
再次将xxx替换为实际数字,我刚才没有在这篇文章中包含实际数字。
任何人都知道为什么会出现这种错误?
答案 0 :(得分:1)
根据https://technet.microsoft.com/en-us/library/jj590690(v=wps.630).aspx,参数“ComputerName”指定要在其中创建预留的DHCP服务器。如果您在此处传递客户名称,则会导致此错误。几分钟前发生在我身上,因为我把“Computername”和“Description”搞混了。
答案 1 :(得分:0)
我知道这个答案来得有点晚,但是我发现在-ClientID参数中,MAC地址必须为小写字母,并且只能包含字母和数字(不带连字符)。
一个好的MAC地址示例:00155D36C906
命令示例:
Add-DhcpServerv4Reservation -ScopeId 10.10.10.0 -IPAddress 10.10.10.2 -ClientId 00155D36C906 -Description "Test device" -Name "Test"