12 January 2016

XtremIO PowerShell Module Updated -- v0.9.5 available

XtremIO + PowerShell!Even more updates and improvements!  Version 0.9.5 of the XtremIO.Utils PowerShell module is now available at https://github.com/mtboren/XtremIO.Utils/releases (starting with the 0.8.x line, this module has been on GitHub). There are a vast number of update, improvements, bugfixes, and even some new features in this release.  From supporting several improvements that came in v2 of the XtremIO REST API (which help with cmdlet speed) to further standardization in the object model (property-availability across types) to now having the somewhat overdue New-XIOSnapshot cmdlet (supporting new snapshots in the XIOS v2 API). See the changelog for the exciting details.

Oh, and, while the cmdlets all have built-in help with examples (like every cmdlet should), there is now a GitHub Pages page with a whole slew of examples with output. See https://mtboren.github.io/XtremIO.Utils/ for a load of such examples.  The readme has a link to that page, but sometimes people don't read the readme.  Yes, really.

While you've probably already gone to the changelog to see all of the gorey details, one other tidbit about this version:  the amount of change in this release probably warranted incrementing the "minor" version number of the module, but "0.10.0" seems odd, and it's not time for v1.0 yet.  So, v0.9.5 it is. Enjoy!

13 December 2015

New PowerShell Module for Sortable HTML Reporting -- NewHtmlReport

A couple of years ago, after wanting to make some HTML reports to present tabular data that included a bit of style and interactivity, we created a PowerShell module for such things.  While there are some posts/scripts on the web that address this need in various ways, we wanted an easy to use, straight forward, flexible way.

Now we've added a GitHub repository to house this NewHtmlReport Powershell module project.  The module uses many of the features of ConvertTo-Html, but goes further by adding things like:
  • jQuery and TableSorter support for HTML tables
  • centralized style and script configuration, for uniform results across reports
  • "hightlighting" of rows' values (to bring focus to rows whose values might be of concern, like a datastore usage value that is over a desired threshold)
  • number formatting so as to make report generation even quicker and easier (you can pass your raw data in, and the cmdlets can handle rounding for you)
The are some examples of the output up at the GitHub Pages page for this repository at http://mtboren.github.io/NewHtmlReport/.

Also, check out the ReadMe and the help at the GitHub repo.  And, for the next feature/fix that you desire:  fork it!

15 November 2015

XtremIO PowerShell Module Updated and on GitHub -- v0.9.0 available

XtremIO + PowerShell!Updates and improvements!  Version 0.9.0 of the XtremIO.Utils PowerShell module is now available at https://github.com/mtboren/XtremIO.Utils/releases (starting with the 0.8.x line, this module has been on GitHub). The main focus of version 0.9.0:  providing support for the new object types that came with the XIOS v4 release and its extended API.  See the changelog for the exciting details.

And, if you missed it, the previous v0.8.x releases focused on implementing some PowerShell-y features/functionality, with some great strides in pipelining capabilities of several of the cmdlets.

Note about the changelog and whatnot:  we will be using GitHub as the official home for the module's code, and, so, the changelog available there will be the authoritative source, instead of the copies that we previously hosted at vNugglets.com.  The module's general info page here at vNugglets now holds links to this new home.

22 January 2015

DRSRule - New PowerShell Module for DRS Rule and Group Management

DRS Things
There's a new PowerShell module out, and it is for handling your DRS rule- and group needs!  "Hello, DRS rule/group export and import?  It's me, the new DRSRule module!"  The "why" and the "hows" about the module are further below in this post.

