Day to Day CMDs for Active Directory Directory Service

1. How to find which domain contoller the Client work station/Server is connected.
open command prompt (cmd.exe)
CMD>> echo %logonserver%


2. How the check the FSMO roles of the connected domain
open command prompt (cmd.exe)
CMD>> netdom query FSMO


3. NTP Troubleshoot:
check the status of NTP in local server
CMD> w32tm /query /status


Check weather server/DC able to get time from respective NTP Server
CMD> w32tm /stripchart /computer:<NTP Server Name>


After you update the NTP setting in local GPO, run below command to update the settings.
CMD> w32tm.exe /config /update


Stop the Time service on local server
CMD> net stop w32time


Start the Time service on local server
CMD> net start w32time


4. How to find the LDAP protocal port number
Open Cmd Prompt & Type below cmds
CMD> nslookup
CMD> set type=1
CMD> _ldap._tcp.dc._msdcs.domainname.com


5. View Local System GPO Settings
Open Run>> RSOP.msc
(or)
CMD> gpresults /R
CMD> gpresults /SCOPE COMPUTER /R


6. How to Check and Release the inactive session on a remote server
//to list all session
CMD> qwinsta /server:<RemoteServerName>
(or)
CMD> quser /server:<RemoteServerName>

//to close inactive session (you will get session id when you list the session on server using above cmd)
CMD>>rwinsta <SessionID> /server:<ServerName>
(or)
logoff <SessionID> /server:<RemoteServername>


7. How to Update the GPO Setting Forcefully on local machine
CMD> gpupdate /force

8. How to Get Local Computer Name
CMD> echo %computername%
or
CMD> hostname


9. How to Rename remote Computer (recommemded to restart the computer after name change).
CMD> netdom renamecomputer <RemoteComputerName/LocalComputerName> /NewName:<NewComputerName>


10. How to List all interface Details
CMD> netsh interface IPv4 show interfaces


11. How to set IP for an IPv4 interface
CMD> netsh interface IPv4 set address name=<Idx Number> source=static address=<xxx.xxx.xxx.xxx> mask=<xxx.xxx.xxx.xxx> gateway=<xxx.xxx.xxx.xxx>


12. How to set IP for an IPv6 interface
CMD> netsh interface IPv6 set address interface=<Idx Number> address=<ex:fd00:0:0:1::2>


13. How to set DNS server
CMD> netsh interface IPv4 add dnsserver name=<Idx Number> address=<DNS address x.x.x.x> index=1


14. How to Set loopback connection
CMD> netsh interface IPv4 add dnsserver name=<Idx Number> address=<DNS address 127.0.0.1> index=2


15. How to list of Roles & Features Installed on Windows Server
CMD> oclist | more


16. How to Run a role in AD
CMD> start /w ocsetup DNS-Server-Core-Role
(/W -  will wait until the window is complete)


17. How to Reboot the machine through Cli
CMD> shutdown /r /t 2


18. how to Check all IP Details
CMD> ipconfig /all | more


19. How to connect the network drive
CMD> net use * \\NetworkShareLocation


20. How to Copy file to local directory
CMD> copy <sourcefile> <targetfile>


21. How to Open a file in notepad
CMD> notepad <filelocation>


22. How to Promoting Domain Controller using answer file
>>dcpromo /unattend:<filelocation>.txt


How to Promoting Domain Controller using cmd
>>dcpromo /replicationOrnewDomain:replica /replicationDomainDNSName:<domain.local> /ConfirmGC:yes /userdomain:<domain.local> /UserName=administrator /Password=<PSW> /SafeModeAdminPassword=<PSW>

###KB Articals###
//fill list of DC Promo settings
http://support.microsoft.com/kb/947034


23. How to LDF file Export Group users Information.
CMD> ldifde -f C:\Temp\Exportuser.ldf -server <DomainName> -r "(&(objectClass=User)(DC=XXXX,DC=XXXX,DC=com))" -l "sAMAccountName,givenName,sn"


24. How to Generate KeyTab File
CMD> ktpass /out <FileName>.keytab /princ <UserName>@<Domain> /pass <password> /ptype KRB5_NT_PRINCIPAL /out username.keytab



##########PowerShell CMDs##################
Note: To Run the below cmds, you should have powershell installed and imported the Active Directory Module (CMD to Import Active Directory Module: PS>>Import-Module ActiveDirectory)


Powershell Cmd: How to Check Schema Version
PS> Get-ADObject "cn=schema,cn=configuration,dc=XXXXX,dc=COM" -properties objectversion


Powershell Cmd: How to find Account Name using SID
PS> $objSID = New-Object System.Security.Principal.SecurityIdentifier ("S-1-5-21-XXXXXXXXXX-XXXXXXXXXX-XXXXXXXXX-XXXXXX")
$objUser = $objSID.Translate( [System.Security.Principal.NTAccount])
$objUser.Value


Powershell Cmd: How to export all OU info to Excel Sheet
PS> Get-ADOrganizationalUnit -server <DomainName> -Filter '*' -properties * | Select CanonicalName,DistinguishedName | export-csv "<FilePath>.csv"


Powershell Cmd: How to set the user should change password at next logon
PS> Set-ADUser -Identity "<AD ID/User Name>" -ChangePasswordAtLogon $true -server <DomainName>


Powershell Cmd: How to set the user account to expire on specific timestamp
PS> Set-ADAccountExpiration -Identity "<AD ID/User Name>" -DateTime '<TimeStamp ex: 1/19/2017 12:01:37 PM>' -server <DomainName>


Powershell Cmd: How to get AD User password last change, account expire date & last password change time.
Get-ADUser -Identity "<AD ID/User Name>"  -server <DomainName> -Properties AccountExpirationDate | Select-Object -Property SamAccountName, AccountExpirationDate, PasswordLastSet
if you installed "ActiveRoles Management shell for Active Directory"
PS> get-qaduser <Domain>\<AD ID> -properties *  | select pwdlastset, passwordexpires


Powershell Cmd: How create a AD Group in 'ActiveRoles Management shell for Active Directory'
PS> New-QADGroup -GroupScope <Universal -GroupType Security -Name '<New_AD_GroupName>' -samAccountName <New_AD_GroupName>' -Description '<Purpose of The Group>' -ParentContainer '<ex:OU=Groups,DC=XX,DC=XXXXX,DC=com>' -ManagedBy <Domain>\<Owner>


Powershell Cmd: How to get user group memberof info in 'ActiveRoles Management shell for Active Directory'
PS> Get-QADMemberOf <UserName> | select name


Powershell Cmd: how to see the powershell cmdlet syntax
PS> Get-Help Set-ADUser –detailed

No comments:

Post a Comment