Get-OSCustomizationSpec
VMware: Retrieves OS customization specifications
#Requires -Version 5.1
#Requires -Modules VMware.VimAutomation.Core
[CmdletBinding(DefaultParameterSetName = "ByName")]
Param(
[Parameter(Mandatory = $true, ParameterSetName = "ByName")]
[Parameter(Mandatory = $true, ParameterSetName = "ById")]
[string]$VIServer,
[Parameter(Mandatory = $true, ParameterSetName = "ByName")]
[Parameter(Mandatory = $true, ParameterSetName = "ById")]
[pscredential]$VICredential,
[Parameter(Mandatory = $true, ParameterSetName = "ById")]
[string]$ID,
[Parameter(ParameterSetName = "ByName")]
[string]$SpecName,
[Parameter(ParameterSetName = "ByName")]
[Parameter(ParameterSetName = "ById")]
[ValidateSet("Persistent", "NonPersistent")]
[string]$SpecificationType,
[Parameter(ParameterSetName = "ByName")]
[Parameter(ParameterSetName = "ById")]
[ValidateSet('*', 'Name', 'Type', 'Server', 'LastUpdate', 'DomainAdminUsername', 'DomainUsername', 'Description', 'AutoLogonCount', 'ChangeSid', 'DeleteAccounts', 'DnsServer', 'DnsSuffix', 'Domain', 'FullName', 'NamingScheme', 'OrgName', 'OSType', 'ProductKey', 'TimeZone', 'Workgroup', 'LicenseMode', 'LicenseMaxConnections', 'Id', 'Uid')]
[string[]]$Properties = @('Name', 'Type', 'Server', 'LastUpdate', 'DomainAdminUsername', 'DomainUsername', 'Description', 'Domain', 'FullName', 'OSType', 'LicenseMode', 'LicenseMaxConnections', 'Id')
)
Process {
try {
if ($Properties -contains '*') { $Properties = @('*') }
$vmServer = Connect-VIServer -Server $VIServer -Credential $VICredential -ErrorAction Stop
$cmdArgs = @{ ErrorAction = 'Stop'; Server = $vmServer }
if ($PSCmdlet.ParameterSetName -eq "ById") { $cmdArgs.Add('Id', $ID) }
elseif ($PSBoundParameters.ContainsKey('SpecName')) { $cmdArgs.Add('Name', $SpecName) }
if ($PSBoundParameters.ContainsKey('SpecificationType')) { $cmdArgs.Add('Type', $SpecificationType) }
$result = Get-OSCustomizationSpec @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
ID of the OS customization specification
Name of the OS customization specification
Type: Persistent or NonPersistent
List of properties to expand; use * for all