Category: Windows Server

Scenario: You need to determine the LastLogon date in a readable format from a list of AD users in a csv file. Edit your users.csv file  so that row1 = name and the following rows have the SamAccountName (or other get-ADUser property) separated by a new line. Example of contents of users.csv = name testusr testuser2 […]
Scenario:  You want to set the Office property for a user account via PowerShell for Active Directory Solution: To set a single User for the property Office: Get-ADUser testusr1 -Properties * | Set-ADObject -Replace @{Office = “test”} To check a single User for the property Office: Get-ADUser testusr1 -Properties * | Select name, Office To […]
Scenario:  A user is a member of multiple security and distribution groups and you wish to determine which of these groups are distribution. Script: $1 = (Get-ADUser STEVE -Properties Memberof).memberof $2 = $1 | %{Get-DistributionGroup $_}  
Scenario:  Display all of the groups a AD user is a member of Scriptlet:   Run the following in Powershell: Get-Aduser STEVE -properties * | Select -expandproperty Memberof | Sort
Scenario:  You want to see the last time AD replication happened between site-to-site. Scriptlet: repadmin.exe /showrepl * /csv > c:\temp\showrepl.csv
Scenario:  You wish to see how many remote mailboxes have the correct email domain configured for their remote routing address (TargetAddress).  You want to perform a AD PowerShell query for speed. Scriptlet: Get-ADuser -filter {TargetAddress -like “*.mail.onmicrosoft.com”} | Select Name, TargetAddress OR you just want a count: (Get-ADuser -filter {TargetAddress -like “*.mail.onmicrosoft.com”} | Select Name, […]
Scenario:  You want to use Get-ADUser to find all Exchange mailboxes in your environment. Scriptlet:   Running the following will provide you with the detail: #First, lets store some results into $1 for every mailbox $1 = Get-ADUser -filter {HomeMDB -ne ‘$null’} -Properties MailNickName, HomeMDB, DisplayName| Select MailNickName, HomeMDB, DisplayName #Now its time to play with […]
Scenario: You are going to install the latest CU for Exchange, but you want to check the AD Schema levels to see if they need to be upgraded before the CU install Command Line:  Using CMD line, run the following: (Everything in bold needs to be edited to reflect your Exchange organization OR your domain) […]
Archives