Saturday, 31 May 2008

How can i view Active Directory Schema

I want to view the Active directory Schema on my windows 2003 domain controller.

go to start - run
type regsvr32 schmmgmt.dll
press return

run mmc.exe, select the snap-in Active Directory Schema.
There you go.
-Ghanshyam Prakash

VBScript to add AD group to local machine

I wanted to add a domain group to a list of windows 2003 virtual machines that i built on the production environment attached to a domain, after googling found some sample script which i modified to get the below script….thanx MS

‘ghanshyam

Dim DomainName
Dim UserAccount
Dim GroupName
DomainName = “sales.Example.ORG”
UserAccount = “userAccount”
GroupName = “groupname”
On Error

Set objShell = CreateObject(”WScript.Shell”)
Set objFSORead1 = CreateObject(”Scripting.FileSystemObject”)
Set objDictionary1 = CreateObject(”Scripting.Dictionary”)
Set objFSORead2 = CreateObject(”Scripting.FileSystemObject”)
Set objDictionary2 = CreateObject(”Scripting.Dictionary”)
Const ForReading = 1
Set objFile1 = objFSORead1.OpenTextFile (”c:\adduserserverlist.txt”, ForReading)
i = 0
Do Until objFile1.AtEndOfStream
strNextLine1 = objFile1.Readline
If strNextLine1 <> “” Then
objDictionary1.Add i, strNextLine1
End If
i = i + 1
Loop
objFile1.Close
For Each strLine1 In objDictionary1.Items
set group = GetObject(”WinNT://”& StrLine1 &”/Remote Desktop Users”)
group.Add “WinNT://”& DomainName &”/”& GroupName &”"
CheckError
Next
Sub CheckError
if not err.number=0 then
set ole = CreateObject(”ole.err”)
WScript.Echo ole.oleError(err.Number), vbCritical
err.clear
else
WScript.Echo “Done.”
end if
end Sub

-Ghanshyam Prakash

Adding Computers to domain

you know the saying there are multiple solutions to a given problem and simpler the better, how about doing it the dos way, simple and easy, found this simple way creating computer object in Active Directory.

FOR /F “tokens=*” %%a in (server.txt) do dsadd computer cn=%%a,ou=”New Computer”,ou=Maintenance,ou=new computer,dc=contoso,dc=org -desc “Reserved for new Project - “
pause