Posts

  • More re-organisation

    I’ve moved the site out of Ghost (where I’d managed to end up in some version cul-de-sac, which was going to require multiple intermediate migrations to get out of), and into Jekyll. I’ll also be purging some older posts (I’m sure people are no longer interested in training resouces for vSphere 4!).
  • Using the vRealize 7.x REST API to get a tenant's Event Broker subscriptions

    After migrating from vRealize Automation (vRA) 6.2, we’ve recently started the long-overdue work of investigating the new functionality introduced with the event broker. We’re still using the state-change triggered workflows for machine life-cycle integration between vRA and vRealize Orchestration (vRO), and that’s going to be a big-job to change; but I thought I could maybe look at one of our other requirements which was to ensure that changes to blueprints made using the GUI get...
  • Using VMware vRealize Orchestrator to run a Jenkins job and get the results

    VMware vRealize Orchestrator (vRO) is pretty flexible, but there are times when you still need to execute a job on Jenkins. It’s pretty easy to create a Jenkins job which you can run by hitting a specific URL and vRO can do this in a couple of lines of JavaScript:- urlObject = new URL(yourJobUrl); urlObject.getContent(); This works well enough, assuming that you don’t need to wait on the job to complete and/or check that it...
  • vRealize Automation - Setting the Orchestrator Server using Custom Properties

    We’re soon going to be implementing multiple vRealize Orchestrator (vRO) servers in our vRealize Automation (vRA) development environment to allow people to choose different endpoints. Essentially if someone’s working on a workflow, that shouldn’t affect a different developer who is testing a template. So I wanted a way of allowing customers (in this case, developers) to choose from a list of Orchestrator endpoints. This might be useful in the following cases: Allowing specific customers to...
  • Defining the CloneFrom attribute of a Blueprint via Build Profile in vRealize Automation

    Using vRealize Automation (vRA) to allow your users to deploy their own infrastructure in minutes is great, but if the first thing they need to do is apply a bunch of patches, they’re not going to be happy. It’s essential that you keep your templates up to date. Doing so is fairly straightforward - clone the existing template, convert it to a running machine, power it on, apply all updates., shut it down and convert...
  • PowerShell script to restart a Virgin Media SuperHub

    Update 23/03/15 - Looks like there’s been an update to the SuperHub which broke the original version of the script. It has now been updated. Sometimes, after a week or so of uptime, I find that wireless access through my Virgin Media SuperHub gets very slow (wired access is fine). Like most IT issues, the issue can be fixed with a restart, but as it’s a wireless issue, restarting the router via the web interface...
  • Auto-generating PowerShell documentation in MarkDown

    I don’t mind writing documentation for my scripts, but I find that most documentation writing exercises tends to suffers from two problems:- Duplicated effort - I tend to document my script inline, (so that Get-Help will work), why do I need to document the same details elsewhere? Keeping it up-to-date - The only thing worse than no documentation, is clearly outdated documentation. I had a folder full of PS1 scripts, each of which had the...
  • Using an Ubuntu CrashPlan appliance to backup a NAS

    I’ve recently upgraded some of my home setup; instead of Windows Home Server 2011 managing everything, I’m now using a NetGear ReadyNAS 104, to serve files and using Windows Server 2012 R2 for the other functions. Moving my files to the Network Attached Storage (NAS) fixed some of my issues (NFS performs better for serving media to XMBC), but it left me with a small problem: I previously used CrashPlan for backing up files from...
  • Get VDI Capacity Information from the Horizon View ADAM Database

    Quick script to assist with capacity planning. The version I’m using here (which is a little too specific to our environment to be posted here), also counts the number of people in the entitlement groups and appends that as a column.
  • AppSense and VMware View Horizon Linked Clones

    The move from persistent physical desktops, to non-persistent linked clones (with a separate user personalisation layer) requires rethinking the way in which machines are configured and software is deployed. The challenge is to deliver a consistent, highly available platform with the maximum efficiency. In this case efficiency means utilising Horizon View’s ability to dynamically provision just enough desktops, while ensuring that the necessary configuration changes are delivered by AppSense. Computer configuration We do the bulk...
  • Displaying vSphere disk properties (including provisioning & persistence)

    I was doing some tidying of old scripts and came across something I thought it might be useful, so I tidied it up and added some documentation. This PowerShell script uses the vSphere PowerCLI to display a list of virtual machine disks, file-names, modes (persistent or non-persistent), sizes and whether or not the disk is thinly provisioned. You’ll need to connect to one or more vSphere servers first. It’s likely that I based the original...
  • Accessing SCSM 2012 using PowerShell (without SMLets)

    I wanted to use PowerShell to create a simple report of open (active & pending) incidents in System Center Service Manager 2012, but the only examples I could find online used the SMLets. Sometimes this wasn’t obvious, but soon became apparent when PowerShell choked over CMDLets like Get-SCSMObject. While I’m sure the SMLets are handy for ad-hoc reports by administrators, I wanted the option for my report to be generated by a group of users...
  • Remove machine objects from VMWare View's ADAM database with PowerShell

    26/02/14 - I’ve updated this script to accept pipeline input and work a little more efficiently when removing multiple machines. It’s one of those things that shouldn’t happen, but which inevitable does. Someone removes a View managed VM from vSphere, and View refuses to realise it’s gone. It also sometimes happens when machines fail to provision correctly (i.e., due to lack of available storage). The procedure is easy enough to follow, but it’s time-consuming and...
  • Invoke a PowerShell script directly from Subversion

    I’ve been thinking about doing something like this for a while. By adding this to PowerShell profiles, I can ensure that other people who use my scripts/functions are using the latest versions by having them run directly from a Subversion URL. This negates the requirement for them to have a local SVN repo (and for them to keep it up to date). Our Subversion is set up for basic, rather than AD integrated, authentication, but...
  • Using AppSense to deliver Microsoft App-V 5 applications to non-persistent VDI desktops at logon

    I’m currently working on user-centric application delivery to non-persistent VDI desktops. The rationale for this is that the more applications which can be delivered dynamically, the fewer pools we need to provision. This suits applications like Microsoft Project and Visio, which both tend to be used by a small number of people on each pool. These apps are too expensive to deploy to non-users, and need locked-down to fulfil license requirements if deployed under Citrix....
  • Get logon timings from AppSense client log

    I’m doing logon tuning just now for non-persistent VDI desktops - seeing long it takes to deploy App-V packages on a per-user basis to a generic desktop based on AD group membership. To assist with the tuning, I thought it would be useful to write a quick PowerShell function to gather information from the AppSense event logs in a way that allowed easy sorting, display, recording and comparison. Example output, sorted and piped to Out-Gridview...
  • Server Uptime (2013 Scripting Games practice)

    I’m not sure yet if I’ll take part in the 2013 Scripting Games; but as the the practice exercise dovetailed nicely with a requirement I had, I thought I’d give it a shot. It was quite different to write something “properly”, rather than just knocking something out that’d do the job. I’m not sure that’s exactly the way I would have done it without the supplied specification; I would have probably just returned total hours...
  • Function to check whether a computer is responding to Ping

    A lot of my scripts use Active Directory to create lists of servers. Unfortunately, AD often contains decomissioned computer objects, which can cause certain queries to time-out I wrote this quick function so that before running WMI queries against a server, we could do a quick check to see whether it was online.
  • Using the WebSphere MQ PowerShell library

    I’ve been doing some work with IBM WebSphere MQ recently. Specifically I’ve been helping to create a (temporary) reporting and monitoring tool which will periodically check channel status and depth of certain queues. While the application has it’s own command-line utility (MQSC) I’ve been trying to work using the WebSphere MQ Windows PowerShell library. After downloading the file I followed the installation instructions, and immediately ran into the following error when trying to load the...
  • Getting VMWare View pool utilisation

    We needed a way to keep track of how many users had been granted permission on a pool to ensure that there were plenty of provisioned desktops. Knowing that it’s possible to list the number of machines in a pool, and the entitled users and groups using View CMDLets on a connection server via a PSRemote session, and knowing that it’s possible to enumerate the total number of users in a group (including indirect membership);...
  • PowerCLI to display VM name and screen resolution

    One-liner PowerCLI to output a list of machine names and screen resolutions. Get-VM | Where-Object {$_.Folder.Name -ne "VMwareViewComposerReplicaFolder"} | Select-Object Name,@{Name="Resolution";Expression={($_.Guest.ExtensionData.Screen.Width.ToString() + "x" + $_.Guest.ExtensionData.Screen.Height.ToString())}} Handy for checking that VDI desktops are not set to less than 1024x768 which can cause issues with PCOIP, hence the exclusion of View replicas via the Folder.Name property (which would otherwise pollute the results when running against a View vCenter). I concatenated the Height and Width values into a...
  • Getting PCOIP statistics via WMI using PowerShell

    I was at a training course last week and it was mentioned briefly on one of the slides that PCOIP session statistics were available via WMI. After a quick Google, I found MyVirtualCloud’s page, which details the class, and property names. The following is a PowerShell function, which pulls this information from WMI, appends the names and descriptions, and returns an object. You could, for example, export the returned object to an HTML page. Or...
  • Formatting PowerShell tables with jQuery and DataTables

    One of the great things about PowerShell is its ability to easily export objects to HTML, which - with a little CSS - makes it straightforward to create great-looking reports. But static lists of data aren’t enough anymore, people demand interactivity. DataTables is a plug-in for the jQuery JavaScript library which is great for displaying interactive HTML tables, with options for sorting and filtering. You can have a look at some of the examples on...
  • Creating shortcuts to PowerShell Scripts

    You’ve probably noticed that when you double-click on a PowerShell script, it is opened for editing rather than being run. This is useful from a security standpoint, and while administrators have no problem opening up the shell and running the script, you’ve probably made something useful that you want to share with users, and users always need a bit more hand-holding. Assuming that your PowerShell installation is in the default location, you need to append...
  • Automatically setting the machine owner as a custom attribute

    As we are constantly creating, moving, renaming and deleting machines, it’s difficult enough to keep track of machines I have deployed myself; never mind keeping track of what the other team members are doing. In order to try make it easier to find the owner of a machine, we implemented a custom attribute “Infrastructure Consultant”, which the analyst should complete. Inevitably, despite the best of intentions, this is occasionally missed, and we end up with...
  • Datastore alerts via Twitter

    With thin provisioning currently being implemented in our environment, and plans to expand the use of Linked Clones, it’s become apparent that we’re going to have to start paying close attention to our datastores. Eric Gray has done some great stuff with using VMware vCenter alarms with PowerShell to automatically migrate machines. And Carter Shanklin’s got a great description of a different method, but I was after something which didn’t involve making any modifications to...
  • Automatically converting machines to thin provisioned format

    I haven’t been posting too much here recently I’m afraid. A lot of the things that I’m currently working on are pretty specific to the environment here, and are not particularly useful (or indeed, interesting) to anyone else. One of the things I’ve been doing might be more generally useful. We needed to convert around 700 of our machines to thin-provisioned format. When migrating to the new environment we’d stuck to traditional “thick” machines, as...
  • Preventing computer password expiry

    If, like me, you work with non-persistent virtual machines on Windows domains, you will be familiar with your machines becoming periodically disconnected from the domain. This usually manifests itself in the following error message when you attempt to log on:- “The trust relationship between this workstation and the primary domain failed.” The problem is detailed in this KB Article. What happens is that every 30 days (by default) the client initiates a computer password change...
  • Changing drive letter assignments after deploying a virtual machine from a template

    We’ve had an ongoing problem with “Sequencing” machines for Microsoft Application Virtualisation (formerly SoftGrid). The virtual machine template is correctly set up with a secondary drive set to Q:\ (the drive letter is integral to the sequencing process). However, when the machines are deployed from the template, the Sysprep part of the customization process results in the drive being “reset” to the lowest available - in this case D:. At first, we manually changed these...
  • Manually creating linked clones in vSphere

    We’ve started our first “proper” implementation of Linked Clones in our vSphere 4 environment. While we’ve done some limited proof-of-concept work, this is the first project to be entirely deployed using Linked Clones. The objective is to reduce the space used by our training machines on our new environment. Linked clones allow multiple machines to share a common read-only “base” VMDK file, with each machine generating their own delta (REDO). Under normal usage circumstances, the...
  • Changing StandByAction using PowerShell script created with help from Onyx

    We’re currently having some issues caused by the convergence of vSphere 4.0, IndependentNonPersistent drives, StandBy and DRS (I’ll post more on that later). As a workaround, we needed to modify 228 machines so that they did not go into hibernation. You can do this though the vSphere Client by right clicking the virtual machine, click Edit Settings, go to the Options Tab, then select Power Management, and changing the radio button. We were wanting to...
  • Using SDelete to maximise the amount of disk space reclaimed during conversion to thin-provisioned disks

    We’re currently neck-deep in migration at the moment, but despite the workload, it’s always worth considering what we can do now, that might save us some time and effort later on. One of the reasons we were moving to vSphere was the ability to thin-provision (TP) our disks, which we’re hoping will allow us to increase the amount of machines that we can provision without needing to allocate more storage (currently 18 TB). I found...
  • Get the last user to power down a VM

    We can use PowerShell to search through the event logs of a machine object ($objVM in the example below) for events which match a specific pattern - in this case powering off a machine. Once we have the event object, we can access the properties of the first object in the array (the most recent event). $objEvent = @( Get-VIEvent -Entity $objVM | Where-Object{$_.fullFormattedMessage -like"Task: Power off Virtual Machine"} ) $objEvent[0].userName $objEvent[0].createdTime I recall seeing...
  • vCenter and host build numbers

    This is based on Carter Shanklin’s PowerShell snippets to query VC and ESX build version numbers. This script loops through the list of vCenter servers, and gets their version and build info, as well as the version and build info for it’s connected hosts.
  • Script to add a hash table full of virtual port groups to vSphere hosts

    As part of the migration I’m working on, we needed to add a whole bunch of Virtual Port Groups with associated VLANs to the servers. The following script could do this in a few minutes (although Host Profiles would accomplish much the same thing, we’re not running Enterprise) Although this isn’t a complicated script, it was the first time I’ve used hash tables (thanks to PowerShell.Com’s excellent page), so I thought I’d share.
  • Script to add VMX path to vSphere Client as a custom attribute

    I love it when I have an idea in my head of a script I need to write, and then I run across one that does exactly what I need! Hugo Peeter’s has written a script to add VMX location as a custom attribute.
  • Understanding memory resource management in VMware ESX

    VMware have published an excellent white paper on memory management [pdf]. The document is technically detailed, but makes interesting reading. The authors do a good job of describing the methods ESX uses to manage and allocate virtual memory; and how when guests deallocate memory it’s not necessarily freed up for reuse by other guests. This should prevent you from allocating more memory to guests than is physically available on the host (overcommitting); however the hypervisor...
  • Master-PowerShell With Dr. Tobias Weltner

    Dr Tobias Weltner has released a free comprehensive eBook on PowerShell. Something to put on your eBook reader.
  • Export and import vSphere customization specifications using PowerShell

    I’m in the middle of preparing for a migration from VI3 to vSphere 4 just now (hence the lack of any substantial updates on this blog). As part of this process, I was just about to start writing a script to export our customisation specifications, when Arnim van Lieshout’s post appeared in my VMware Planet V12N RSS feed. Export and import customization profiles using Powershell. It failed on a couple of customisations, but by adding…...
  • VMware Developer CodeCentral

    VMware have launched a new community site for code examples, and there’s a section on VMware vSphere PowerCLI (formerly VI Toolkit). They seem to be picking the best scripts from the regular contributors to the forums, so it’s a good place to have a look for examples. They’re rated by users, and tend to be slightly better documented than the ones posted in the forums (which tend to be appended and amended as the thread...
  • Cleaning up VM template names

    I wrote this today to remove occurrences of the string “Tmpl” anywhere in the name of the template, and then to re-name the template with “Tmpl” as a prefix. It had a higher purpose than keeping everything nice and neat, but it’s rather specific to our environment so I won’t bother going into the details. Despite being quite specific in it’s current form, this could easily be modified to rename virtual machines (or indeed any...
  • Virtual machine BSoD detector

    Carter Shanklin has used Microsoft Office Document Imaging Library (MODI) to improve Eric Sloof’s script to detect Blue Screens of Death (BSoDs); it now captures the errors and converts them to text. From Eric’s blog: [F]irst it captures a screenshot of a virtual machine. Secondly it uses the Toolkit Extensions to copy it to the local drive. When the PNG image is saved on the local drive, it’s converted to TIFF. The TIFF image will...
  • Check if servers in a text list exist as VMware VMs

    I got handed a list of around 1,000 servers today, and asked if any of them were part of our VI environment. Rather than work through it by hand, I wrote the following script: If your VM object names do not match the DNS names on the list, then this won’t work, but I suppose you could combine this with some logic from the script I wrote to find mismatches.
  • Thin Provisioning in ESX 3.5

    One of the nice new features of vSphere 4 is thin provisioning of virtual disks. Thin provisioned (TP) disks will be familiar if you’ve ever used VMware Workstation where they are used by default, (you need to select Allocate all disk space now to create thick disks). Essentially, rather than allocate all disk space at creation, disk space is allocated on the fly, meaning that a 50 GB virtual disk with only 5 GB being...
  • Add disk persistence information to the VI Client using PowerShell

    I’ve further adapted Hugo’s script to add a custom attribute which shows the drive persistence state(s) when the script was run. The script also adds drive state information for templates as well as VM objects.
  • Add disk size information to the VI Client using PowerShell

    This is based on Hugo Peeters’ script to add snapshot information to the VI client using PowerShell. Our users occasionally need larger machines created for packaging big applications. After increasing the size, we used to append the VM Object name (e.g, “PACKVM01 - 10GB”), but this caused a mismatch between the virtual machine object name in VIC and the DNS host name. Also, it looked untidy! We needed a new way for VIC users to...
  • Creating new Virtual Port Groups in ESX with PowerShell

    We frequently need to create new virtual port groups on our ESX hosts with VLAN tags which correspond to pre-assigned DHCP scopes. I wrote this PowerShell script to create the new VPG across all hosts. This assumes that your virtual port group is on a switch called VMSwitch. You could easily modify this to accept parameters from the command-line, rather than being specified in the script. When it comes to re-naming existing virtual port groups...
  • Find vSphere templates with non-persistent disks

    As we’re running a development lab, we use a lot of templates for machine deployment and a lot of non-persistent disks to allow machines to be easily restored to a clean-state. We’ve had issues where machines with non-persistent disks were converted to templates. In this case guest customisation will fail. This script looks at your templates, and outputs a list of those with non-persistent drives.
  • Resolving Virtual Machine object name and DNS name mismatches using PowerCLI

    We were working recently to align our guest VM object names (the ones shown in vSphere) with their DNS names. As we have over 800 guests, this would have taken us a while to compile by hand. In order to make the process a little easier, I wrote the following PowerShell script to flag machines where the hostname differs from the object name. This worked perfectly. While I could have had the script rename these...

Subscribe