Link to home
Start Free TrialLog in
Avatar of jmateknik
jmateknikFlag for Denmark

asked on

Powershell-script: Modify of local(non-AD)-user accounts

I am looking for an [adsi]("WinNT://./$strUser, user") --> psbase.invoke("?","?") command for enabling 'Password never expires' and 'User cannot change password'.

I have succesfully build a script that changes passwords according to an CSV-file - see attached script, and now imagine adding two lines of code doing the job.

Help is greatly appreciated...
{
    $ImportUserListPath = "E:\Anders\JmaWebUserNamesPasswords.csv"

    $users = Import-Csv $ImportUserListPath
    Foreach ($user in $users)
    {

    $strUser = $User.username
    $strPWD = $User.Password
    $strUser
    $LocalUser =[adsi]("WinNT://./$strUser, user")
    $LocalUser.psbase.invoke("SetPassword", $strPWD)
    # Password never expires: $LocalUser.psbase.invoke( ??? )
    # User cannot change password: $LocalUser.psbase.invoke( ??? )
    }
}

setPasswordFromCSV

Open in new window

Avatar of NJComputerNetworks
NJComputerNetworks
Flag of United States of America image

Avatar of KingR
KingR

QAD can only be used for AD accounts, not local.

I haven't tried this myself, but both these entries are userflags so you should be able to set the value of the userflag for the account. A good list of the values (which you simply add together) is at http://www.motobit.com/help/usrmgr/cl16.htm
ASKER CERTIFIED SOLUTION
Avatar of Chris Dent
Chris Dent
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of jmateknik

ASKER

I Humbly thanks for the joy that this script has spread - exellent! :)