{"id":429,"date":"2018-02-27T15:36:49","date_gmt":"2018-02-27T20:36:49","guid":{"rendered":"http:\/\/nukeitmike.com\/blog\/?p=429"},"modified":"2018-02-27T15:36:49","modified_gmt":"2018-02-27T20:36:49","slug":"pull-dhcp-info-using-powershell","status":"publish","type":"post","link":"https:\/\/blog.nukeitmike.com\/index.php\/2018\/02\/27\/pull-dhcp-info-using-powershell\/","title":{"rendered":"Pull DHCP info using PowerShell"},"content":{"rendered":"<p>This short script will get all the DHCP servers authorized in your Windows domain, and pull all the scopes and IPs. It exports these to two separate CSV files.<\/p>\n<blockquote>\n<p>$DHCPServers = Get-DhcpServerInDC     <br \/> If (Test-Path -Path $env:TEMP\\Scopes.csv) {Remove-Item $env:TEMP\\Scopes.csv}      <br \/>If (Test-Path -Path $env:TEMP\\Leases.csv) {Remove-Item $env:TEMP\\Leases.csv}      <br \/> If (Test-Path -Path $env:TEMP\\Leases.csv) {Remove-Item $env:TEMP\\DNSExport.csv}      <br \/>foreach ($_ In $DHCPServers) {      <br \/>&#160;&#160;&#160; Get-DhcpServerv4Scope -ComputerName $_.DnsName | Select-Object -Property ScopeId,SubnetMask,Name,State,StartRange,EndRange,LeaseDuration,Description,type | Export-Csv $env:TEMP\\Scopes.csv -Append -NoTypeInformation      <br \/>&#160;&#160;&#160; Get-DhcpServerv4Scope -ComputerName $_.DnsName | Get-DhcpServerv4Lease -ComputerName $_.DnsName -AllLeases | Select-Object -Property IPAddress,ScopeId,ClientId,HostName,AddressState,LeaseExpiryTime,ClientType,Description,DnsRegistration,DnsRR,ServerIP&#160;&#160;&#160; | Export-Csv $env:TEMP\\Leases.csv -Append -NoTypeInformation      <br \/>&#160;&#160;&#160; }<\/p>\n<\/blockquote>\n<p>The formatting for the script is a little off.&#160; I need to get a code display plugin, but I am too lazy.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>This short script will get all the DHCP servers authorized in your Windows domain, and pull all the scopes and IPs. It exports these to two separate CSV files. $DHCPServers = Get-DhcpServerInDC If (Test-Path -Path $env:TEMP\\Scopes.csv) {Remove-Item $env:TEMP\\Scopes.csv} If (Test-Path -Path $env:TEMP\\Leases.csv) {Remove-Item $env:TEMP\\Leases.csv} If (Test-Path -Path $env:TEMP\\Leases.csv) {Remove-Item $env:TEMP\\DNSExport.csv} foreach ($_ In $DHCPServers) {&hellip; <a class=\"more-link\" href=\"https:\/\/blog.nukeitmike.com\/index.php\/2018\/02\/27\/pull-dhcp-info-using-powershell\/\">Continue reading <span class=\"screen-reader-text\">Pull DHCP info using PowerShell<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"advanced_seo_description":"","jetpack_seo_html_title":"","jetpack_seo_noindex":false,"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[25],"tags":[73,135,154],"class_list":["post-429","post","type-post","status-publish","format-standard","hentry","category-scripting","tag-dhcp","tag-powershell","tag-scripting","entry"],"jetpack_featured_media_url":"","jetpack-related-posts":[],"jetpack_likes_enabled":true,"jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/pcW544-6V","_links":{"self":[{"href":"https:\/\/blog.nukeitmike.com\/index.php\/wp-json\/wp\/v2\/posts\/429","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.nukeitmike.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.nukeitmike.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.nukeitmike.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.nukeitmike.com\/index.php\/wp-json\/wp\/v2\/comments?post=429"}],"version-history":[{"count":0,"href":"https:\/\/blog.nukeitmike.com\/index.php\/wp-json\/wp\/v2\/posts\/429\/revisions"}],"wp:attachment":[{"href":"https:\/\/blog.nukeitmike.com\/index.php\/wp-json\/wp\/v2\/media?parent=429"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.nukeitmike.com\/index.php\/wp-json\/wp\/v2\/categories?post=429"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.nukeitmike.com\/index.php\/wp-json\/wp\/v2\/tags?post=429"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}