2014/11/26

Finding VIBs on ESXi hosts with PowerCLI

I did not work with PowerCli for the last couple of months and I had an interesting question from one of my follower Ivo from Netherlands.

He was trying to retrieve the VIB information with the name 'net-e1000e' from all his VMware Hosts using the PowerShell and the Snapin PowerCli from VMware.


What is a VIB ?
VIB stands for vSphere Installation Bundle.  At a conceptual level a VIB is somewhat similar to a tarball or ZIP archive in that it is a collection of files packaged into a single archive to facilitate distribution


Here is the piece of code to retrieve this information.
The output is sent to Out-GridView which create a simple GUI.

Get-VMHost | Where-Object { $_.ConnectionState -eqConnected” } | Foreach-Object {
    $CurrentVMhost = $_
    TRY
    {
        # Exposes the ESX CLI functionality of the current host
        $ESXCLI = Get-EsxCli -VMHost $CurrentVMhost.name
        # Retrieve Vib with name 'net-e1000e'
        $ESXCLI.software.vib.list() | Where-Object { $_.Name -eq "net-e1000e" } |
        FOREACH
        {
            $VIB = $_
            $Prop = [ordered]@{
                'VMhost' = $CurrentVMhost.Name
                'ID' = $VIB.ID
                'Name' = $VIB.Name
                'Vendor' = $VIB.Vendor
                'Version' = $VIB.Version
                'Status' = $VIB.Status
                'ReleaseDate' = $VIB.ReleaseDate
                'InstallDate' = $VIB.InstallDate
                'AcceptanceLevel' = $VIB.AcceptanceLevel
            }#$Prop
            
            # Output Current Object
            New-Object PSobject -Property $Prop
        }#FOREACH
    }#TRY
    CATCH
    {
        Write-Warning -Message "Something wrong happened with $($CurrentVMhost.name)"
        Write-Warning -Message $Error[0].Exception.Message
    }
} | Out-GridView


Script Version


I also wrote a more complete version available on Github


Thanks for reading! If you have any questions, leave a comment or send me an email at fxcat@lazywinadmin.com. I invite you to follow me on Twitter @lazywinadm / Google+ / LinkedIn. You can also follow the LazyWinAdmin Blog on Facebook Page and Google+ Page.

2014/10/05

PowerShell - Who Reports to Whom? (Active Directory recursive DirectReports)

I've been working in the video games industry for a bit more than 3 months now. A lot is going on, and the pace seems faster than regular corporation environment. I also notice a lot of employees movements between teams and projects.

Last week I had an interesting "Quest": To find the list of employees under a specific manager. In Active Directory you can retrieve this information under the property DirectReports.

However if this manager manage other managers... how can I do a recursive search... ?
Sounds like a mission for PowerShell :-)

2014/10/04

PowerShell GUI - LazyTS (Terminal Services Management)


LazyTS is a PowerShell script to manage Sessions and Processes on local or remote machines. It allows you to Query/Disconnect/Stop session(s), Query/Stop process(es) and Send Interactive message to one or more sessions.

This tool is using the module PSTerminalService which relies on the Cassia .NET Library.I used Sapien PowerShell Studio 2014 to which make life easier if you want to start building WinForms tools and add PowerShell code.

2014/10/01

PowerShell - Check the GPO Replication accross your domain

A couple of days ago we had to troubleshoot some SYSVOL replication issues throughout the domain. I wanted to check the version of the GPO that was modified recently and make sure it was replicated on all the Domain Controllers.

I created a small function called Get-ADGPOReplication to easily compare the versions of each Group Policy Objects (User and Computer Configurations) on each Domain Controllers in the Domain.

Get-ADGPOReplication sent to Out-Gridview

2014/09/28

PowerShell Tip - Escape Regex MetaCharacters


Last week I worked on a Scorch PowerShell script that is looking for duplicate Incident Requests inside SCSM by checking new incoming request and existing ticket already in the system.

One of the script step is to look for a match between two strings, something similar to the following:

$String1 = "Title:[PowerShell Rocks!]"
$String2 = "Title:[PowerShell Rocks!]"

$String1 -match $String2

Straight forward you would think! And at first I was surprised to see the result $FALSE ... yep...to "ass-u-me"...

2014/09/21

PowerShell - NetBackupPS: Module for Symantec NetBackup


In my previous job, we used Symantec NetBackup to handle backups and restores. To handle some of the reporting, the storage admins were using the Symantec CLI tools (bunch of Exe).
Example of usages: Find the scratch tapes in a particular robot... or in a particular site...

I wanted to parse the output and be able to reuse the information for other commands or to report information to the team. I realised that could be a good exercice to improve my parsing skills using PowerShell and decided to work on some more cmdlets and eventually a module.

2014/09/09

PowerShell/SCSM - Finding the GUID of an object

Retrieving the GUID of an object in SCSM using PowerShell is sometime a bit challenging. For the WorkItems, this piece of information is not present in any Property available, you have to invoke the get_id method to retrieve it.

There is an 'ID' property which is misleading, it contains the number of the request, for example IR123456.

And for some other type of objects, such as the DomainUser or Enumeration objects the GUID is the..... ID property.

2014/09/08

PowerShell/SCSM - Install and Config the SMlets Module

If you follow my blog, you might have noticed that I recently started to post about SCSM. We just finished to migrate to a new SCSM environment in Azure (Iaas) while using Cireson Portal as a front end.

Of course of lot of the automation part is handled by SCORCH in the background which rely on a lot of PowerShell :-)  (We don't use SMA yet, but I will soon look into it)

Anyway I just wanted to post a quick article on how to configure SMlets on a workstation to be able to query SCSM.