Monthly Archive


A deal of the day you’ll not want to miss

PowerShell in Action, Third Edition is part of Manning’s Deal of the Day on Friday 27 November – see for details on the day -


Half off my book Windows PowerShell in Action, Third Edition. Use code dotd112715au at

PowerShell in Action, 3e MEAP 2

Another chapter of PowerShell in Action third edition has been released into the MEAP process. – see

Creating DNS records

Following on from my previous post about creating a reverse lookup zone in DNS here’s a function to create records in that zone.


The function takes an IP address and name (of host) and uses Add-DnsServerResourceRecordA  to add the record to the forward lookup zone – I use my default AD zone.


The function then splits the IP address. Uses the last octet for the name in the reverse record. Creates the reverse lookup zone from the first 3 octets – notice how the range parameter is used in a decreasing way to specify the order of the octets – to create the reverse lookup zone. The host name and zone are used to create the FQDN of the host.


Add-DnsServerResourceRecordPtr  is used to create the reverse (PTR) record.


function new-dnsrecord {
  param (
    [string]$zone = ''

  Add-DnsServerResourceRecordA -Name $name -ZoneName $zone -AllowUpdateAny -IPv4Address $ipaddress

  $octs = $ipaddress -split '\.'

  $revname = "$($octs[3])"
  $revzone = "$($octs[2..0] -join '.')"
  $fqdn = "$name.$zone"
  Add-DnsServerResourceRecordPtr -Name $revname -ZoneName $revzone -AllowUpdateAny -PtrDomainName $fqdn


Create a reverse lookup zone

I needed to create a DNS reverse lookup zone for my test environment. With Windows Server 2012 R2 I’ve got cmdlets available for managing DNS servers – the DnsServer module. You need to install the DNS role or the DNS RSAT tools to get access to the module.


To create a new reverse lookup zone

Add-DnsServerPrimaryZone -DynamicUpdate Secure -NetworkId '' -ReplicationScope Domain


Use the netorkId to define the subnet the zone spans. Setting DynamicUpdate to Secure ensures I have an AD integrated zone and I’ve set the replication scope to the domain.


Doesn’t get any easier

Win free entry to the PowerShell Summit

Want to go to the PowerShell Summit? Want to go for free?


You can win free entry to the Summit (need to pay your own travel & hotel) through the competition at

DSC resource kit update–October 2015

The DSC resource kit is the primary place to look for DSC resources beyond those baked into Windows.


An update to the resources in the kit has been announced. Some new resources and lots of bug fixes.



for details

PowerShell and SSH

The PowerShell team have announced the availability of OpenSSH 7.1 for Windows -


This is their first step in bringing SSH support into PowerShell.


The roadmap for next steps is available on their blog at the link above

PowerShell resources–you tube

One place you might not think of looking for PowerShell resources is you tube. has its own channel on you tube - - where we’ve posted the session recordings from:

PowerShell Summit Europe 2015

PowerShell summit Europe 2014

PowerShell Summit NA 2015


selected sessions from

PowerShell Summit NA 2014 and

PowerShell Summit NA 2013

are also available.


In addition we have a number other recordings available.


Manning Deal of The Day – 17 October 2015

A treat for PowerShell users looking for books. 50% off PowerShell in Depth, second edition and PowerShell in Action, third edition on 17 October 2015


Half off Windows PowerShell in Action, Third Edition. Use code dotd101715au at


Half off Powershell in Depth, Second Edition. Use code dotd101715au at


I’m co-author of both books and while I may be a touch biased about it I think this is n excellent opportunity to get 2 great PowerShell books

NSlookup in PowerShell

nslookup.exe is a command line executable that is used to discover the IP address of a remote machine from its FQDN. The results look something like this:

PS> nslookup
DNS request timed out.
    timeout was 2 seconds.
Server:  UnKnown

Non-authoritative answer:
DNS request timed out.
    timeout was 2 seconds.


The output is text – not the most useful of things to use.


One option if you want to perform lookups in PowerShell is to write your self a script

$ns = (nslookup.exe )[-4..-3]
$lookup = [PSCustomObject]@{
  Name = ($ns[0] -split ':')[1].Trim()
  Address = ($ns[1] -split ':')[1].Trim()


Run nslookup and take the 3rd and 4th lines from the end of the output. Then create an output object where the text in the array is split at the : the second element is used and trimmed of blank spaces.


If you like using .NET static methods you can do this:

PS> [System.Net.DNS]::GetHostEntry('')

HostName       Aliases AddressList
--------       ------- ----------- {}      {,}


Best of all is the use the Resolve-DnsName cmdlet from the DnsClient module that’s present in Windows 8 and later

PS> Resolve-DnsName -Name '' | ft -a

Name           Type TTL Section IPAddress
----           ---- --- ------- --------- A    300 Answer