Results for category "PowerShell"

Windows Server 2012 R2 – Hyper-V Cluster – Updates/Driver/Firmware Consistency Report

As the environment gets bigger, you may face challenges on maintaining the consistency with respect the patches , drivers and firmwares of each cluster nodes. I thought of make a Powershell script which will give a report on the updates/drivers/firmware consistence of a cluster. Along with this, I want to have a check on the Hyper-V specific updates. As you may already knowing, The Technet wiki page for Windows Server 2012 R2 Hyper-V Updates is the place where I keep monitoring for Hyper-V specific patches. This page should be the source which my script needs to cross check. Keeping all this in mind, I started last week.

Challenge 1- Reading the data from http://social.technet.microsoft.com/wiki/contents/articles/20885.hyper-v-update-list-for-windows-server-2012-r2.aspx and making out the list of KBs. I don’t know what all I did , what all options I tried – but successful at last. I know, it may not be the optimal way to make this list. Any help improving this code is highly appreciated.

Challenge 2 – An IE Popup comes related with Internet Explorer Enhanced Security Configuration. May be tweaking iE settings can suppress this. But If you know any option to fix this through my code, Please let me know.

 

Download this script from Technet Gallery.

Screenshots from the report below.

Windows Server 2012 R2 – Hyper-V Cluster – Updates/Driver/Firmware Consistency Report

Windows Server 2012 R2 – Hyper-V Cluster – Updates/Driver/Firmware Consistency Report

 

Windows Updates

Windows Updates

 

HBA Driver Firmware

HBA Driver Firmware

 

Network Drivers

Network Drivers

 

Powershell one liners for Hyper-V

Few Powershell based OneLiners which I use frequently !

 

Identify the best node for placement with respect to memory utilization.

(Get-ClusterNode -cluster CLUSTERNAME |Select Name, @{L="VMCount";E={(Get-VM -ComputerName $_.name).count}},
@{L="AvailableMemory(GB)"; E={(Get-VMHOST $_.Name).MemoryCapacity/1GB-(Get-VM -ComputerName $_.name |Measure-Object MemoryAssigned -Sum).sum/1GB}}|Sort "AvailableMemory(GB)" -Descending)

 

 

PowerShell One Liner - MemoryUsage

PowerShell One Liner – MemoryUsage

 

CSV Usage Statistics

 

Get-ClusterSharedVolume -Cluster CLUSTERNAME| select -Expand SharedVolumeInfo |select FriendlyVolumeName, @{n="Capacity(GB)";e={$_.Partition.Size/1GB}}, @{n="FreeSpace(GB)";e={($_.Partition.Size -$_.Partition.UsedSpace)/1GB}} |Sort-Object "FreeSpace(GB)" |sort "FreeSpace(GB)" -Descending

 

 

CSV Stat

List all VMs in a Hyper-V Cluster

 

Get-ClusterNode -Cluster CLUSTERNAME |foreach {Get-VM -ComputerName $_.Name}

 

 

List all VMs in a cluster with Integration Service version

Get-ClusterNode -Cluster CLUSTERNAME |Foreach {Get-VM -ComputerName $_.name |select name, IntegrationServices
Version}

 

 

List all VMs in a cluster which got a SnapShot/CheckPoint

 

Get-ClusterNode -Cluster CLUSTERNAME |Foreach {Get-VM -ComputerName $_.name|Where {$_.ParentSnapshotId -ne $Null}}

 

List all VMs with DVD/CD information

Get-ClusterNode -Cluster CLUSTERNAME |Foreach {Get-VM -ComputerName $_.name |Get-VMDvdDrive}

 

Mounted DVD Information

Mounted DVD Information

 

List all Hyper-V related errors for the last 24 hours

Get-ClusterNode -Cluster CLUSTERNAME |Foreach {Get-WinEvent Microsoft-Windows-hyper-V-* -ComputerName $_.name|where {$_.TimeCreated -gt (Get-Date).AddDays(-1) -AND ($_.LevelDisplayName -eq "Error" -OR $_.LevelDisplayName -eq "Critical")}|Select Machinename, TimeCreated, LevelDisplayName, MEssage |FL}

 

 

More to come !

 

Cheers.

 

Hyper-V Dashboard – V3 Released

As mentioned in my last post, Hyper-V Dashboard V3 is ready and available in Technet Gallery.

With the new version, this become a full Hyper-V Dashboard as this report will provide you details on VMs, Physical Host and the storage.

New Features with V3.

Added Host Report to capture the Processor/Memory utilization of Hyper-V Host

Added Color Coding to identify servers which needs attention

New look

Here is few screen shots from the report.

Hope you enjoyed the script !

Hyper-V VM Dashboard

