Add Active Directory Module to PowerShell:
Import-Module ActiveDirectory

Find Help on Powershell Commands:
Get-Help *
Get-Help <command> -examples

Find Locked Accounts:
search-adaccount -lockedout

Verify if Account is Locked:
get-aduser UserName -properties * | select-object lockedout

Unlock user account:
unlock-adaccount username

Export email addresses from All users in a group
Get-ADGroup "group name" | Get-ADGroupMember -Recursive | Get-ADUser -Properties * | Select SamAccountName,GivenName,sn,Mail | Export-CSV "C:\email.csv"

Get Active Directory user information using Powershell:
  • get-aduser alex    > Will show basic information
    • get-aduser alex -properties  * | select -property *   > Will show advance information
    • get-aduser alex -properties  * | select -property * | out-file c:\alex.txt   > Will export to a file c:\alex.txt
    • get-aduser alex -properties  * | select -property * | Out-GridView -Title > Will display complete results of all fields qureied in a new Powershell Gridview window, where we can filter results
    • get-aduser alex -properties  * | select -property * | Format-Table -Wrap > Display complete results  in a table form
    • get-aduser alex -properties  * | select -property * | Format-List > Display complete results in Rows
    • For More Information View  this third party link 
  • Get-ADUser -LDAPFilter "(!manager=*)" -SearchBase "OU=OUName,DC=DomainName,DC=DotName" -Properties * | select-object name, manager > Find Users without Manager in Active Directory

  • Get-ADUser -Filter * -SearchBase "OU=3, 0U2, OU1, DC=DOMAIN-NAME,DC=DOTDOMAIN" -properties proxyaddresses, emailaddress, msExchRecipientDisplayType, msExchRecipientTypeDetails, msExchRemoteRecipientType, TargetAddress | select Name, ProxyAddresses, EmailAddress, msExchRecipientDisplayType, msExchRecipientTypeDetails, msExchRemoteRecipientType, TargetAddress > Get selected attributes
  • Get-ADUser -Identity alex -Properties Canonicalname > Will find Group and OU Membership
    • Get-ADUser -Filter * -SearchBase "OU=OU_NAME2, OU_NAME1, DC=DOMAIN,DC=DOTDOMAIN" -properties attribute1, attribute2, attribute3 >> c:\export_to_file.txt > shows attributes for all users in the OUs
  • Get-ADUser -Filter * -SearchBase "OU=SIERRA CENTRAL DEPARTMENTS AND GROUPS (DON'T DELETE),DC=SCCU-DOMAIN,DC=SIERRACENTRAL" -properties * | select-object name, email, enabled, @{"name"="proxyaddresses";"expression"={$_.proxyaddresses}} > Find all (attributes) ProxyAddresses for all users
  • Get-ADGroup -filter * -properties GroupCategory | ft name,groupcategory > List all Groups (security and distribution) in AD
Configure Office 365 Attributes on AD using Powershell:
  • Set-ADUser Username –Replace @{msExchRecipientDisplayType = “-2147483642”}
  • Set-ADUser Username –Replace @{msExchRecipientTypeDetails = “2147483648”}
  • Set-ADUser Username –Replace @{msExchRemoteRecipientType = “1”}
  • Set-ADUser Username –Replace @{targetAddress = “”}
  • Get-ADUser Username | Set-ADUser -Add @{proxyAddresses = ""}
  • Get-ADUser Username | Set-ADUser -Add @{proxyAddresses = ""}
  • Get-ADUser Username | Set-ADUser -Add @{proxyAddresses = "X400:C=US;A= ;P=Company Name;O=Exchange;S=LastName;G=FirstName;"}
Use PowerShell on Office 365:
  • $UserCredential = Get-Credential
  • Connect-MsolService -Credential $UserCredential
  • Connect-MsolService
    • Test using Get-MsolUser
    • Get-MsolUser | Where-Object { $_.isLicensed -eq "TRUE" } | Select-Object UserPrincipalName, DisplayName, Country, Department | Export-Csv c:\LicensedUsers.csv > Get all the users with a license in 365
Find Programs Installed using PowerShell:
Get-ItemProperty HKLM:\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\* | Select-Object DisplayName, DisplayVersion, Publisher, InstallDate | Format-Table –AutoSize > C:\InstalledPrograms.txt

Show Group Members using Powershell:
get-adgroupmember "Domain Admins" | Select-Object Name, distinguishedName

Get Members of an AD Group using PowerShell:
Get-ADGroupMember "group_name_in_AD" | Get-ADUser | Select-Object Name, mail | Export-Csv -Path "c:\groupname.csv" -NoTypeInformation

Disable SMBv1 from PowerShell:
Set-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Services\LanmanServer\Parameters" SMB1 -Type DWORD -Value 0 -Force

Rebuild TCP/IP Stack:
1. Reset WINSOCK entries to installation defaults:
netsh winsock reset catalog.
2. Reset IPv4 TCP/IP stack to installation defaults.
netsh int ipv4 reset reset.log

Find Remote NetBIOS Computer Name 
nbtstat -a IP.ADDRESS

Show Hidden Adapters in Windows: 
1.Click Start, click Run, type cmd.exe, and then press ENTER.
2.Type set devmgr_show_nonpresent_devices=1, and then press ENTER.
3.Type Start DEVMGMT.MSC, and then press ENTER.
4.Click View, and then click Show Hidden Devices.
5.Expand the Network Adapters tree.
6.Right-click the dimmed network adapter, and then click Uninstall.

Reset Vcenter "administrator@vcenter.local" password from cli
  1. From Vcenter console login as root and press "Alt + F1" to go to shell
  2. Log in to the vCenter Server Appliance via SSH;

    Run this command to enable access the Bash shell;

    shell.set –enabled true

    Type shell and press Enter;

    Run the following command:


  3. This menu loads:


Please select:

0. exit

1. Test LDAP connectivity

2. Force start replication cycle

3. Reset account password

4. Set log level and mask

5. Set vmdir state


Press 3 to enter the Reset account password option;

When prompted for the Account UPN, enter:


By default, this is:


A new password is generated.

Use the generated password to log in to the administrator@vSphere.local account.

SelectionFile type iconFile nameDescriptionSizeRevisionTimeUser

  Nov 19, 2017, 1:17 PM Alex Roldan Leben

  Nov 19, 2017, 1:17 PM Alex Roldan Leben

  Nov 19, 2017, 1:17 PM Alex Roldan Leben

  Nov 19, 2017, 1:17 PM Alex Roldan Leben

  Nov 19, 2017, 1:17 PM Alex Roldan Leben

How to reset Vsphere administrator@vcenter.local password from CLI  Mar 17, 2019, 1:40 PM Alex Roldan Leben