Saturday, January 28, 2017

Nested Hyper-V with Windows 10

I've been away all week, teaching in Trondheim Norway. A nice place, great students and a useful Microsoft training course. In the course, Hyper-V features quite a lot - one cool feature discussed in nested Hyper-V.

Nested Hyper-V is a feature that enables you to create a virtual machine, and then load Hyper-V into that machine. So you can have a VM running VMs. This feature is cool, certainly at a technical level. No doubt someone is going to point out that VMware supports this, but the feature is new in Hyper-V on Server 2016. And interestingly enough, it works in Windows 10 Anniversary Update too!

Why does it matter?  For me, it matters since I am writing a book on PowerShell showing its range and depth. One chapter covers Hyper-V and having Nested Hyper-V means I can create two VMs (HV1, HV2) cluster the VMs, then create clustered virtual machines, The chapter is now easier to write.

The feature matters for customers too.  This enables you to use Hyper-V containers within a VM on a VM. And, it's a fantastic training tool when using on-line labs. The lab vendor, such as Virsoft (a great hosted labs experience!), to provide a student with a VM, in which they can load and use Hyper-V. Previously that was unsupported.

Getting nested Hyper-V to work is great news. For some time, I believed that this would not work on my systems. I have three big Dell Precision 7500 systems. When I tried this during the beta of Windows Server 2016, Coreinfo.exe suggested that my system did not support SLAT. And that meant I could not use nested Hyper-V. But it was wrong!

Here's a picture of a VM hosting a nested VM:
As you can see, a VM running a nested VM. The nested VM, which I called 'embedded' is in the midst on installation.

It turns out that the fix was pretty simple. In the host VM, I just had to issue a simple PowerShell command:

Set-VMProcessor -VMname DC1-ExposeVirtualizationExtensions $True
I had to shut down the  VM first, then reboot. Once rebooted, I was able to bring up the Hyper-V console and create the embedded VM.




Saturday, January 21, 2017

Grammarly

Last year, I wrote about a few great writing aids. One of the tools was Grammarly.

Grammarly is a browser plug in for the Chrome browser which provides spelling and grammar advice. A spell and grammar checker on steroids. On my main writing workstation, I have Grammarly loaded and running all the time. It almost feels like a part of the underlying browser, but with nice bells and whistles.

I am currently working on a book for Packt, and we have a sweet content development portal. We just go to the web site and use the text editing features to enter the text and graphics. We can then output to PDF - it works well. Inside this CDP, Grammarly is wonderful!

When I am entering content in the CDP, you can see Grammarly when it has something it's not happy with, like this:



If you hover over the red squiggly, Grammarly displays a little pop up box that gives you options - in this case some spelling alternatives. From that little popup, you can click on 'Correct with Grammarly', and a larger box appears with more advice. From this second pop up, you can scroll through your entire document to see where Grammarly feels you should make a change. It's awesome.

In practice, I write and insert code/pics, then repeat and repeat. I touch type, but not with perfect accuracy. For me, at least, it's faster to leave a typo in the sentence and continue typing than to fix the error then carry on. I can then just use the mouse to fix the errors - and that works well for me!

The free version is excellent. But for a fee, there's a Professional version that adds a significant number of additional grammar checking rules, including passive voice as well as a plagiarism checker. The Pro version is billed either monthly ($US 37.95), quarterly ($US 24.98), and annually ($US 11.66). At the moment, there is a 20% reduction - but I do now know how long that will last - with the discounts the prices are $29.95, $19.98, and 11.66 per month).

On the downside, several of us have noticed that with Grammarly turned on, our content deployment system can crash. This is a pain, but regular saves, autosave turned on, and bit of experience - recovery is usually pretty easy. I can live with the occasional hang in exchange for such a great product.


Friday, January 20, 2017

WMF 5.1 released for download

When Microsoft ships a new version of PowerShell, it issues what they call the Windows Mangement Framework (WMF). The WMF package includes a new version of PowerShell, updated core cmdlets, and includes updated versions of other related components (e.g. an updated WMI).

In a blog post on the MS Site, Microsoft announced that release of the WMF 5.1 package. The blog post makes it clear that WMF 5.1 upgrades Window 8, Windows 8.1, Windows Server 2008 R2, Windows Server 2012, and Windows Server 2012 R2 to the PowerShell, WMI, WinRM, and SIL components that were released with Windows Server 2016 and Windows 10 Anniversary Edition.

If you are using Windows 7 or Windows Server 2008 R2, you should be a little careful installing this package. The installation instructions were changed - so read the release notes carefully. 

It should be clear from the blog post, but if not: if you are using Windows 10 AU or Windows Server 2016, there is nothing for you to do. Those two operating systems ship with WMF 5.1 installed.

Wednesday, January 18, 2017

Using Get-CimAssociatedInstance

Tonight I finally found a use for the Get-CimAssociatedInstance cmdlet. I know what that cmdlet does, but never had a real use case, until tonight. 

What I was trying to do was to use the CIM cmdlets to find the logged-on user. 

Initially, I searched through the many Win32_Classes and found one that looked promising (Win32_LogonSession). So I tried looking at the interactive logons:
Get-CimInstance Win32_LogonSession |         Where-Object LogonType -EQ 10
But that returned me a somewhat unhelpful response:


I wanted the username (and the SID). So I searched around a bit and found a class name that looked appealing: win32_loggedonuse. Turns out this is one an associator class. In WMI, the associator associates two other instances in the WMI database. In this case. the associator class associates a Win32_LogonSession with the WIn32_Account that is logged on in that session.

So I turned it into a tool :.
Function Get-WhoIAm {
# Get Account for the loggede on user$Me = Get-CimINstance Win32_LogonSession |         Where-Object LogonType -EQ 10 |           Get-CimAssociatedInstance -Association win32_loggedonuser
# Extract useful properties$IAmHT = [ordered] @{}$IAmHT.Account            = $Me.Caption$IAmHT.Description        = $Me.Description$IAmHT.LocalAccount       = $Me.LocalAccount$IAmHT.PasswordChangeable = $me.PasswordChangeable$IAmHT.SID                = $Me.SID$IamHT.CommputerName      = (Get-CimInstance -Classname Win32_Computersystem).Name
# Create a new object$IAm = New-Object -TypeName PSCustomObject -Property $IAmHT
# And return the Iam objectreturn $IAm
}
And for fun, I set an alias of WhoAmi - a tool I've used for a decade or longer. With that done, the output looks like this:


Happy days with WMI and the CIM Cmdlets.