Clean up vCenter with PowerShell after SCVMM leaves

Microsoft System Center Virtual Machine Manager (SCVMM) 2008 makes several changes to your vCenter environment that you may like to know about, especially since they don’t seem to be mentioned in the product documentation.  It’s also worth pointing out that none of these changes are reverted when you subsequently decide to discontinue managing vCenter with SCVMM.

There are three different affected areas and you can fix each one manually or all in one shot with a VI Toolkit (for Windows) PowerShell script that I wrote for just this purpose.

1.  SCVMM Port Groups


First, let’s address the new port groups that SCVMM created when managing your VMware ESX VMs.  I covered this in more detail in a previous article.  Essentially, the SCVMM interface presents vSwitches, not port groups.  It then creates one or more new port groups for you without warning — one per vSwitch, per VLAN, on each ESX host.

To recover from this mess, you will need to reconfigure any VMs that are currently using these port groups and then delete the port groups from the vSwitches.  If you have more than a couple VMs this task will be easier with the script.

2.  Custom Attribute: ClusterInvariantVMMId

I bet you did not know that SCVMM would add a new strangely-named custom attribute to vCenter and tag every single VM in your inventory with a GUID.  I’ve heard puzzled VMware customers asking about this.  Initially, the explanation for this phenomenon was not clear — until I evaluated the SCVMM product and VMware vCenter integration.  If you are done with SCVMM, it is safe to remove this attribute with VI Client (on the Administration menu).


3.  Self-Service Role

Evidently the Self-Service Portal feature of SCVMM will allow users to provision and manage VMs on ESX hosts in addition to Hyper-V.  I tried this and it did not work, but I probably wasn’t persistent enough.  When you are done using SCVMM you won’t be needing that role anymore — go ahead and delete it.


PowerShell Cleanup Script

If you would like to clean up all three of these issues in one step, use the following VI Toolkit (for Windows):

# SCVMM-Cleanup.ps1
# When SCVMM connects to vCenter, it makes several changes and doesn't clean up
# after itself.  This script returns everything back to normal.

# Version 1.0  January 5, 2009
# Eric Gray

# modify this line accordingly
Get-VC vchostname -user xxx -Password yyy

# VMs using SCVMM-created port groups will be reconfigured to use this instead
$portGroup = "VM Network"

# Move all NICs from the SCVMM.vSwitchX.Y port groups to $portGroup
get-vm | Get-NetworkAdapter | where {$_.NetworkName -like "SCVMM*"} `
    | Set-NetworkAdapter -NetworkName $portGroup -Confirm:$false

# Delete those SCVMM port groups after they are no longer in use
foreach ($esx in Get-VMHost) {
    Get-VirtualPortGroup -VMHost $esx.Name | where { $_.Name -like "SCVMM*" } `
    | Remove-VirtualPortGroup  -Confirm:$false

# Clean up the custom attribute
Get-Datacenter | Remove-CustomField -Name ClusterInvariantVMMId -Confirm:$false

# Remove the SCVMM role
$authMgr = Get-View AuthorizationManager
foreach($role in $authMgr.RoleList | where {$_.Name -eq "SCVMMSelfServiceUser"}){
    $authMgr.RemoveAuthorizationRole($role.roleid, 1)

If you or one of your coworkers accidentally polluted your vCenter environment, this should help you get everything back in order.

Thanks go to Carter Shanklin for reviewing the script.

(Visited 854 times, 1 visits today)
This entry was posted in Virtualizationism and tagged , , , , , . Bookmark the permalink.

3 Responses to Clean up vCenter with PowerShell after SCVMM leaves

  1. Hany Michael says:


    Great post! I’ve been always wondering what the SCVMM is leaving behind when managing vCenter.


  2. Alan Renouf says:

    Nice script, hope you dont mind but I posted an article on my blog about this, very nice use of the VI Toolkit.

  3. Eric Gray says:

    @Hany: Thanks!

    @Alan: Mind? Heck no! I’m flattered.

Comments are closed.