ADSIClient

This class provides the functions what use ADSI.

Methods:
ADSIClient.AddLocalUser($localuserid, $password)
ADSIClient.AddLocalUserToGroup($groupname, $localuserid)
ADSIClient.DisableLocalUser($localuserid)
ADSIClient.EnableLocalUser($localuserid)
ADSIClient.GetLocalGroupNames()
ADSIClient.GetLocalUserNames()
ADSIClient.GetMemberOf($groupname)
ADSIClient.Initialize($computername)
ADSIClient.InterpretUserFlags($localuserid)
ADSIClient.RemoveLocalUser($localuserid)
ADSIClient.RemoveLocalUserFromGroup($groupname, $localuserid)
ADSIClient.SetLocalUserPassword($localuserid, $password)

ex)
#new ADSIClient
$adsic = new ADSIClient;
#initialize
$adsic = $adsic.Initialize($env:computername);
#see local groups
$adsic.GetLocalGroupNames();

#see local users
$adsic.GetLocalUserNames();

#make a local user
$username = "testuser";
$adsic.AddLocalUser($username, "P@ssw0rd");
$adsic.SetLocalUserPassword($username, "P@ssw0rd!");

#check result
$adsic.GetLocalUserNames();

#see user flags
$adsic.InterpretUserFlags($username);

#disable a local user
$adsic.DisableLocalUser($username);

#check disabled user
$adsic.InterpretUserFlags($username);

#enable a local user
$adsic.EnableLocalUser($username);

#check enabled user
$adsic.InterpretUserFlags($username);

#list member of Administrators
$adsic.GetMemberOf("Administrators");

#add a local user to administrators
$adsic.AddLocalUserToGroup("Administrators", $username);

#check member of Administrators
$adsic.GetMemberOf("Administrators");

#remove a local user to administrators
$adsic.RemoveLocalUserFromGroup("Administrators", $username);

#check member of Administrators
$adsic.GetMemberOf("Administrators");

#remove a local user
$adsic.RemoveLocalUser($username);

#check result
$adsic.GetLocalUserNames();

Last edited Mar 2, 2013 at 11:45 AM by Tom__S, version 6

Comments

No comments yet.