[英]Difference between “RenewDHCPLease()” and “IPConfig /renew”?
I am using RenewDHCPLease()
to renew the IP address of the system. 我正在使用
RenewDHCPLease()
来更新系统的IP地址。
RenewDHCPLease()
and ipconfig /renew
? RenewDHCPLease()
和ipconfig /renew
之间的确切区别是什么? ReleaseDHCPLease()
before RenewDHCPLease()
? RenewDHCPLease()
之前使用ReleaseDHCPLease()
RenewDHCPLease()
? If so why? Below is my code: 以下是我的代码:
try {
$ips = Get-WmiObject -Class Win32_NetworkAdapterConfiguration | Where { $_.IpEnabled -eq $true -and $_.DhcpEnabled -eq $true} -ErrorAction Stop
if (!$ips) {
Write-Output "`nDHCP is not Enabled on this system"
Exit
}
foreach ($ip in $ips) {
Write-Output "`nRenewing IP Addresses"
$ip.RenewDHCPLease() | Out-Null
if ($?) {
Write-Output "IP address has been renewed for this system"
}
else {
Write-Error "IP Address Could not be renewed"
}
}
}
catch {
$_.Exception.Message
}
ReleaseDHCPLease
releases the IP address bound to a specific DHCP enabled network adapter RenewDHCPLease
Renews the IP address on a specific DHCP enabled network adapter ReleaseDHCPLease
释放绑定到特定DHCP启用的网络适配器 的IP地址 RenewDHCPLease
更新 特定DHCP启用的网络适配器上 的IP地址
There is no need to use ReleaseDHCPLease
before RenewDHCPLease
since the old address is released and a new one is automatically acquired when using RenewDHCPLease
RenewDHCPLease
之前无需使用ReleaseDHCPLease
,因为旧地址已发布,并且在使用RenewDHCPLease
时会自动获取新地址
Get-WmiObject Win32_NetworkAdapterConfiguration -Filter 'IpEnabled=True AND DhcpEnabled=True' | Foreach-Object{
$_.RenewDHCPLease()
}
You could also use the RenewDHCPLeaseAll
method to renew them all at once. 您还可以使用
RenewDHCPLeaseAll
方法立即更新它们。 Hope this helps :) 希望这可以帮助 :)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.