Synchronizing vCenter Notes, Tags and Annotations to Commander Custom Attributes
VMware vCenter enables Administrators to add metadata to VMs and vApps in the form of Notes, Tags and Attributes. Using the Windows Task Scheduler with the PowerShell scripts provided in this article, administrators can synchronize vCenter metadata to a custom attribute in Commander, up to 255 characters.
Important: VMs with duplicate names under a single vCenter server will be ignored during the synchronization process, even if they have different parent elements (for example being contained in different datacenters). The notes and tags for these VMs will have to be added to Commander manually.
Requirements
- Commander scripts (attached)
- Commander custom attributes created to take values
- PowerShell v3 installed on the Commander application server
- Commanderâ„¢ 5.2 or later
- VMware PowerCLI
- Commander REST API powershell libraries (Download here)
Creating Custom Attributes
The first thing to do is create a custom attribute in Commander to store the information. Follow the steps below to do so.
- Under the Configuration menu, choose Custom Attributes. Click Add.
- Name the attribute vCenter Notes and provide a meaning Description.
- Select Type: Text and Applies To: All Types.
- Uncheck Edit in Service Portal (changes made in Commander are not synchronized back into vCenter). Click Next.
- Leave Free Form selected and click Finish.
Prepare the Script Files
Download and extract the scripts to your Commander application server. Snow Software recommends storing all scripts called by Commander in a single location, using sub-folders to identify the functions of particular scripts. This script is not executed by Commander, but storing them in the same area is still recommended. With the scripts extracted, the file system will look like this:
The scripts require minor editing before they will work with your systems. Refer to the comments in the individual script or the table below for guidance on editing the contents.
| Setting | Description |
| $vCommanderServer | The hostname or IP address of the Commander server. |
| $CredFile | The credentials file which handles access to your Commander. For more details, please refer to the Appendix: PowerShell Script Credential Encryption in the Commander API Getting Started Guide, available attached here . |
| $VIServer | The vCenter Server name as it appears in Commander. This value must be resolvable via DNS and reachable from the Commander application server. |
| $vCredFile | The credentials file which handles access to your vCenter. The user must have permission to read the notes for all the VMs you wish to synch to Commander. |
| $Attrib2update | The name of the attribute you created in Commander to hold the values. |
| $TagCategory | The category name of the tag you want to populate in Commander. |
Configure Windows Task Scheduler
Windows Task Scheduler is used to execute this script on the schedule you define. The steps to configure below are an example using Windows Server 2016. Other versions of the server OS may introduce slight variations. If you encounter these, refer to Microsoft documentation or contact Snow Software Technical Support for assistance.
- Logged in as an Administrator, Open Task Scheduler.
- In the Actions pane, click Create Basic Task.
- Name the task Synchronize vCenter Notes to Commander and add a meaningful Description. Click Next.
- Choose to trigger the task Daily and click Next. Choose a time to run the task, and set it to recur every day. Click Next.
- Choose Start a program and click Next. Click Browse… to locate the PowerShell executable.
- Add the argument:
& 'C:\Scripts\vCenterNotes2vCommanderv2.ps1'using the correct path to your copy of the script. Click Next.
- Click Finish.
Update VM Details
Finally, interested users must configure the custom attributes holding the values to appear for them in Commander.
- Open the Summary tab for any VM in vCommander.
- Click
in the Details section.
- Locate and select the custom attribute you created in the Hidden Properties list. Click Add > to move it to the Shown Properties list.
- Use the Move Up and Move Down buttons to order where the information will appear in the list, and click OK.