<vNugglets_note> I got to work with the PowerCLI master, Luc Dekens, on this module -- what a treat! (Check out his post about the new module at http://lucd.info/drsrule-drs-rules-and-groups-module)  It was a great learning experience for me, not only on the PowerShell/PowerCLI tip, but also on topics like collaborative/concurrent development, GitHub features (organizations, releases, etc.), and more.

The cmdlets from the module are solid as one would expect:  pipeline support, value by object or name, WhatIf support, and so on.  As for using some of the cool features of PowerShell, the module includes things like advanced/custom type support (including enabling tab-completion of properties later in the pipeline; handy), XML-based external help as manufactured by https://pscmdlethelpeditor.codeplex.com/, and leveraging other object storage formats so as to simplify handling/export/import of rich objects (via JSON) -- just a few of the great features/bonuses by Mr. Dekens. </vNugglets_note>

Now, more about the module.

Why the DRSRule module?

The core PowerCLI PSSnapin from VMware allows for many of the DRS rule operations that one might want to perform.  There have been questions over the years in the VMware Communities PowerCLI forum about how to export DRS rules and groups, and, on how to then import such items.

While there are several posts on the web about how to get/export such things, importing/recreating DRS rules/groups from such exported data has not received much focus.  This was the spark for this DRSRule module:  to allow for easy export/import of such rules/groups.  As part of making a module to handle these actions, other cmdlets were born, like the Get-/New-/Remove-/Set-* cmdlet sets for DRS VM groups and VMHost groups, along with sets for DRS VM to VM rules and VM to VMHost rules.

How to use the DRSRule module?

The DRSRule module comes with an about_DRSRule.
Once the module is installed, use that help topic to get a general introduction to the use of the DRSRule module:
Get-Help about_DRSRule

How to get the DRSRule module?

The source for this PowerShell module is hosted on GitHub.com.
The repository is managed by the GitHub organization "PowerCLIGoodies", and the repo itself is at https://github.com/PowerCLIGoodies/DRSRule.

There are a few ways to get the module, and use it in your PowerShell session:


    Via a script
    Use a PowerShell script to perform the download and the extract.
    The script is included in the repository as file DownloadLatest.ps1.

    Via PsGet
    If you have the PsGet module loaded in your PowerShell session, then installing this DRSRule module is as simple as updating PsGet and then installing DRSRule:
    Update-Module -Verbose -Module PsGet
    Install-Module DRSRule


    Grab the .zip file of the latest release from the GitHub repository.
    Extract the content to a suitable folder.

    You can go for the Modules folder linked to the Windows account you are using.  To find this path, run:
    Join-Path ${env:\userprofile} "Documents\WindowsPowerShell\Modules"

    Or, you can select any other folder you desire.

    Either way you will end up with a folder named [PathToModule]\DRSRule, in which the PowerShell files for the DRSRule module reside.

    Then, load the DRSRule module into your session:
    If you selected one of the folders in $env:PSModulePath (your PSModule path), you can do this with
    Import-Module DRSRule

    If you picked another folder, you should use the full path to the folder that contains the module's files, like:
    Import-Module [PathToModule]\DRSRule

    Please also read the note below about using Unblock-File, since this module is not Authenticode signed

Note on Unblock-File

This section pertains to using the Manual method above to get the DRSRule module (downloading .zip file).  Since there is no Authenticode certificate supplied for this module, and, assuming that one's PowerShell ExecutionPolicy is at least RemoteSigned, below is a quick/easy way to unblock files.  But, this should only be done when you trust the code in the files that you are unblocking -- inspecting the files is for your own good.
Get-ChildItem [PathToModule]\DRSRule | Unblock-File

06 December 2014

Get VMs' Current EVC Mode via PowerCLI

EVC Mode
Need to report on what is the current EVC mode in which some VMs are running?  We recently did, and out popped a bit of PowerShell/PowerCLI code to do it, of course. As part of some migrations and retirements, we were moving VMs from clusters at one EVC mode (lower) to clusters with higher- or no EVC mode, but were not scheduling power-cycles for the VMs at migration time, so as to keep smaller the scope of work for that event.  Rather than have to keep track of "here are the X number of VMs that are at EVC mode [low]", which would need power-cycled at some later date to bring them up to the EVC mode of their new cluster, PowerCLI is there for us.
It is pretty straightforward, but is handy for identifying those VMs that are, say, at a different EVC mode than is configured on the cluster.  So, the code:
function Get-VMEVCMode {
    <#  .Description
        Code to get VMs' EVC mode and that of the cluster in which the VMs reside.  May 2014, vNugglets.com
        Get-VMEVCMode -Cluster myCluster | ?{$_.VMEVCMode -ne $_.ClusterEVCMode}
        Get all VMs in given clusters and return, for each, an object with the VM's- and its cluster's EVC mode, if any
        ## Cluster name pattern (regex) to use for getting the clusters whose VMs to get
        [string]$Cluster_str = ".+"

    process {
        ## get the matching cluster View objects
        Get-View -ViewType ClusterComputeResource -Property Name,Summary -Filter @{"Name" = $Cluster_str} | Foreach-Object {
            $viewThisCluster = $_
            ## get the VMs Views in this cluster
            Get-View -ViewType VirtualMachine -Property Name,Runtime.PowerState,Summary.Runtime.MinRequiredEVCModeKey -SearchRoot $viewThisCluster.MoRef | Foreach-Object {
                ## create new PSObject with some nice info
                New-Object -Type PSObject -Property ([ordered]@{
                    Name = $_.Name
                    PowerState = $_.Runtime.PowerState
                    VMEVCMode = $_.Summary.Runtime.MinRequiredEVCModeKey
                    ClusterEVCMode = $viewThisCluster.Summary.CurrentEVCModeKey
                    ClusterName = $viewThisCluster.Name
            } ## end foreach-object
        } ## end foreach-object
    } ## end process
} ## end function

And, some examples: Get EVC mode info for all of the VMs in this cluster:
PS vN:\> Get-VMEVCMode -Cluster myCluster
Name                   PowerState   VMEVCMode        ClusterEVCMode   ClusterName
----                   ----------   ---------        --------------   -----------
somesvr01.dom.com       poweredOn   intel-westmere   intel-westmere   OurCluster
somesvrlm1.dom.com      poweredOn   intel-penryn     intel-westmere   OurCluster
somesvrbs03.dom.com    poweredOff                    intel-westmere   OurCluster
somesvrxp.dom.com       poweredOn   intel-penryn     intel-westmere   OurCluster

For all of the VMs in this cluster where their EVC mode does not match the config'd cluster EVC mode, return their info:
PS vN:\> Get-VMEVCMode -Cluster myCluster | ?{($_.VMEVCMode -ne $_.ClusterEVCMode) -and ($_.PowerState -eq "poweredOn")}
Name                   PowerState   VMEVCMode      ClusterEVCMode   ClusterName
----                   ----------   ---------      --------------   -----------
somesvrlm1.dom.com      poweredOn   intel-penryn   intel-westmere   OurCluster
somesvrp83.dom.com      poweredOn   intel-penryn   intel-westmere   OurCluster
somesvra.dom.com        poweredOn   intel-merom    intel-westmere   OurCluster

Note:  The function does expect that you are using at least PowerShell v3, which surely everyone is well beyond by now, anyway.  But, if not, the "[ordered]" cast should be the only thing one would need to take out in order to use in older PowerShell versions.

Straightforward, and uses everyone's favorite PowerCLI cmdlet, Get-View, so you know that it is FaF!  Enjoy.

30 November 2014

XtremIO PowerShell Module Updated -- v0.7.0 available

XtremIO + PowerShell!Even more updates!  Version 0.7.0 of the XtremIO.Utils PowerShell module is now available.  This release brings some great new features, like superior handling of credentials (via new Connect-XIOServer and Disconnect-XIOServer cmdlets), the rest of the New-XIO* cmdlets for creating items in the XtremIO configuration, and new performance-related cmdlets for focusing in on XtremIO performance reporting from several different aspects.

As is now standard, the release notes and change log are where you can read about the new features available in each updated release. We have also made a new general information page for this PowerShell module (like how to get it, how to install it, credentials handling). One can find this info page in the Sticky Posts section at the right, too. Or, if you just want at the module immediately, you can download it from https://github.com/mtboren/XtremIO.Utils/releases/download/Latest/XtremIO.Utils.zip.
Once you have read those items, let us get to some examples!

Connect to a couple of XMS servers:
PS vN:\> Connect-XIOServer -Credential $credMe -ComputerName somexms01.dom.com,somexms02.dom.com -TrustAllCert

ComputerName             ConnectDatetime               Port
------------             ---------------               ----
somexms01.dom.com        11/30/2014 1:54:02 PM         443
somexms02.dom.com        11/30/2014 1:54:02 PM         443

Note: this allows for the rest of the subsequent XIO cmdlet calls to be used without presenting credentials again to the cmdlet -- the cmdlets will use the given XIO connection(s) and corresponding connection credentials! Yes, that also means that you need not supply the XMS name each subsequent call: the default, connected XMS servers will be used, unless otherwise specified by the user.

Get the cluster performance information for all XIO clusters managed by the XMS servers:
PS vN:\> Get-XIOClusterPerformance

Name        WriteBW_MBps   WriteIOPS    ReadBW_MBps   ReadIOPS   BW_MBps      IOPS     TotWriteIOs  TotReadIOs
----        ------------   ---------    -----------   --------   -------      ----     -----------  ----------
somexms01   6.057          771          41.768        531        47.824       1302     4664182545   3886061537
somexms02   67.480         2783         238.808       5286       306.288      8069     31163303937  81948491968

Create a new initiator in initiator group "myserver0" on array managed by "somexms02":
PS vN:\> New-XIOInitiator -Name myserver0-hba2 -InitiatorGroup myserver0 -PortAddress 0x100000000000ab56 -ComputerName somexms02.dom.com

Name                   PortAddress                   PortType              IOPS
----                   -----------                   --------              ----
myserver0-hba2         10:00:00:00:00:00:ab:56       fc                    0

Create a new LUN maps on array managed by "somexms02":
PS vN:\> New-XIOLunMap -Volume myVolume02 -InitiatorGroup myserver0,myserver1 -HostLunId 50 -ComputerName somexms02.dom.com

VolumeName          LunId           InitiatorGroup           tg-name
----------          -----           --------------           -------
myVolume02          50              myserver0                Default
myVolume02          50              myserver1                Default

A couple of Get-XIOEvent examples:
PS vN:\> Get-XIOEvent

EventID  DateTime               Severity     EntityDetails      Description
-------  --------               --------     -------------      -----------
2267     11/30/2014 10:39:29 PM information  myVolume02 [1]     Mapped LUN 50 to Volume myVolume02 TG Defa...
2266     11/30/2014 10:39:29 PM information                     User: vNuggsUser, Command: maplun, Argumen...
27672    11/30/2014 1:37:41 PM  information  someVolume03       Small block (blocks smaller than 4KB) IO r...
27671    11/30/2014 1:17:05 PM  information                     External user 'vNuggsUser' authenticated w...

PS vN:\> Get-XIOEvent -Category activity -Severity information -EntityType BatteryBackupUnit -Start "11 oct 2014" -End "14 nov 2014 8am"

EventID  DateTime               Severity     EntityDetails   Description
-------  --------               --------     -------------   -----------
195      11/11/2014 9:29:30 PM  information  X2-BBU [2]      Added new Battery Backup Unit - UPS[2] "X2-BB...
193      11/11/2014 9:29:30 PM  information  X1-BBU [1]      Added new Battery Backup Unit - UPS[1] "X1-BB...

While it was quite a bit of doing to make this release happen, the new features are well worth it, and it was quite fun along the way. Now to keep the creativity flowing: on to the next update, in which better pipeline support is one of the targets. Until then, enjoy!

XtremIO.Utils PowerShell Module General Info

XtremIO + PowerShell!Herein lies much of the supporting/side information about this PowerShell module that has been written throughout the related vNugglets posts.  The intention, however, is to create this more central spot for this info, instead of people having to sift through the previous posts to get all of these tidbits. To read about the latest additions and changes, one can refer to the change log and the ReadMe (which are available in the module itself, too).
* Update 15 Nov 2015:
Updated links to changelog and readme to be to GitHub, as well as the link to the PowerShell module itself
* end of 15 Nov 2015 update

Module availability:

One can get the XtremIO.Utils module in a couple of ways:
  • via the supercool module PsGet, so installing/updating the module becomes a snap for PsGet module users.  The quick how-to on using PsGet to install the XtremIO.Utils module:
    PS vN:\> Install-Module -Verbose -Module XtremIO.Utils
    Or, to update the existing version you may already have:
    PS vN:\> Update-Module -Verbose -Module XtremIO.Utils
  • Or, if you like the "old fashioned" module management route (of manually handling the module grab), you can always follow the steps:
    1. download from latest and greatest! https://github.com/mtboren/XtremIO.Utils/releases/download/Latest/XtremIO.Utils.zip
    2. unzip somewhere you like (like, say, in Join-Path ${env:\userprofile} "Documents\WindowsPowerShell\Modules")
    3. you should now have a folder named <pathToModules>\XtremIO.Utils, in which the PowerShell files reside (see note below about using Unblock-File, since this module is not yet Authenticode signed)
    4. Import-Module <pathToModules>\XtremIO.Utils

Unblock-File discussion:

One of the other "features" of this module:  we have not yet set the Authenticode signature for it.  That is, it is unsigned.  We went back and forth on the solution:
  • buy a legit cert for code signing (best solution, but $$$)
  • sign it with a self-signed cert (which still leads to a prompt of 'Do you want to run software from this untrusted publisher?' when you try to import the module, since everyone is security-minded and has at least the RemoteSigned execution policy set on their machines)
  • ✔ do not add a signature, and make mention that you will need to Unblock-File the files in the module (after careful inspection of the files to make sure that there is nothing dangerous in there; but, we're talking about vNugglets, here -- you can trust us, right?!  a:  No.  Trust no one)
So, since we went with the last option there, below is the quick/easy way to unblock files.  But, again, this should only be done when you trust the code in the files that you are unblocking -- inspecting the files is for your own good.  Anyway, the unblock command:
PS vN:\> Get-ChildItem <pathToModules>\XtremIOInfo | Unblock-File

Credentials discussion:

Credentials come into play in a couple of ways in this module.  One can use the New-XIOStoredCred cmdlet to store one credential persistently on disk.  And, the use of the Connect-XIOServer cmdlet holds credentials in a variable, only for the duration of the PowerShell session (and, only while connected to any XIO servers).

Stored credentials are encrypted using the Windows Data Protection API, via a derivative of HalR9000's Export-PSCredential.  If the encrypted credential file is found at runtime of any of the module's functions that require credentials, the credentials will be imported from said file transparently.

Decryption of the encrypted credentials can only be performed by the user account that performed the encryption, and on the same computer on which the encryption was performed.  This module stores the credential file in the ${env:temp} directory by default, and this location is configurable as desired.

If no credentials are specified to the functions of this module, the given function will look for the credential file in the configured location.  If none exists, the functions behave as before:  they will prompt for credentials as necessary.  And, you can get the stored credential with Get-XIOStoredCred, and remove it from disk, if you would like, with Remove-XIOStoredCred.