lElOUCHE_79
Enthusiast
Enthusiast

Security Password Quality Control

Jump to solution

I'm trying to set the password policy using PowerCLI unfortunately it's not working and not able to identify where's my mistake

$PassPolicy = "retry=3 disabled,disabled,disabled,disabled,15"
$VMHost = Get-Content -Path ".\Esx-liste.txt" -PipelineVariable ESX |
ForEach-Object -Process {

if ($ESXi.ConnectionState -eq 'Connected') {

Get-AdvancedSetting -Entity $ESXi -Name 'Security.PasswordQualityControl' |
Where-Object{$_Value -ne $PassPolicy} |
Set-AdvancedSetting -Value $PassPolicy -Confirm:$false
}

else {

Write-Error "Node $($ESX.Name) is not connected"
}

}

Tags (1)
0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership

Can you try like this?

$PassPolicy = "retry=3 disabled,disabled,disabled,disabled,15"

Get-VMHost -Name (Get-Content -Path ".\Esx-liste.txt") -PipelineVariable ESX |
ForEach-Object -Process {
    if ($ESX.ConnectionState -eq 'Connected') {
        Get-AdvancedSetting -Entity $ESX -Name 'Security.PasswordQualityControl' |
        Where-Object{$_Value -ne $PassPolicy} |
        Set-AdvancedSetting -Value $PassPolicy -Confirm:$false
    }
    else {
        Write-Error "Node $($ESX.Name) is not connected"
    }
}


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

View solution in original post

2 Replies
LucD
Leadership
Leadership

Can you try like this?

$PassPolicy = "retry=3 disabled,disabled,disabled,disabled,15"

Get-VMHost -Name (Get-Content -Path ".\Esx-liste.txt") -PipelineVariable ESX |
ForEach-Object -Process {
    if ($ESX.ConnectionState -eq 'Connected') {
        Get-AdvancedSetting -Entity $ESX -Name 'Security.PasswordQualityControl' |
        Where-Object{$_Value -ne $PassPolicy} |
        Set-AdvancedSetting -Value $PassPolicy -Confirm:$false
    }
    else {
        Write-Error "Node $($ESX.Name) is not connected"
    }
}


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

View solution in original post

lElOUCHE_79
Enthusiast
Enthusiast

Thank you very much, it's working 🙂 

0 Kudos