Adding SCOM Management Groups to Agents Using Powershell

I’ve been buried in automation recently, which has thrown up more than the odd technical challenge along the way. One which I found surprising was the lack of a PowerShell script for adding management groups to SCOM agents… There was a VB Script available but I decided it was time to get with the program, the script I wrote can be found here:

http://gallery.technet.microsoft.com/Add-SCOM-Management-Group-af049566

The manual process for adding management groups to SCOM agents can be found on TechNet here:

http://technet.microsoft.com/en-us/library/hh212883.aspx

PowerShell v3 – The Script Editors Choice or is it?

Musing over a well-earned break today with friend, college and, all round Exchange guru Will Rawlings the topic of Windows 8 was brought to the forefront. Will was telling me about how after acclimatising to the shock of the tiled interface he dug a little deeper and got his hands dirty with PowerShell v3.

There are some great new features in PS3 but what really grabbed Will’s attention, and later my own, was the new look ISE. It’s not only easier on the eye but has some useful functionality under the hood including Intellisense (a useful autocomplete feature) and much more.

The one simple thing that really got us talking was the copy and paste feature now maintains the colours seen in the ISE! That feature alone is worth the upgrade. Personally I prefer to use PowerGUI as my editor but on client systems I frequently use the ISE so I can’t wait until the Windows Management Framework v3 is released.

 

Of course the real excitement with PowerShell 3 does not lie in the ISE but it is well worth a look all the same. In order to try it out simply download the consumer preview of Windows Management Framework v3

4 Steps to Find and Remove Orphaned Disks in VMware Vcenter

Disk space can seem like an ongoing battle in many virtual environments. In this post I’m going to be showing you one way of dealing with orphaned disks within VMWare’s Vcenter in order to free up any “lost” storage.

First off, what is an orphaned disk? Well it’s fairly simple, ever deleted a disk from a virtual machine (VM) and not removed it from the datastore? Well congratulations, you have just created an orphaned disk! Orphaned disks are not attached to any VM within the Vcenter environment. In most cases that means we don’t want the disk, however there may be exceptions so before you run ahead and delete everything check that your orphaned disks aren’t shall we say, applying for adoption!

Pre Requisites:

  • PowerGUI – Download Here
  • PowerGUI – VMWare PowerPack (Included with PowerGUI)
  • VMware vCenter

To search our environment for orphaned disks we will be using the PowerGUI Administrative Console. Open the console from the start menu. We will be using the VMWare PowerPack. In the navigation tree window on the left hand side if you don’t see a “VMWare” tree then we need to enable the PowerPack, if you do the skip the next section.

1 – Enable the VMWare PowerPack

In the PowerGUI administration console browse to “File” > and click “PowerPack Management” Click “Import” and browse to “C:\Program Files (x86)\PowerGUI\PowerPacks” Select “VMware.VIToolkit.powerpack” click “Open” that’s it! Close the PowerPack Management window.

2 – Connect PowerGUI to vCenter

Expand the “VMware” tree and select “Managed Hosts” On the right hand menu click “Add Managed Host…” you are presented with the parameter window, here enter the FQDN name (or IP Address) of your vCenter server. Configure your account details and click “OK”

Your newly added vCenter host appears in the managed window, highlight your host and from the actions pane click “Connect”

3 – Run the Report

In the Navigation Tree (left hand pane of PowerGUI) Under VMWare\DBest Practice Queries \Disk Queries select “Orphaned VMDK files. Depending on the size and perfomrance of your environment the query will take some time to complete. You will notice at least one esxconsole-<hashed Number>.vmdk DO NOT DELETE THESE FILES.PowerGUI and the VMware PowerPack

4. Remove the Disks

After you have verified that the orphaned disks are genuinely no longer required it’s time to reclaim that disk space.

You could do this via Powershell and PowerCLI or even using PowerGUI but for the purpose of this article we will fire up vCenter and navigate to our datastore. From the “Home” page click “Datastores” .

Open the datastore containing the orphaned .vmdk file you wish to remove. Browse the contents of the datastore by right-clicking the datastore and selecting “Browse Datastore…”

In the datastore browser window navigate to the correct disk and select it in the main window. Check the name carefully, now is not a good time to delete the wrong disk! Select the disk and clik the red X on the menu bar of the datastore browser. You will be promted to confirm your actions! Congratulations you just removed an orphaned disk, now on to the next!

 

 

 

 

 

 

PowerShell just got bigger!

If you are not familiar with PowerShell and its ability to simplify your working life then now is the time to harness the power of the command line. Like many windows admins I grew up using a GUI and until working for an ISP using mainly Linux and Cisco devices I’d only ever used the command line for automating a few tasks. Once you get through the pain of learning how to use the command line life just gets easier!

Too Much time in the shell can lead to unexpected outcomes!

 

PowerShell is clearly the future for Microsoft, the current version is V2 however V3 beta is already available and adds some really cool features that underline MS’s commitment to PowerShell moving forward.

If you have been using PowerShell for a while you may have heard of the Quest PowerShell commands and if you haven’t already used them now is the time to get involved!

The Quest commands allow for much simpler scripting tasks and have saved me hours in managing various environments.

Here is the blurb from Quest:

ActiveRoles Management Shell for Active Directory is a set of free, predefined commands for Windows PowerShell, the powerful command line and scripting language developed by Microsoft. These commands are designed to help administrators automate common, repetitive and bulk management tasks for Active Directory, such as creating, removing or updating objects in AD.

 

By using the ActiveRoles Management Shell for Active Directory to build your scripts, you can harness Quest ActiveRoles Server to leverage proven rules, roles, workflow and attestation features giving you a robust management option for Windows PowerShell and Active Directory.

Download the commands here