Thursday, December 3, 2009

AD Command's

FSMO Roles ntdsutilroles Connections "Connect to server %logonserver%" Quit "selectOperation Target" "List roles for conn server" Quit Quit Quit[JDH: This is really a series of steps, not a single commandexpression]
Domain Controllers Nltest /dclist:%userdnsdomain%
Domain Controller IP Configuration for /f %i in (’dsquery server -domain %userdnsdomain% -o rdn’) do psexec \\%i ipconfig /all
Stale computer accounts dsquery computer domainroot -stalepwd 180 -limit 0
Stale user accounts dsquery user domainroot -stalepwd 180 -limit 0
Disabled user accounts dsquery user domainroot -disabled -limit 0
AD Database disk usage for /f %i in (’dsquery server -domain %userdnsdomain% -o rdn’) do dir \\%i\admin$\ntds
Global Catalog Servers from DNS dnscmd %logonserver% /enumrecords %userdnsdomain% _tcp find /i "3268"
Global Catalog Servers from AD dsquery * "CN=Configuration,DC=forestRootDomain" -filter
"(&(objectCategory=nTDSDSA)(options:1.2.840.113556.1.4.803:=1))"Users with no logon script dsquery * domainroot -filter"(&(objectCategory=Person)(objectClass=User)(!scriptPath=*))"-limit 0 -attr sAMAccountName sn givenName pwdLastSet distinguishedName
User accounts with no pwd required dsquery * domainroot -filter "(&(objectCategory=Person)(objectClass=User)(userAccountControl:1.2.840.113556.1.4.803:=32))"
User accounts with no pwd expiry dsquery * domainroot -filter"(&(objectCategory=Person)(objectClass=User)(userAccountControl:1.2.840.113556.1.4.803:=65536))"
User accounts that are disabled dsquery * domainroot -filter "(&(objectCategory=Person)(objectClass=User)(userAccountControl:1.2.840.113556.1.4.803:=2))"
DNS Information for /f %i in (’dsquery server -domain %userdnsdomain% -o rdn’) do dnscmd %i /info
DNS Zone Detailed information dnscmd /zoneinfo %userdnsdomain%
Garbage Collection and tombstone dsquery * "cn=Directory Service,cn=WindowsNT,cn=Services,cn=Configuration,DC=forestRootDomain" -attrgarbageCollPeriod tombstoneLifetime
Netsh authorised DHCP Servers netsh dhcp show server
DSQuery authorised DHCP Servers Dsquery * "cn=NetServices,cn=Services,cn=Configuration, DC=forestRootDomain" -attr dhcpServers
DHCP server information netsh dhcp server \\DHCP_SERVER show all
DHCP server dump netsh dhcp server \\DHCP_SERVER dumpWINS serer information Netsh wins server \\WINS_SERVER dump
Group Policy Verification Tool gpotool.exe /checkacl /verbose
AD OU membership dsquery computer -limit 0
AD OU membership dsquery user -limit 0
List Service Principal Names for /f %i in (’dsquery server -domain %userdnsdomain% -o rdn’) do setspn -L %i
Compare DC Replica Object Count dsastat ?s:DC1;DC2;… ?b:Domain ?gcattrs:objectclass ?p:999
Check AD ACLs acldiag dc=domainTree
NTFRS Replica Sets for /f %i in (’dsquery server -domain %userdnsdomain% -o rdn’) do ntfrsutl sets %i
NTFRS DS View for /f %i in (’dsquery server -domain %userdnsdomain% -o rdn’) do ntfrsutl ds %i
Domain Controllers per site Dsquery * "CN=Sites,CN=Configuration,DC=forestRootDomain" -filter (objectCategory=Server)
DNS Zones in AD for /f %i in (’dsquery server -o rdn’) do Dsquery * -s %i domainroot -filter (objectCategory=dnsZone)
Enumerate DNS Server Zones for /f %i in (’dsquery server -o rdn’) do dnscmd %i /enumzones
Subnet information Dsquery subnet ?limit 0
List Organisational Units Dsquery OU
ACL on all OUs For /f "delims=" %i in (’dsquery OU’) do acldiag %i
Domain Trusts nltest /domain_trusts /v
Print DNS Zones dnscmd DNSServer /zoneprint DNSZone
Active DHCP leases For /f %i in (DHCPServers.txt) do for /f "delims=- " %j in (’"netshdhcp server \\%i show scope find /i "active""’) do netsh dhcp server\\%i scope %j show clientsv5
DHCP Server Active Scope Info For /f %i in (DHCPServers.txt) do netsh dhcp server \\%i show scope find /i "active"
Resolve DHCP clients hostnames for /f "tokens=1,2,3 delims=," %i in (Output from ‘Find Subnets fromDHCP clients’) do @for /f "tokens=2 delims=: " %m in (’"nslookup %j find /i "Name:""’) do echo %m,%j,%k,%i
Find two online PCs per subnet Echo. > TwoClientsPerSubnet.txt & for /f "tokens=1,2,3,4delims=, " %i in (’"find /i "pc" ‘Output from Resolve DHCP clientshostnames’"’) do for /f "tokens=3 skip=1 delims=: " %m in (’"Find /i /c"%l" TwoClientsPerSubnet.txt"’) do If %m LEQ 1 for /f %p in (’"ping -n1 %i find /i /c "(0% loss""’) do If %p==1 Echo %i,%j,%k,%l
AD Subnet and Site Information dsquery * "CN=Subnets,CN=Sites,CN=Configuration,DC=forestRootDomain" -attr cn siteObject description location
AD Site Information dsquery * "CN=Sites,CN=Configuration,DC=forestRootDomain" -attr cn description location -filter (objectClass=site)
Printer Queue Objects in AD dsquery * domainroot -filter "(objectCategory=printQueue)" -limit 0
Group Membership with user details dsget group "groupDN" -members dsget user -samid -fn -mi -ln -display -empid -desc -office -tel -email -title -dept -mgr
Total DHCP Scopes find /i "subnet" "Output from DHCP server information" find /i "subnet"
Site Links and Cost dsquery * "CN=Sites,CN=Configuration,DC=forestRootDomain" -attr cn costdescription replInterval siteList -filter (objectClass=siteLink)
Time gpresult timethis gpresult /v
Check time against Domain w32tm /monitor /computers:ForestRootPDC
Domain Controller Diagnostics dcdiag /s:%logonserver% /v /e /c
Domain Replication Bridgeheads repadmin /bridgeheads
Replication Failures from KCC repadmin /failcacheInter-site Topology servers per site Repadmin /istg * /verbose
Replication latency repadmin /latency /verbose
Queued replication requests repadmin /queue *
Show connections for a DC repadmin /showconn *
Replication summary Repadmin /replsummary
Show replication partners repadmin /showrepl * /all
All DCs in the forest repadmin /viewlist *
ISTG from AD attributes dsquery * "CN=NTDS Site Settings,CN=siteName,CN=Sites,CN=Configuration,DC=forestRootDomain" -attr interSiteTopologyGenerator
Return the object if KCC Intra/Inter site is disabled for each site Dsquery site dsquery * -attr * -filter "((Options:1.2.840.113556.1.4.803:=1)(Options:1.2.840.113556.1.4.803:=16))"
Find all connection objects dsquery * forestRoot -filter (objectCategory=nTDSConnection) ?attr distinguishedName fromServer whenCreated displayName
Find all connection schedules adfind -b "cn=Configuration,dc=qraps,dc=com,dc=au" -f "objectcategory=ntdsConnection" cn Schedule -csv
Software Information for each server for /f %i in (Output from ‘Domain Controllers’) do psinfo \\%i &filever \\%i\admin$\explorer.exe \\%i\admin$\system32\vbscript.dll\\%i\admin$\system32\kernel32.dll \\%i\admin$\system32\wbem\winmgmt.exe\\%i\admin$\system32\oleaut32.dllCheck Terminal Services Delete Temp on Exit flag For /f %i in (Output from ‘Domain Controllers’) do Reg query"\\%i\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\TerminalServer" /v DeleteTempDirsOnExit
For each XP workstation, query the current site and what Group Policy info @dsquery * domainroot -filter"(&(objectCategory=Computer)(operatingSystem=Windows XPProfessional))" -limit 0 -attr cn > Workstations.txt & @For /f%i in (Workstations.txt) do @ping %i -n 1 >NUL & @if ErrorLevel0 If NOT ErrorLevel 1 @Echo %i & for /f "tokens=3" %k in (’"regquery "\\%i\hklm\software\microsoft\windows\currentversion\grouppolicy\history" /v DCName Find /i "DCName""’) do @for /f %m in(’"nltest /server:%i /dsgetsite find /i /v "completedsuccessfully""’) do @echo %i,%k,%m
Information on existing GPOs dsquery * "CN=Policies,CN=System,domainRoot" -filter"(objectCategory=groupPolicyContainer)" -attr displayName cnwhenCreated gPCFileSysPath
Copy all Group Policy .pol files for /f "tokens=1-8 delims=\" %i in (’dir /b /s\\%userdnsdomain%\sysvol\%userdnsdomain%\policies\*.pol’) do @echo copy\\%i\%j\%k\%l\%m\%n\%o %m_%n.pol
Domain Controller Netlogon entries for /f %i in (’dsquery server /o rdn’) do echo %i & reg query\\%i\hklm\system\currentcontrolset\services\netlogon\parameters
WINS Statistics for /f "tokens=1,2 delims=," %i in (WINSServers.txt) do netsh wins server \\%i show statistics
WINS Record counts per server for /f "tokens=1,2 delims=," %i in (WINSServers.txt) do netsh wins server \\%i show reccount %iWINS Server Information for /f "tokens=2 delims=," %i in (WINSServers.txt) do netsh wins server \\%i show info
WINS Server Dump for /f "tokens=2 delims=," %i in (WINSServers.txt) do netsh wins server \\%i dump
WINS Static Records per Server netsh wins server \\LocalWINSServer show database servers={} rectype=1
Find policy display name given the GUID dsquery * "CN=Policies,CN=System,DC=domainRoot" -filter (objectCategory=groupPolicyContainer) -attr Name displayName
Find empty groups dsquery * -filter "&(objectCategory=group)(!member=*)" -limit 0-attr whenCreated whenChanged groupType sAMAccountNamedistinguishedName memberOf
Find remote NIC bandwidth wmic /node:%server% path Win32_PerfRawData_Tcpip_NetworkInterface GET Name,CurrentBandwidth
Find remote free physical memory wmic /node:%Computer% path Win32_OperatingSystem GET FreePhysicalMemory
Find remote system information SystemInfo /s %Computer%
Disk statistics, including the number of files on the filesystem chkdsk /i /c
Query IIS web sites iisweb /s %Server% /query "Default Web Site"
Check port state and connectivity portqry -n %server% -e %endpoint% -v
Forest/Domain Functional Levels ldifde -d cn=partitions,cn=configuration,dc=%domain% -r"((systemFlags=3)(systemFlags=-2147483648))" -lmsds-behavior-version,dnsroot,ntmixeddomain,NetBIOSName -p subtree -fcon
Forest/Domain Functional Levels dsquery * cn=partitions,cn=configuration,dc=%domain% -filter"((systemFlags=3)(systemFlags=-2147483648))" -attrmsDS-Behavior-Version Name dnsroot ntmixeddomain NetBIOSName
Find the parent of a process wmic path Win32_Process WHERE Name=’notepad.exe’ GET Name,ParentProcessId
Lookup SRV records from DNS nslookup -type=srv _ldap._tcp.dc._msdcs.{domainRoot}
Find when the AD was installed dsquery * cn=configuration,DC=forestRootDomain -attr whencreated -scope base
Enumerate the trusts from the specified domain dsquery * "CN=System,DC=domainRoot" -filter "(objectClass=trustedDomain)" -attr trustPartner flatName
Find a DC for each trusted domain for /f "skip=1" %i in (’"dsquery * CN=System,DC=domainRoot -filter(objectClass=trustedDomain) -attr trustPartner"’) do nltest /dsgetdc:%i
Check the notification packages installed on all DCs for /f %i in (’dsquery server /o rdn’) do @for /f "tokens=4" %m in(’"reg query\\%i\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Lsa /v"Notification Packages" find /i "Notification""’) do @echo %i,%m
List ACLs in SDDL format setacl -on %filepath% -ot file -actn list -lst f:sddl
Find out if a user account is currently enabled or disabled dsquery user DC=%userdnsdomain:.=,DC=% -name %username% dsget user -disabled -dn
Find servers in the domain dsquery * domainroot -filter "(&(objectCategory=Computer)(objectClass=Computer)(operatingSystem=*Server*))" -limit 0
Open DS query window rundll32 dsquery,OpenQueryWindow

Monday, July 27, 2009

SRV Records

A quick tip to verify the SRV records of the Active Directory
SRV records play an important role for domain controllers in the Active Directory domain. It is not possible for a client computer, for a service, and for an application to know the location of a domain controller without the SRV records. Client computers (Winlogon Service) always query DNS Server to find the IP Address of the domain controller. You can follow the simple steps to ensure SRV records of a domain controller are registered in the DNS Server:
Method 1: Using NSLOOKUP Command
Steps:
Open Command Prompt
Type NSLOOKUP and hit enter
Type Set Type=all and press enter
At NSLOOKUP prompt, type _LDAP._TCP.DC.MSDCS.Domain_Name.com and hit enter.
The above query to the DNS Server will return all the domain controllers in the domain name Domain_Name.com.
Method 2: Using Ping Command:
You can also use the Ping Utility to verify the existence of a host or SRV Record in DNS Server. You need to know the exact location of the SRV records. As an example, if you ping the above SRV record, the ping will return the IP Address for one of the domain controllers in the domain.

Sunday, June 14, 2009

To customize the Windows 7 logon screen

  • To set a custom picture, place a JPG named backgroundDefault.jpg in the %windir%\system32\oobe\info\backgrounds folder.
  • Now go to the registry and navigate to HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Authentication\LogonUI\Background. There should be a DWORD value named OEMBackground (create it if it's missing).
  • Set the value to 1 and click OK.
    Now when you log off or switch users the new background picture will be displayed.
  • Note: No reboot is necessary.
    You can also place custom files in the backgrounds folder with the name background to have different pictures for different resolutions. For example, a 1024×768 resolution picture should be save as background1024x768.jpg.

Saturday, June 13, 2009

Terminal Services Configuration

Terminal Services Configuration
You can configure new connections for Terminal Services, modify the settings of existing connections, and delete connections by using the Terminal Services Configuration tool (TSCC.msc) or Group Policy (gpedit.msc)

To specify a maximum number of sessions that can connect to the server
Using Group Policies (best practice)
Using Terminal Services Configuration
Using Group Policies (best practice)
Open Group Policy.
In Computer Configuration, Administrative Templates, Windows Components, Terminal Services, double-click the Limit number of connections setting, and then click Enabled.
In the TS Maximum Connections allowed box, type the maximum number of connections you want to allow, and then click OK.
Important
You should thoroughly test any changes you make to Group Policy settings before applying them to users or computers. For more information on testing policy settings, see
Resultant Set of Policy.
Note
Use the above procedure to configure the local Group Policy object. To change a policy for a domain or an organizational unit, you must log on to the primary domain controller as an Administrator. Then, you must invoke Group Policy by using the Active Directory Users and Computers snap-in.

Using Terminal Services Configuration
Open Terminal Services Configuration.
In the console tree, click Connections.
In the details pane, right-click the connection for which you want to specify a maximum number of sessions, and then click Properties.
On the Network Adapter tab, click Maximum connections, type the maximum number of sessions that can connect to the server, and then click Apply.
Notes
To open Terminal Services Configuration, click Start, click Control Panel, double-click Administrative Tools, and then double-click Terminal Services Configuration.
To perform this procedure, you must be a member of the Administrators group on the local computer, or you must have been delegated the appropriate authority. If the computer is joined to a domain, members of the Domain Admins group might be able to perform this procedure. As a security best practice, consider using Run as to perform this procedure. For more information, see
Default local groups, Default groups, and Using Run as.
Group Policy overrides the configuration set with the Terminal Services Configuration tool.
By default, the connection is configured to allow an unlimited number of sessions to connect to the server.
Restricting the number of sessions improves performance because fewer sessions are demanding system resources.
Information about functional differences
Your server might function differently based on the version and edition of the operating system that is installed, your account permissions, and your menu settings. For more information, see
Viewing Help on the Web

Sunday, June 7, 2009

Exchange on a cluster – How to configure SAN in VMware.

It brings great pleasure to me to inform you all that I have set up a 3 way exchang ecluster on a SAN in my lab enviornment at EDS. Dont Jump to conclusions yet.The software i want to introduce to you is called starwind. Its available http://www.rocketdivision.com/wind.html
Storage Area Network (SAN) is an architecture to attach remote computer storage devices such as disk array controllers, tape libraries and CD arrays to servers in such a way that to the operating system the devices appear as locally attached devices. Although cost and complexity is dropping, as of 2007, SANs are still uncommon outside larger enterprises.
as defined by Wikipedia. Do browse the
wiki for more details.
I used a 30 day trial of Vmware 6.0, Starwind, and Windows 2003 and Exchange 2003 obviously with SP2.
Here is the deal.
Install windows 2003. set up the NICs atleast 1 for the san box and install the starwind software.
It has a good guide to get you started.do install the iscsi initiator software from from microsoft and test if the volumes bind correct.
Microsoft iSCSI Software Initiator Version 2.04
Install Windows and setup the iscsi initiator software and run it.Read the guide on setting it up.Its actually simple.
1) Go to discovery tab and add the address for the SAN box.
2) On targets tab click logon on each connection if multiple ones are created in SAN.
3) Ensure you select the automatically restore this connection when computer starts check box only.
4) Go to persistent targets tab and click refresh to list the targets.
5) Go to bound volumes/devices to bind the drives.
That's it. Then setup the disks with drive letter and format it. Install the microsoft cluster service and if you did everything right you will have a cluster ready.

