In this guide, I will show you how to add, remove, and read Microsoft's System Center Virtual Machine Manager (SCVMM) custom properties with PowerShell and the Virtual Machine Manager Console.

Like VMware vSphere, SCVMM allows you to create custom properties to better filter through information about your virtual machines, hosts, and templates. For example, you could create a custom property to track the product of the virtual machine (i.e., VPS Level 1).

Manage SCVMM custom properties with the VMM Console ^

Launch the SCVMM. You can install the Virtual Machine Manager Console using the Microsoft SCVMM installer, which is available for download from the Microsoft Development Network (MSDN) or the Volume Licensing Service Center (VLSC).

VMM console

VMM console

Find a virtual machine to which you want to add a custom property. Right-click the virtual machine and select Properties.

Virtual machine properties

Virtual machine properties

The virtual machine properties will open. Select the Custom Properties section. You should see ten custom properties, labeled Custom1 through Custom10.

Default custom properties

Default custom properties

While you can, of course, add values to these properties, it is much more practical to create your own custom properties. Click the Manage Custom Properties button. From here, you can view custom properties that you've already created by object type, as well as assign new or existing custom properties to different objects. For this guide, we will focus on creating and assigning custom properties for the virtual machine object.

Manage custom properties

Manage custom properties

Click the Create button to create a new custom property for the virtual machine object. For this guide, enter the Department for the custom property name and click OK. Optionally, you can also add a description.

Create custom property

Create custom property

You should now see the custom property Department available to assign. Select the property under the column Available properties and click the Add button. You've now just assigned the custom property Department to the virtual machine object, and it is now available on all your VMs globally for you to assign values.

Assigned properties

Assigned properties

Click OK. You should now see a custom property named Department listed in the VM custom properties. Enter a value and click OK. For this guide, I will enter the value HR.

New custom properties

New custom properties

Click OK. You've now just added a custom property to your VM and assigned it a value—but where is it in the VMMC? Well, you need to add your newly created custom property as a column to display in the VM grid. Right-click any of the column headers and select your newly created property. You should now see your newly created custom property in the VM grid.

Department column

Department column

Now let's say you want to search for VMs that are used by the HR department. In the search bar, enter with quotes "Department: HR". Sure enough, when you enter "Department: HR", the VMs assigned the value HR for the custom property Department are returned as a result.

Department search

Department search

From the Manage Custom Properties setting, you can also perform several other functions, such as renaming custom properties and unassigning custom properties from objects.

Create SCVMM custom properties with PowerShell ^

Now, if you're like me, you tend to do most of your administrative tasks using PowerShell. Fortunately, SCVMM comes with several PowerShell cmdlets you can use to manage custom properties. Note that you need the VMMC installed on the workstation or server you use to run these commands.

Let's start by opening the PowerShell ISE and creating a new custom property called Cost Center for all our VMs. Enter the following command:

New-SCCustomProperty -Name "Cost Center" -AddMember VM

The -Member switch specifies which object to add the custom property to (VM, Template, VM Host, etc.).

New-SCCustomProperty -Name "Cost Center" -AddMember VM

If the command is successful, you will see output like this:

Creating a custom property with New SCCustomProperty

Creating a custom property with New SCCustomProperty

Additionally, you should now see the custom property Cost Center available for use in the VMMC.

Cost center custom property

Cost center custom property

Now, let's pick a VM and assign a value to this custom property. Enter the following command:

Set-SCCustomPropertyValue -InputObject (Get-SCVirtualMachine -Name "US-GLOBAL-03") -CustomProperty (Get-SCCustomProperty -Name "Cost Center") -Value "IT001"

The Get-VirtualMachine -Name "US-GLOBAL-03" command is required to properly convert the VM name to a readable format—as standard quotation marks will not work. The same requirement exists when specifying a custom property to assign a value. If the command is successful, you will see output like this:

Setting the value of a custom property with Set SCCustomPropertyValue

Setting the value of a custom property with Set SCCustomPropertyValue

Additionally, you should now see the custom property Cost Center with the value IT001 added your VM—in my case, the VM US-GLOBAL-03:

Cost center value

Cost center value

Read SCVMM custom properties with PowerShell ^

To read the custom property Cost Center, enter the following command:

Read a custom property with Get SCCustomProperty

Read a custom property with Get SCCustomProperty

Finally, let's remove the custom property Cost Center from the VMMC altogether. Enter the following command:

Remove-SCCustomProperty -CustomProperty (Get-SCCustomProperty -Name "Cost Center")

The Get-SCCustomProperty -Name "Cost Center" command is required to convert the custom property properly to a readable format. If the command is successful, you will see output like this:

Removing a custom property with Remove SCCustomProperty

Removing a custom property with Remove SCCustomProperty

Additionally, the custom property Cost Center will no longer be available/visible in the Virtual Machine Manager Console.

Subscribe to 4sysops newsletter!

You can use these and other SCVMM cmdlets to write PowerShell scripts to create, add, and remove custom properties and values for multiple VMs and other object types.

avatar
0 Comments

Leave a reply

Your email address will not be published.

*

© 4sysops 2006 - 2022

CONTACT US

Please ask IT administration questions in the forums. Any other messages are welcome.

Sending

Log in with your credentials

or    

Forgot your details?

Create Account