Author Archives: Chris

vSphere Reports in Microsoft Teams

By joining PowerCLI to interrogate a VMware vSphere environment and the Webhook API to post Microsoft Teams messages, we can send informational reports on the state of a virtual environment to channels in Teams.

In this example I have a weekly report on the number of hosts and VMs in an environment. This is fairly straightforward, but more complicated information surfaced by PowerCLI could easily be included.

vistatsinteams

Setting up the WebHook

The Webhook allows messages to be pulled into the Teams channel of choice. You’ll need to setup an Incoming Webhook on your channel of choice.

To do this

  1. Right-click on the Teams Channel and choose Connectors
  2. Find Webhook in the list and click on the adjacent Confugure button.
  3. Enter a name, and choose an icon for the Webhook as prompted. Click on Create and a URL will be generated- this is needed for the script below.

Storing vCenter credentials

As this will be run as a scheduled task we need to store credentials so that the script doesn’t try to prompt for a password. There’s a number of ways of doing this- here I’ve used the Get-Credential cmdlet to prompt for the username and password and then the Export-CliXml cmdlet to save those credentials to a file.

 $Credential = Get-Credential

$Credential |

Export-CliXml -Path C:\Users\myuser\readonlyuser.cred

For the vCenter operations in the script below (counting hosts and VMs) then a user account with Read-Only access is sufficient.

The Script

Finally the script. This can be run manually or set as a scheduled task. The URL of the webhook created above needs to be entered as the value of the $TeamsWebhookURI variable at the top, along with the vCenter credentials and the name of the vCenter.

#Set the Webhook URI to send the message to
$TeamsWebhookURI="https://outlook.office.com/webhook/[email protected]/IncomingWebhook/zzzzzzzzz/zzzzz-zzzz"
#Use pre-defined credentials
$credential = import-clixml -Path C:\Users\myuser\readonlyuser.cred
#What is the address of the vCenter?
$vCenter="vcenter.mydomain.com"
#Connect to vCenter
Connect-VIServer -Server $vCenter -Credential $credential
#Count the VMs and hosts
$poweredoff = @(get-vm | Where-object{$_.PowerState -ne "PoweredOn" } | measure-Object -Line).Lines
$poweredon = @(get-vm | Where-object{$_.PowerState -eq "PoweredOn" } | measure-Object -Line).Lines
$hostCount=(Get-VMHost | Measure-Object).Count
#Disconnect from vCenter
Disconnect-viserver -Server $vCenter -Confirm:$false

#Build the JSON for the Body of the message
$JSONBody = [PSCustomObject][Ordered]@{
"@type" = "MessageCard"
"@context" = "http://schema.org/extensions"
"summary" = "Weekly Infrastructure Stats"
"themeColor" = '0078D7'
"sections" = @(
@{
"activityTitle" = "Virtual Infrastructure"
"activitySubtitle" = "Statistics"
"activityImage" = "https://mydomain.com/infoicon.svg"
"facts" = @(
@{
"name" = "Num. of Hosts: "
"value" = $hostcount
},
@{
"name" = "Powered On VMs: "
"value" = $poweredon
},
@{
"name" = "Powered Off VMs: "
"value" = $poweredoff
},
@{
"name" = "Total VMs: "
"value" = ($poweredon+$poweredoff)
}
)
"markdown" = $true
}

)
}
$TeamMessageBody = ConvertTo-Json $JSONBody -Depth 100

#Build the API call
$parameters = @{
"URI" = $TeamsWebhookURI
"Method" = 'POST'
"Body" = $TeamMessageBody
"ContentType" = 'application/json'
}
#Make the API Call
Invoke-RestMethod @parameters

ITIL® 4 Foundation Certification

After three days spent breathing nothing but IT Service Management, I’ve sat –and passed- the ITIL®4 Foundation exam. This post has some tips I learnt along the way and some resources that might be useful if you’re looking to get the certification yourself.

Exam Prep Tips

The exam is closed book with 40 multiple choice questions and an hour to complete. The pass mark is 65%, so that’s 26 correct answers as there’s no penalty for getting a question wrong. With some prior experience in ITSM, and a bit of focussed study, this is quite an achievable mark.

Where to start? You’ll see the “4 Dimensions of Service Management” and the “7 Guiding Principles” and the components of the “Service Value Chain”. Make sure you can recall as many as possible of these. You shouldn’t get asked “What’s the fourth Guiding Principle?”, but you might be asked “Which Dimension of Service Management applies here?” and be able to rule out two of the four multiple choice answers because they’re not the Dimensions from the framework at all.

Learn and remember the prescribed vocabulary. There’s lots of terms, many of which are words in common use more generally in IT.  These may not have the same meaning or have a more precisely defined description under ITIL®. Release Management is a good example here- it’s not about installing a latest version of your app or website- that’s Deployment Management. Release Management can be thought of as just the process of making that new version available to be deployed.

You keep using that word

I can’t overstate how important it is to know as many of the ITIL® terms, and what they mean is to passing the exam. Of course a full understanding of the principles is what you’re really after, but this is tested at this level by making sure you can recall the right name for a component of the framework and recognise where it should be used.

Also, checkout sample papers, but make sure you’re using the official ones for ITIL®4, and not any which may have v2 or v3 content. A lot has changed from v3 to 4 and you don’t want to be answering with the wrong framework. The sample papers I accessed felt remarkably similar in content and question structure to the real exam.

Learning Resources

Subscriptions or purchases may be required for some of these resources.

ITIL® is a registered trade mark of AXELOS Limited

Using your Ignite Attendee benefits to extend your Office subscription


imageAs a benefit for attending the online (and free!) Ignite conference this year, Microsoft have rewarded delegates with some discount prices on “select digital downloadable products” at the company store. Amongst the X-box games there’s also a great deal on the Office Family subscription.

Continue reading

The input arguments had entities that did not belong to the same datacenter.

Symptoms

Trying to vMotion (in my case a cross-vCenter vMotion from a 6.5 system to 6.7) a VM the error “The input arguments had entities that did not belong to the same datacenter.” occurred. Other VMs were migrating fine.

image

Cause

The CD Drive in the source VM was mapped to (although not connected to) a Content Library ISO file.

Solution

Point the source VM CD drive at “Client Device” and retry the vMotion.

image