Saturday, June 6, 2009

To Change the Administrator / Domain Admin Password in windows 2003 AD

Note: The reason for that is that you need to have the local administrator's password in order to perform the following

Update: After some reader feedback I'm pleased to say that this procedure ALSO WORKS for Windows Server 2008 Domain Controllers. Feel free to send in your feedback. I kept the original page syntax in relation to Windows Server 2003, but you can now perform the same actions on Windows Server 2008.
We Need to following Requirement:
1. Local access to the Domain Controller (DC).
2. The Local Administrator password.
3. Two tools provided by Microsoft in their Resource Kit: SRVANY and INSTSRV. Download them from
HERE (24kb).
Step 1
Restart Windows 2003 in Directory Service Restore Mode.
Note: At startup, press F8 and choose Directory Service Restore Mode. It disables Active Directory. When the login screen appears, log on as Local Administrator. You now have full access to the computer resources, but you cannot make any changes to Active Directory.
Step 2
Now we are going to install SRVANY. This utility can virtually run any programs as a service. The interesting point is that the program will have SYSTEM privileges (LSA) (as it inherits the SRVANY security descriptor), i.e. it will have full access on the system. That is more than enough to reset a Domain Admin password. You will configure SRVANY to start the command prompt (which will run the 'net user' command).
Copy SRVANY and INSTSRV to a temporary folder, mine is called D:'temp. Copy cmd.exe to this folder too (cmd.exe is the command prompt, usually located at %WINDIR%\System32).
Start a command prompt, point to d:\temp (or whatever you call it), and type:
instsrv PassRecovery "d:\temp\srvany.exe"
It is now time to configure SRVANY.
Start Regedit, and navigate to
HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\PassRecovery
Create a new subkey called Parameters and add two new values:
name: Application
type: REG_SZ (string)
value: d:\temp\cmd.exe

