Browsed by
Month: October 2016

Replace NSLookup with Resolve-DnsName

Replace NSLookup with Resolve-DnsName

So we have all been there where we need to confirm that the DNS record exists, or you have a script which needs the IP address rather than the DNS address. Traditionally we would use NSLookup to validate all of this.
Recently I have needed to complete a solution based in PowerShell that I needed to create a DNS record and then validate that it exists, and that the IP address has been set correctly.
Rather than writing heaps of extra code to handle the result from NSLookup in PowerShell, or to instantiate the DNS .Net object, I spent the time to look into the PowerShell options.
This is where I stumbled upon Resolve-DnsName which is fantastic, it allows you to not only complete a generic lookup of the DNS address, but you can use the -type parameter for example -type A will bring back only the A name records for that DNS address for example:

blogpic1
If we were to then run the same query with AAAA as the type (IPv6 Address) we get the following:

blogpic2
Where the Commandlet comes into its own is that you can save it into an object and then use the result to complete your tasks which require an IP address, for example like this:

blogpic3
Obviously this is just scratching the surface of what you can do with the commandlet, but hopefully a starting point for people to think about using more PowerShell.
Good Luck
Steve

How to install Azure Stack TP2 on a server with less than 12 CPU Cores

How to install Azure Stack TP2 on a server with less than 12 CPU Cores

Currently out of the box (binaries) Azure Stack TP2 won’t install on anything less than 12 Cores on the host server be it physical or Virtual, (Yes you can install Azure Stack in Nested Virtualization to get around the Physical Disk allocation issue, but be aware there is a Blue Screen Bug when running it so not advised.)

If you’re like me and can’t get your hands on shining new kit for a lab/testing environment and need to make do with DL380 G6’s which have 8 cores and a truck load of RAM and the required number of disk which worked fast enough for Azure Stack TP1 it doesn’t work out of the box for Azure Stack TP2, so below is the process we worked out to allow for the installation of Azure Stack TP2 on under speced system.

So you have already found the config.xml file located in c:\CloudDeployment which looks something like below, and you have already done a search on the file and found the MinimumNumberOfCoresPerMachine value and updated it to the number of cores which you have, from here you reran the PowerShell command and it failed. The next step was to search the internet and find this blog.

File Edit Format View Help encoding= (Role (Publiclnfo> < Logs > <Fi1eLog Location <Fi1eLog Location <Fi1eLog Location <Fi1eLog Location "$env : SystemDrive\C10udDep10yment\Logs "*env : / > "$env : \ " / > " $env : \IPInformation . txt" / > <WindowsEventLog / > <WindowsEventLog Pattern="App1ication"/> < / Logs > Guid]</Dep10ymentGuid> </Pub1icInfo> (Privatelnfo> < ! Do not change the Deployment Guid. For re-deploying update (ExecutionContext IdempotentRun="True" < Ski pDriverInj / SkipDriverInj ection> < 3mdWaitTimeoutMinutes> / 8mdWaitTimeoutMinutes> < / 3MCWinPETimeOutInMinutes> IdempotentRun ' property to "False" < /TimeServiceStartTimeoutInMinutes> < Us eWim300t>F a Is / Us eWim800t> < / Ignore01dOSCheckResu1t> < Install Image Path " Index="" VHDName="" <LibraryShareImageF01der <VhdImageTargetDir Path < Sta / Sta rtupTimeoutInMinutes> < Shutdown / Shutdown TimeoutInMinutes> (Accounts) < / LocalAdminAccountID> <RunAsAccountID>Fabric</RunAsAccountID> < DomainAdminAccountID> Doma inAdmin< / Doma inAdminAccountID> / ChassisManagerAccountId> LocalAdmin< / BuiltInAdminAccountID> </Accounts> (ValidationRequirements> <MinimumOperati /MinimumOperatingSystemVersion> (Min PerMa ch in e) /Min imumNumberOfCores PerMa ch in e) /MinimumPhysica1MemoryPerMachineG3> <MinimumNumberOfAdaptersPerMa chin /MinimumNumberOfAdaptersPerMa chin e) /MinimumAdapterSpeed3itsPerSecond>

So now to find the real config file which is used to install the bare metal(host machine) for Azure Stack, this is located here: C:\CloudDeployment\Configuration\Roles\Infrastructure\BareMetal\OneNodeRole.xml easy right, we make the change to the MinimumNumberOfCoresPerMachine again save the file then rerun the PowerShell Command and it fails again… now this is getting annoying.

After some digging we find that during the installation of Azure Stack it creates a group of encrypted files which are located here: C:\EceStore these contain an encrypted version of the Config file from the first time you ran the PowerShell script, So we will delete this folder, and the config.xml file from C:\CloudDeployment and rerun the whole process from the start. Presto the installation process will complete this time around.

Good Luck,

Steve

Replace Telnet with Test-NetConnection PowerShell Module

Replace Telnet with Test-NetConnection PowerShell Module

While troubleshooting some issues for a client this week I needed to test that a port was open. Traditionally our first step for this would to reach for Telnet. But given it is 2016 and telnet has been a feature that has been intentionally removed by default from all Windows OS for the last 4 years as a result of the security concerns, I don’t have it enabled on my laptop.  

So, the question is if not Telnet what do I use for testing a port? Well the easy answer is: PowerShell

The CmdLet in question is “Test-NetConnection” sounds like it would just do a ping, which doesn’t really help me right? Well that’s true, but you can then use the -Port parameter which allows you to define the port which you wish to send the packet down to test that the port is open.

Here is an example of how to use the command. The first usage in the image is a failed reply, while the second usage is a successful response.

blog-image-for-test-netconnection

Good Luck.

Steve