Hyper-V VM Dashboard

Hyper-V Host Dashboard

Hyper-V Host Dashboard

 

Hyper-V Storage Dashboard

Hyper-V Storage Dashboard

 

Hyper-V Dashboard – V3 … Coming soon !

This month was a busy month for me due to various factors. Though I couldn’t make much posting this month, I was working further on enhancing the Hyper-V Dashboard. The V3 is getting ready and I am doing the finishing works.

The new features with V3 are

  • A new section to list out the Host utilization with respect to Memory and Processor. We already have two sections in the existing script – One for VMs and one for the CSV Storage. One more table will get added which will list out the Host utilization.
  • Added the CSV Volume details along with the VM details. So its easy to understand on which CSV Volume this specific VM is residing.
  • Removed Snapshot details. Instead, only first snapshot date is there. Logically thinking, If snapshot exists, First snapshot date also should exists.
  • Now trying out to make some color coding to identify the overall health of a VM / Host or CSV Volume.

One of the plan which I had previously was to include an option to calculate the white-space in VHDX. This will help us in making a decision if its worth to shrink the disk. I couldnt find  a straight way here and hence took a long route using multiple WMI queries and to get an estimation on what space in the disk is actually used. However, I see that there are many chances where the calculation may go wrong. So I am looking out for a better option.

I really feel that Microsoft should give a commandlet which will give some information on the whitespace in a VHDX disk.

Keep watching this page for the release of HyperV Dashboard V3.

Cheers !

Shaba

 

Hyper-V Dashboard – V2.1

Its almost a week I made the first version of the dashboard. Yesterday, I published v2.1 this dashboard.

Just a brief on the changes on each versions.

Ver 2.1 – 2/12/2014

* Added logic to identify Virtual Disk type – VHD or VHDX. VHD Disk will be marked as yellow cell

* Added logic to identify vNIC – Legacy or Synthetic. The cell of Legacy vNic will be marked yellow.

* Fixed few bugs related with the logic

Ver 2 – 2/12/2014

* Added logic to include an input file

* Added logic to include Hyper-V Stand Alone nodes

* Added component for Free Space percentage on each Local Disk /CSV Volume

* Changes on coding and more detailed logging on the console

Ver 1.1 – 2/9/2014

* Added logic to identify Dynamic Memory and mark Min Meory and Max Memory to “DM Disabled” on a VM without Dynamic Memory

* Added additional components like UpTime, IC, SnapShot Count, First SnapShot Date etc

* For Windows Server 2012 R2 HyperV Clusters, The report will also check if the Integration Component is ” Up To date” or not. If not, the cell color will be changed to Yellow so that Administrators can quickly identify

* Improved the logic to skip a Hyper-V Cluster node without any VM

You can download the script from the Technet Script Gallery.

What is planned next:

In the upcoming version, What I would like to do

  • Along with the VM and Storage details, A new section for the physical host which will have have the physical resources on each host
  • A comparison with actual resources VS allocated resources

May be some more items which I a yet to finalize :).

Cheers!

 

Identify WWN through Powershell

Run this command from Powershell

$nodewwntmp = Get-WmiObject -class MSFC_FCAdapterHBAAttributes -Namespace “root\wmi” |select NodeWWN

And then

$NodeWWN = (($nodewwntmp[1].NodeWWN) | ForEach-Object {“{0:x}” -f $_}) -join “:”

The variable $nodeWWN will have the WWN listed.

 

 

Measure-VM – Its just amazing !

Some times, its nice to see how a particular VM is performing through a commandlet. I am sure, you know this. Get-VM will give you a quick overview on the resource utilization at that moment.

Get-VM -ComputerName HyperVHostServver

Get-VM

How about getting an average performance report. Its possible in Windows Server 2012 HyperV. We can measure the average value of specific performance counters. The first step to achieve this is to enable resource metering.

By default, Resource metering is set as false for all VMs.

Get-VM-RM-Default

Resource Metering can be enabled for a specific VM or for all VMs on a server in one time. Once you enable Resource Metering, key counters are captured and will give use an option to generate an average utilization report.

To enable Resource Metering for a specific VM

Enable-VMResourceMetering -ComputerName HyperVHostName -VMName VMName

To enable for all VMs on a server

Enable-VMResourceMetering -ComputerName HyperVHostName-VMName *

Enable-RM

To check if a VM is configured with Resource Metering, Use Get-VM

Get-VM VMName |Select-Object ResourceMeteringEnabled

Get-VM Resource-Metering-Enabled

To check the total time duration resource metering is running, use Measure-VM with FL

Measure-VM

At last, to disable resource metering

Disable-VMResourceMetering -VMName VM

Hope that helps !

Shaba