name: AppParameters
type: REG_SZ (string)
value: /k net user administrator 123456 /domain
Replace 123456 with the password you want. Keep in my mind that the default domain policy require complex passwords (including digits, respecting a minimal length etc) so unless you've changed the default domain policy use a complex password such as P@ssw0rd
Now open the Services.msc (Control Panel\Administrative Tools\Services) and open the PassRecovery property tab. Check the starting mode is set to Automatic.
Go to the Log On tab and enable the option Allow service to interact with the desktop.
Restart Windows normally, SRVANY will run the NET USER command and reset the domain admin password.
Step 3
Log on with the Administrator's account and the password you've set in step #2.
Use this command prompt to uninstall SRVANY (do not forget to do it!) by typing:
net stop PassRecovery
sc delete PassRecovery
Now delete d:\temp and change the admin password if you fancy.
Done!

Saturday, May 2, 2009

Windows 2008 failure Clustering Videos By John Savill

One of the most useful videos I have found on the internet, for failover clustering. Thanks to John Savill for his efforts and time.
Creating Windows Server 2008 Failover Clusters:
http://www.savilltech.com/Videos/clustercreate/ClusterCreate.wmv
Configuring a Windows Server 2008 Failover Cluster from the command line:
http://www.savilltech.com/Videos/clustercmd/clustercmd.wmv
Understanding Failover Cluster Quorum:
http://www.savilltech.com/Videos/ClusterQuorum/ClusterQuorum.wmv
Hyper-V Quick Migration:
http://www.savilltech.com/Videos/QuickMigration/QuickMigration.wmv
Configuring iSCSI connections from the command line:
http://www.savilltech.com/Videos/iscsicli/iscsicli.wmv
Failover Clustering with MELIO File System:
http://www.savilltech.com/Videos/meliofs/meliofs.wmv