2025-01-02

Get All DHCP Lease Info

$DHCPServer = "DHCPServer.Contoso.com";
$DHCPScopes = Get-DhcpServerv4Scope -ComputerName $DHCPServer;
foreach ($Scope in $DHCPScopes) {
Get-DhcpServerv4Lease -ComputerName $DHCPServer -ScopeID $Scope.ScopeId;
};

or

$Global:Utf8NoBomEncoding = New-Object System.Text.UTF8Encoding $False;
$DHCPData = (Get-DhcpServerv4Scope -ComputerName "DHCPServer.Contoso.com" | Get-DhcpServerv4Lease -ComputerName "DHCPServer.Contoso.com");
[System.IO.File]::WriteAllLines('C:\DHCP.json', ($DHCPData | ConvertTo-Json -Depth 100 -Compress), $Global:Utf8NoBomEncoding);

--##

Change Lease Duration 30 Days, 8 Hours, 9 Minutes, 10 Seconds

Set-DhcpServerv4Scope -ComputerName $DHCPServer -ScopeID $Scope.ScopeId -LeaseDuration "30.08:09:10";

沒有留言:

張貼留言