I'm trying to write a script where I ensure that local user accounts are set with the proper configurations. I can access all of the properties, but I'm getting error messages every time I try to modify them.
When I try to run the following code:
$Computername = $env:COMPUTERNAME
$adsi = [ADSI]"WinNT://$Computername"
$Users = $adsi.Children | where {$_.SchemaClassName -eq 'user'}
$Users[0].MinPasswordLength.value #This returns the minimum password length just fine
$Users[0].MinPasswordLength.value = 8
$Users[0].SetInfo()
I get the following error message:
Exception setting "value": "Exception from HRESULT: 0x80000500F"
Any ideas as to why this fails?