Get-TagCategory
VMware: Retrieves tag categories
#Requires -Version 5.1
#Requires -Modules VMware.VimAutomation.Core
[CmdletBinding()]
Param(
[Parameter(Mandatory = $true)]
[string]$VIServer,
[Parameter(Mandatory = $true)]
[pscredential]$VICredential,
[string]$Name,
[ValidateSet('*', 'Name', 'Description', 'Cardinality', 'EntityType', 'Id', 'Uid')]
[string[]]$Properties = @('Name', 'Description', 'Cardinality', 'EntityType', 'Id')
)
Process {
try {
if ($Properties -contains '*') { $Properties = @('*') }
$vmServer = Connect-VIServer -Server $VIServer -Credential $VICredential -ErrorAction Stop
$cmdArgs = @{ ErrorAction = 'Stop'; Server = $vmServer }
if ($PSBoundParameters.ContainsKey('Name')) { $cmdArgs.Add('Name', $Name) }
$result = Get-TagCategory @cmdArgs | Select-Object $Properties
if ($null -ne $result) { foreach ($item in $result) { $item | Add-Member -NotePropertyName Timestamp -NotePropertyValue (Get-Date -Format "yyyy-MM-dd HH:mm:ss") -PassThru -Force } }
}
catch { throw }
finally { if ($null -ne $vmServer) { Disconnect-VIServer -Server $vmServer -Force -Confirm:$false -ErrorAction SilentlyContinue } }
}IP address or DNS name of the vSphere server
PSCredential object for authenticating with the server
Name of the tag category
List of properties to expand; use * for all