Useful Administration Commands

What groups is this user a member of?

dsquery user -samid loginname | dsget user -memberof -expand

When did someone last change his password?

net user loginname /domain | find /I "password last set"

Is someone's account locked?

net user loginname /domain | find /I "account active"

List all domains and workgroups in the network

net view /domain

List all computers in the network

net view

List all domain controllers

nltest /dclist:contoso.com

netdom query dc /domain:domainname

List all member servers

netdom query server /domain:domainname

List all local administrators

net localgroup Administrators

List all ldap servers in domain

nslookup -type=srv _ldap._tcp.DOMAINNAME

Server not pinging

netsh firewall set icmpsetting 8

Remotely start terminal service

sc \\servername start termservice

Remotely check who is logged in to the server

query user /server:servername

quser /server:servername

qwinsta /server:servername

Log off remote users

logoff /server:servername id /v

Remotely reboot or shutdown a server

shutdown /i

shutdown /r /f /t 0 /m \\servername /c "Description"

List all users in a specific group (powershell)

import-module activedirectory

get-adgroupmember "domain admns" -recursive | select-object name

Check from which DC it's authenticating

set logon

echo %logonserver%

Restart Management Agents in ESXi

services.sh restart

Get NIC list and index number:

wmic nic get name, index

Enable NIC with index number: (eg: 7)

wmic path win32_networkadapter where index=7 call enable

Disable NIC with index number: (eg: 7)

wmic path win32_networkadapter where index=7 call disable

Get SID of any user

wmic useraccount where name='username' get sid

Comments