Reply to Message

View discussion in a popup

Replying to:
baber
Expert
Expert

Thanks. But as I said when we select 2 not define specific hosts and it should apply on all hosts and VMS so this part should be change such as this when select 2 :

Get-Cluster -Name $clusterName | Get-VM |
ForEach-Object -Process {
New-AdvancedSetting -Entity $_ -Name log.keepOld -Value '10' -Confirm:$false -Force
New-AdvancedSetting -Entity $_ -Name RemoteDisplay.maxConnections -Value '1' -Confirm:$false -Force
New-AdvancedSetting -Entity $_ -Name log.rotateSize -Value '2048000' -Confirm:$false -Force

 

Also I have resided that script here as I got error Would you please check it in your env ?

 

"Please choose an Option to apply security configurations:"
"1- Select Host"
"2- Apply on All ESXi Host"

$options= Read-Host "Enter your Number 1/2"
if ( 1 -eq $options )
{

$hostname= read-host "Please enter your hostname"

Write-Output "esxi-7.account-auto-unlock-time" 

Get-VMHost $hostname | Get-AdvancedSetting Security.AccountUnlockTime | Set-AdvancedSetting -Value 900 -Confirm:$false -Force

 


Get-Cluster -Name $clusterName | Get-VM |
ForEach-Object -Process {
Get-VMHost $hostname | New-AdvancedSetting -Entity $_ -Name log.keepOld -Value '10' -Confirm:$false -Force
Get-VMHost $hostname | New-AdvancedSetting -Entity $_ -Name RemoteDisplay.maxConnections -Value '1' -Confirm:$false -Force
Get-VMHost $hostname | New-AdvancedSetting -Entity $_ -Name log.rotateSize -Value '2048000' -Confirm:$false -Force

}}
if
( 2 -eq $options )
{
Write-Output "6- esxi-7.account-auto-unlock-time" | Green
Get-VMHost | Get-AdvancedSetting Security.AccountUnlockTime | Set-AdvancedSetting -Value 900

Get-Cluster -Name $clusterName | Get-VM |
ForEach-Object -Process {
New-AdvancedSetting -Entity $_ -Name log.keepOld -Value '10' -Confirm:$false -Force
New-AdvancedSetting -Entity $_ -Name RemoteDisplay.maxConnections -Value '1' -Confirm:$false -Force
New-AdvancedSetting -Entity $_ -Name log.rotateSize -Value '2048000' -Confirm:$false -Force

}}
else {
Write-Output "Insert correct number" 

Please mark helpful or correct if my answer resolved your issue.
Reply
0 Kudos