Pull DHCP info using PowerShell

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) {
    Get-DhcpServerv4Scope -ComputerName $_.DnsName | Select-Object -Property ScopeId,SubnetMask,Name,State,StartRange,EndRange,LeaseDuration,Description,type | Export-Csv $env:TEMP\Scopes.csv -Append -NoTypeInformation
    Get-DhcpServerv4Scope -ComputerName $_.DnsName | Get-DhcpServerv4Lease -ComputerName $_.DnsName -AllLeases | Select-Object -Property IPAddress,ScopeId,ClientId,HostName,AddressState,LeaseExpiryTime,ClientType,Description,DnsRegistration,DnsRR,ServerIP    | Export-Csv $env:TEMP\Leases.csv -Append -NoTypeInformation

The formatting for the script is a little off.  I need to get a code display plugin, but I am too lazy.

DNS PowerShell one liner

This is a “one liner” that pulls all the DNS Entries for a particular zone, including the IPv4 and IPv6.  If you don’t care about the IPv6, you can remove that segment of the code.

Get-DnsServerResourceRecord –ComputerName <DNSServerName> –ZoneName <YourZoneName> | Select-Object DistinguishedName,HostName,@{Name=’IPv4Address’;Expression={$_.RecordData.IPv4Address.IPAddressToString}},@{Name=’IPv6Address’;Expression={$_.RecordData.IPv6Address.IPAddressToString}},RecordType,Timestamp,TimeToLive | Export-Csv $env:TEMP\DNSExport.csv –NoTypeInformation

It is amazing how much you can do with just one line (even if the line is obnoxiously long.)

Still not there

A while back, I said I was making progress on migrating this blog to Azure.  In case you care, I didn’t.

I was really interested in doing so for a little while, but got busy on other things, and … lost interest.  I am interested again, so maybe this time I will make it.

The capabilities are there, but my skills are not.  Mainly because I never take the time to just get it done.  I really enjoy technology, but I get distracted easily.  Also, like a mechanic’s car, my technology use is always a bit ugly.

A while back, I made a list of topics that I wanted to blog about.  I didn’t make it very far on that stuff.  Maybe 2018 will be a better year for that stuff.

Strange Reboots

This isn’t going to be a terribly helpful post, but I do think it is interesting.  I have a server that is exhibiting some strange behavior.  When I copy a file to the server it reboots. 

At first, I thought this was a specific file, but later determined that it didn’t matter what the file was as long as it was over 4 MB.  I copied a 1 KB file and nothing happened.  I copied a file just under 5 MB and the system locked up, and then rebooted. 

I thought maybe it was a problem with the file, so I copied it local to my computer.  No problem. hmm…

I copied it directly from the source server to the destination server. Crashed the destination.  Weird…

I copied it from my computer to the destination server.  No problem.  I copied a very large (2 GB) file from my computer to the destination computer.  No problem.

I was about to decom that server anyway.  Bombs away…

StorSimple Virtual Array

I really like Microsoft.  As a company, they don’t always do things the way I would like them to, but overall, they make products that meet a need.

We operate in a (mostly) centralized infrastructure.  Our file servers are (mostly) in our main office.  I have a few virtualized StorSimple appliances that I use in a couple of the remote offices. 

Today, I learned that they may occasionally throttle themselves if they are having trouble keeping up with the churn rate.  I probably would have expected this, but I didn’t really put as much thought into that until today. 

I also learned that this can impede a users ability to make changes to or save new files on that share.   This is somewhat frustrating because an error caused it to throttle today, not (apparently) the churn rate.  And my first alert was from the end users.    Bummer…

Even better, the engineer saying “we’ve never seen that one before”.

Back Up!

So after several months of not being accessible, my blog is once again available.  I know that there are thousands of people (or maybe just me) that missed my blog while it was down. 

So I would like to have some grand reason for being down so long, but the simple fact is, we made some network changes here and this blog wasn’t very high on the priority list.  Such is life…

Not quite yet…

So the other day I said that I was moving this blog to Azure.  I have tinkered with that, and am actually making a little progress.  (This happens when you put little effort/time into something).  I decided to bring it back up where it was in order to do an easier transfer of the image content.  We shall see how that works out.  Wish me luck…

Migrating to Azure

So, at the time of this writing, my blog is down.  If you are reading this, then I must have succeeded in migrating it to Azure for hosting.  If I didn’t succeed, maybe I will be the only one who reads this.  I am an “on again/ off again” blogger, so anything is possible.

I have until a few months ago, hosted this blog on a server running on infrastructure at my employer.  I do that, because it is a good price (free) and because I mostly talk to myself in this blog anyway. 

There is a fairly simple “how to” on creating a WordPress site in Azure.  I am following this post to create a temporary site to test with.  If all goes well, I will do a test migration to this and then do it again to a “production” instance.

So far so good:


Open Live Writer

Since it first came out, I have been a fan of what was “Windows Live Writer”.  It was probably one of the simplest, and friendliest tools that came from Microsoft in the Windows Live time frame (in my opinion).   I recall coming across something a while back that reference an update to Live Writer, and today I actually downloaded it.

This post was written with “Open Live Writer”.  Cool right?


Express Route Provisioning Error


We have recently decided to invest in an Express Route circuit for Azure.  It is supposed to be helpful with Azure and Office 365.  There are two ways to provision the ExpressRoute circuit.  Both require PowerShell.

There is the classic: https://azure.microsoft.com/en-us/documentation/articles/expressroute-howto-circuit-classic/

And there is the Resource Manager: https://azure.microsoft.com/en-us/documentation/articles/expressroute-howto-circuit-arm/

Here is the note about those options:

Resource Manager: This is the newest deployment model for Azure resources. Most newer resources already support this deployment model and eventually all resources will.

Classic: This model is supported by most existing Azure resources today. New resources added to Azure will not support this model.

This seems to indicate that using Resource Manager is the right way to go long term.

The problem (for me currently) is the documentation isn’t quite where I think it should be.  If you try to run the commands to setup Express Route and ask for detailed help, you get little if any helpful information. 

One item that kind of bothers me.  When you request the service provider information using the “Get-AzureRmExpressRouteServiceProvider” command, the results are not as informative as they need to be.  I say this because the results look like this:

Name              : Verizon
Id                : /subscriptions//resourceGroups//providers/Microsoft.Network/expressRouteServiceProviders/
ProvisioningState :
Type              : Microsoft.Network/expressRouteServiceProviders
PeeringLocations  : null
BandwidthsOffered : null

Name              : Vodafone
Id                : /subscriptions//resourceGroups//providers/Microsoft.Network/expressRouteServiceProviders/
ProvisioningState :
Type              : Microsoft.Network/expressRouteServiceProviders
PeeringLocations  : null
BandwidthsOffered : null

Name              : Zayo Group
Id                : /subscriptions//resourceGroups//providers/Microsoft.Network/expressRouteServiceProviders/
ProvisioningState :
Type              : Microsoft.Network/expressRouteServiceProviders
PeeringLocations  : null
BandwidthsOffered : null

From that you are supposed to then run a command (per the documentation) that looks like this:

New-AzureRmExpressRouteCircuit -Name "ExpressRouteARMCircuit" -ResourceGroupName "ExpressRouteResourceGroup" -Location "West US" -SkuTier Standard -SkuFamily MeteredData -ServiceProviderName "Equinix" -PeeringLocation "Silicon Valley" -BandwidthInMbps 200

The problem is the previous results don’t give you the PeeringLocation.  All of them come back as “null”.  I looked at the sample output from the “Classic” process and picked the location that seemed to make the most sense.  The command finished so I assume that it worked correctly.