# Henter alle aktive leases direkte fra Windows DHCP databasen via CIM
Get-CimInstance -Namespace root\Microsoft\Windows\DHCP -ClassName PS_DhcpServerv4Lease -ComputerName localhost |
Where-Object { $_.AddressState -ne 3 } | # 3 = Inactive/Declined
Select-Object HostName, IPAddress, ClientId, ScopeId |
Export-Csv -Path "C:\temp\dhcp_leases.csv" -NoTypeInformation -Encoding UTF8
Write-Host "Eksport fullført!" -ForegroundColor Green