Home > DHCP, Powershell Scripts, Windows Server > Export DHCP leases to html using powershell – update

Export DHCP leases to html using powershell – update

There was a minor quirk in the original script, as lease dates where being mixed with hostnames in the final output html. As it turns out it was all a matter of what date it was, when I created the script 🙂

Line 21 in the original:

$l = $l -replace '[-]{1}\d{2}[/]\d{2}[/]\d{4}',''

matches dates in the following format: -xx/yy/zzzz but not -x/yy/zzzz or for that matter -xx/y/zzzz.

The correct –replace should have been:

$l = $l -replace '[-]{1}\d{1,2}[/]\d{1,2}[/]\d{4}',''

Thanks you for the comments, which was the final spark to get me to fix it in my production environment 🙂

  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: