Get-HostServices
VMware: Retrieves information about a host services
#Requires -Version 5.1
#Requires -Modules VMware.VimAutomation.Core
[CmdletBinding()]
Param(
[Parameter(Mandatory = $true)]
[string]$VIServer,
[Parameter(Mandatory = $true)]
[pscredential]$VICredential
)
Process {
$vmServer = $null
try {
$vmServer = Connect-VIServer -Server $VIServer -Credential $VICredential -ErrorAction Stop
$timestamp = Get-Date -Format "yyyy-MM-dd HH:mm:ss"
$result = Get-VMHostService -Server $vmServer -ErrorAction Stop | Sort-Object Name
foreach ($item in $result) {
[PSCustomObject]@{
Timestamp = $timestamp
Value = $item.Id
DisplayValue = $item.Key
}
}
}
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