Quantcast
Channel: Windows PowerShell forum
Viewing all articles
Browse latest Browse all 21975

Unable to set user account properties

$
0
0

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?




Viewing all articles
Browse latest Browse all 21975

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>