57 lines
1.7 KiB
PowerShell
57 lines
1.7 KiB
PowerShell
<#
|
|
.SYNOPSIS
|
|
A short one-line action-based description, e.g. 'Tests if a function is valid'
|
|
.DESCRIPTION
|
|
A longer description of the function, its purpose, common use cases, etc.
|
|
.NOTES
|
|
Information or caveats about the function e.g. 'This function is not supported in Linux'
|
|
.LINK
|
|
Specify a URI to a help page, this will show when Get-Help -Online is used.
|
|
.EXAMPLE
|
|
Test-MyTestFunction -Verbose
|
|
Explanation of the function or its result. You can include multiple examples with additional .EXAMPLE lines
|
|
#>
|
|
|
|
function Enable-ITDVMwareVMHostFeature {
|
|
[CmdletBinding()]
|
|
param (
|
|
|
|
[Parameter(Mandatory = $true)]
|
|
[string[]]
|
|
$Name,
|
|
|
|
[switch]
|
|
$LockdownMode,
|
|
|
|
[switch]
|
|
$AlarmActions,
|
|
|
|
[switch]
|
|
$SSH
|
|
)
|
|
Begin {
|
|
|
|
}
|
|
Process {
|
|
$VMHosts = Get-VMHost -Name $Name
|
|
ForEach ($VMHost in $VMHosts) {
|
|
If ($LockdownMode) {
|
|
($VMHost | Get-View).EnterLockdownMode()
|
|
}
|
|
If ($SSH) {
|
|
Get-VMHostService -VMHost $VMHost | Where-Object { $_.key -eq 'TSM-SSH' } | Start-VMHostService -Confirm:$false | Select-Object VMHost, Key, Label, Running
|
|
}
|
|
If ($AlarmActions) {
|
|
$VIServer = $VMHost.Uid.Split('@')[1].Split(':')[0]
|
|
$alarmMgr = Get-View AlarmManager -Server $VIServer
|
|
$alarmEnabled = $VMHost.ExtensionData.AlarmActionsEnabled
|
|
if ($alarmEnabled -eq $false) {
|
|
$alarmMgr.EnableAlarmActions($VMHost.ExtensionData.MoRef, $true)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
End {
|
|
|
|
}
|
|
} |