Doc,I think this is a more concise list -
ADSI FAQ
Here are these converted over.
Adding a User to a Group with ADSI
code:
$DomainString = "DomainName"
$UserString = "jdoe"
$GroupString = "GroupName"
$GroupObj = GetObject("WinNT://" + $DomainString + "/" + $GroupString)
$GroupObj.Add ("WinNT://" + $DomainString + "/" + $UserString)
$DomainObj = ""
$GroupObj = ""
Adding a Domain User to a Group with ADSI
code:
$PdcName = "ComputerName"
$ComputerName = "ComputerName"
$UserString = "jdoe"
$GroupString = "GroupName"
$GroupObj = GetObject("WinNT://" + $ComputerName + "/" $ $GroupString)$GroupObj.Add ("WinNT://" + PdcName + "/" + UserString)
$DomainObj = ""
$GroupObj = ""
Changing passwords with ADSI
code:
$UserObj = GetObject("WinNT://ComputerName/UserName")
$UserObj.ChangePassword "oldpassword", "newpassword"
$UserObj.SetInfo
$UserObj = ""
Changing a User's Description with ADSI
code:
$UserObj = GetObject("WinNT://ComputerName/UserName")
$UserObj.Description = "New Description"
$UserObj.SetInfo
$UserObj = ""
Confirming a Password Change with ADSI
code:
On @Error Resume Next$UserObj = GetObject("WinNT://ComputerName/UserName")
$UserObj.ChangePassword "oldpassword", "newpassword"
$UserObj.SetInfo
$UserObj = ""
If @Error = 0
? "Password Change Failed"
Else
? "Password Change Was Successful"
Endif
Creating a Share with ADSI
code:
$FservObj = GetObject("WinNT://ComputerName/lanmanserver")$newshare = $FservObj.create("fileshare","test")
$newshare.path = "C:\temp"
$newshare.setinfo
$newshare = ""
Creating a User with ADSI
code:
$DomainObj = GetObject("WinNT://Domain")
$UserObj = $DomainObj.Create("user", "jdoe")
$UserObj.SetInfo
$UserObj = ""
Deleting a Group from a Domain
code:
$DomainString = "Domain"
$GroupString = "Group"
$DomainObj = GetObject("WinNT://" + $DomainString)
$DomainObj.Delete("group", $GroupString)
$DomainObj = ""
Delete a Share using ADSI
code:
$fserv = GetObject("WinNT://ComputerName/lanmanserver")
$fserv.delete "fileshare","test"
Deleting a User from a Domain with ADSI
code:
$DomainString = "Domain"
$UserString = "jdoe"
$DomainObj = GetObject("WinNT://" + $DomainString)
$DomainObj.Delete("user", $UserString)
$DomainObj = ""
Disabling an Account with ADSI
code:
$UserObj = GetObject("WinNT://ComputerName/UserName")
$UserObj.AccountDisabled = "True"
$UserObj.SetInfo
$UserObj = ""
Displaying Domains with ADSI
code:
$NameSpaceObj = GetObject("WinNT:")
$NameSpaceObj.Filter = Array("domain")For Each $DomObj in $NameSpaceObj
?$DomObj.Name + "," + $DomObj.Class
next
Displaying Groups with ADSI
code:
$DomainString = "DOMAINNAME"
$DomainObj = GetObject("WinNT://" + $DomainString)
$DomainObj.Filter = Array("group") For Each $GroupObj In $DomainObj
If $GroupObj.Class = "Group"
$List = $List + $GroupObj.Name
EndIf
Next
? List
$DomainObj = ""
$GroupObj = ""
Displaying Groups of a User with ADSI
code:
$DomainString="ComputerName"
$UserString = "jdoe"$UserObj = GetObject("WinNT://" + $DomainString + "/" + $UserString)
For $Each GroupObj In $UserObj.Groups
$List = $List + $GroupObj.Name
Next
? $List
$UserObj = ""
$GroupObj = ""
Getting the Users of a Group
code:
$DomainString="ComputerName"
$GroupString = "GroupName"
$GroupObj = GetObject("WinNT://" + $DomainString + "/" + $GroupString)
For each $UserObj in $GroupObj.Members
$List = $List + $UserObj.Name
Next
? $List
Renaming a user/b]
code:
$oDomain = GetObject("WINNT:\\DOMAIN")
$oUser = $oDomain.GetObject("user", "Logon ID")
$oDomain.MoveHere $oUser.AdsPath, "New Logon ID"
[b]Setting a User's Account Expiration with ADSI/b]
code:
$UserObj = GetObject("WinNT://ComputerName/UserName")
$UserObj.AccountExpirationDate = @DATE + " " + @TIME
$UserObj.SetInfo
$UserObj = ""
[b]Setting a User's Home Directory with ADSI
code:
$UserObj = GetObject("WinNT://ComputerName/UserName")
$UserObj.put "HomeDirectory", "Directory Path"
$UserObj.put "HomeDirDrive", "H:"
$UserObj.SetInfo
$UserObj = ""
Setting Password Expiration with ADSI
code:
$UserObj = GetObject("WinNT://ComputerName/UserName")
$UserObj.Put "PasswordExpired", "1"
$UserObj.SetInfo
$UserObj = ""
Setting a Required Password with ADSI
code:
$UserObj = GetObject("WinNT://ComputerName/UserName")
$UserObj.PasswordRequired = "True"
$UserObj.SetInfo
$UserObj = ""
Setting a User's Login Script with ADSI
code:
$UserObj = GetObject("WinNT://ComputerName/UserName")
$UserObj.LoginScript = "Login script file name"
$UserObj.SetInfo
$UserObj = ""
Setting a User's Full Name with ADSI
code:
$UserObj = GetObject("WinNT://ComputerName/UserName")
$UserObj.FullName = "John Doe"
$UserObj.SetInfo
$UserObj = ""
Setting a User's Profile with ADSI
code:
$UserObj = GetObject("WinNT://ComputerName/UserName")
$UserObj.Profile = "New Profile Path"
$UserObj.SetInfo
$UserObj = ""
Starting an NT service
How do I start the browser service using ADSI?
code:
$BrowserServiceObj = GetObject("WinNT://ComputerName/browser")
$BrowserServiceObj.start
$BrowserServiceObj = ""
Stopping an NT serviceb
How do I stop the messenger service using ADSI?
code:
$MessengerServiceObj = GetObject("WinNT://ComputerName/messenger")
$MessengerServiceObj.stop
$MessengerServiceObj = ""
Realizing there are more on the page referenced above, these should be pretty easy to convert over to KIX.
Not really into ADSI, well here are some for WMI FAQ.
Thanks!
- Kent
[ 24 February 2002: Message edited by: kdyer ]