Powershell

Powershell Commands

Exchange Specific Commands

Lync Specific Commands

Get Exchange version

Get-ExchangeServer

Disable default Exchange attachment filter

Disable-TransportAgent -Identity "Attachment Filtering Agent"

Reseed Exchange mailbox database search catalog

Update-MailboxDatabaseCopy -Identity "Mailbox\Server" -CatalogOnly

Check current CAS and if it needs to be updated

get-mailboxdatabase | select name,rpcclientaccessserver | fl (Set to what you want) get-mailboxdatabase | set-mailboxdatabase –rpcclientaccessserver cas.yourdomain.com (Verify it is set) get-mailboxdatabase | select name,rpcclientaccessserver | fl

Create CAS array

New-ClientAccessArray -FQDN cas.psa.local -Site "site1" -Name "cas.psa.local"

Configure OAB virtual directory

Set-WebServicesVirtualDirectory -Identity "ServerName\EWS (Default Web Site)" -InternalUrl https://mail.site.local/EWS/Exchange.asmx -ExternalUrl https://mail.site.com/EWS/Exchange.asmx -BasicAuthentication:$True

Set the autodiscover URI on the CAS

Get-ClientAccessServer |Set-ClientAccessServer -AutoDiscoverServiceInternalUri https://autodiscover.site.com/Autodiscover/Autodiscover.xml

Change transport message limits (20mb here)

set-TransportConfig -ExternalDsnMaxMessageAttachSize 20971520 set-TransportConfig -InternalDsnMaxMessageAttachSize 20971520 set-TransportConfig -MaxSendSize 20971520 set-TransportConfig -MaxReceiveSize 20971520

Update email address policies

Set-EmailAddressPolicy "Default Policy" -IncludedRecipients AllRecipients

Update address lists

Set-AddressList "All Users" -IncludedRecipients MailboxUsers Set-AddressList "All Groups" -IncludedRecipients MailGroups Set-AddressList "All Contacts" -IncludedRecipients MailContacts Set-AddressList "Public Folders" -RecipientFilter { RecipientType -eq 'PublicFolder' } Set-GlobalAddressList "Default Global Address List" -RecipientFilter {(Alias -ne $null -and (ObjectClass -eq 'user' -or ObjectClass -eq 'contact' -or ObjectClass -eq 'msExchSystemMailbox' -or ObjectClass -eq 'msExchDynamicDistributionList' -or ObjectClass -eq 'group' -or ObjectClass -eq 'publicFolder'))} - Set-AddressList "Custom" -RecipientFilter (.\ConvertFrom-LdapFilter.ps1 (Get-AddressList "Custom").LdapRecipientFilter)

Start public folder migration

.\AddReplicatoPFRecursive.ps1 –TopPublicFolder \ -ServerToAdd ServerName .\AddReplicatoPFRecursive.ps1 –TopPublicFolder \NON_IPM_Subtree -ServerToAdd ServerName

Set databases to custom site settings

get-mailboxdatabase | set-mailboxdatabase -mailboxretention 90 -deleteditemretention 35 -issuewarningquota 9gb -prohibitsendquota 10gb -offlineaddressbook "\Site OAB" -publicfolderdatabase "Public Folder Database"

Reset search index for mailbox database

C:\Program Files\Microsoft\Exchange Server\v14\Scripts\ResetSearchIndex.ps1 "Mailbox Database Name" -force

Replicate a receive connector across hub transport servers

$connector = Get-ReceiveConnector "EX01\External Relay" Set-ReceiveConnector "EX02\External Relay" -RemoteIPRanges $connector.RemoteIPRanges

Get detailed info for moved mailbox

Get-MoveRequestStatistics -id 'John Doe' |  Select DisplayName, Status, TotalItemSize,  TotalMailboxItemCount, PercentComplete,  BytesTransferred, ItemsTransferred

Generate a report for mailbox move

$MRep = Get-MailboxStatistics -id TR -IncludeMoveReport$MRep.MoveHistory\[0] |  Export-CSV 'C:\TEMP\MoveReport.CSV'

Change exchange mail contacts to not use MAPI

Get-MailContact -ResultSize unlimited -OrganizationalUnit "gmrcnt.local/Users/Internet Addresses" | where {$_.UseMapiRichTextFormat -eq "UseDefaultSettings"} | Set-MailContact -UseMapiRichTextFormat Never

Track failed messages because of recipient max receive size

Get-MessageTrackingLog -EventID FAIL | where {$_.RecipientStatus -like “*RecipSizeLimit*”}

Track failed messages because of sender max send size

Get-MessageTrackingLog -EventID FAIL | where {$_.RecipientStatus -like “*SendSizeLimit*”}

Disable CEIP (Customer Experience Improvement Program)

Set-OrganizationConfig -CustomerFeedbackEnabled $false

Allow anonymous External relaying on hub transport server

Get-ReceiveConnector -Identity "GMVM382\External Relay" | Add-ADPermission -User "NT AUTHORITY\ANONYMOUS LOGON" -ExtendedRights "ms-Exch-SMTP-Accept-Any-Recipient"

Export Exchange mailbox to PST file

New-MailboxExportRequest -Mailbox jdoe-FilePath \\exchangeshare\pst\jdoe.pst

Remove user permissions to specific mailbox

Remove-MailboxPermission -Identity user@company.com -User admin@company.com -AccessRights FullAccess -InheritanceType All

List mobile devices that have connected to Exchange in the last 30 days

Get-ActiveSyncDevice | Get-ActiveSyncDeviceStatistics | ?{$_.LastSuccessSync -gt (Get-Date).AddDays(-30)} | ft identity,devicemodel,deviceos,lastsuccesssync,devicemobileoperator

Turn on Mutual Auth TLS for a receive connector

Set-ReceiveConnector “Default internal receive connector DS-FEDGE” –DomainSecureEnabled $true –AuthMechanism tls

Check Public Folder migration status

Get-PublicFolder -recurse |fl name,replicas

Enable IM Warnings

Get-CSClientPolicy | Set-CSClientPolicy -IMWarning "Im's will be archived"
Enable "appear offline" option
Get-CSClientPolicy | Set-CSClientPolicy -EnableAppearOffline $true

Export all IM conversations for all users from specific date until today

Export-CSArchivingData -DBInstance lynclab2ma.lynclab2.local\LyncArchiving -StartDate 3/1/2011 -EndDate 3/12/2011 -OutputFolder “C:\ArchivingExports”

Export all IM conversations for specific user from specific date until today

Export-CSArchivingData -DBInstance lynclab2ma.lynclab2.local\LyncArchiving -StartDate 3/10/2011 -EndDate 3/10/2011 -OutputFolder “C:\ArchivingExports” -UserURI “user3@lynclab2.local”

Change default contact list photo size limit

Get-CsClientPolicy | Set-CsClientPolicy -MaxPhotoSizeKB 100

Show available (whitespace) space in mailbox database

Get-MailboxDatabase <DB Name> -Status | fl Name,Avail*

Shutdown a remote computer

Stop-Computer –Computer computername –Credential psa\administrator

Disable DHCP on NIC

Get-NetAdapter -Name Ethernet | Set-NetIPInterface -DHCP Disabled

Set a static IP and default gateway

Get-NetAdapter -Name Ethernet | New-NetIPAddress -AddressFamily IPv4 -IPAddress 10.0.1.100 -PrefixLength 24 -Type Unicast -DefaultGateway 10.0.1.1

Configure DNS server address

Get-NetAdapter -Name Ethernet | Set-DnsClientServerAddress -InterfaceAlias Ethernet -ServerAddresses 10.0.1.10

Add GUI to Server 2012

Install-WindowsFeature -ComputerName Server-Gui-Mgmt-Infra, Server-Gui-Shell -Restart

Remove GUI from Server 2012

Uninstall-WindowsFeature -ComputerName Server-Gui-Mgmt-Infra, Server-Gui-Shell -Restart

Join computer to a domain

Add-Computer -DomainName "psa.local" -Credential "psa\adminaccount"

List the number of enabled users in Lync environment

Get-CsUser -filter {enabled -eq $true} | Measure-Object | fl Count

Update file share witness

 Set-DatabaseAvailabilityGroup DAG –WitnessServer “servername”  -WitnessDirectory “c:\DAG”

Set a users PIN

Set-CsClientPin -Identity "John Doe" -Pin 123456

Get last password change for users

 Get-ADUser ‘UserName’ -properties PasswordLastSet | fl

List top mailbox sizes for an organization

Get-Mailbox | Get-MailboxStatistics | select Displayname, Itemcount, TotalItemSize | Sort-Object Totalitemsize -Descending | more

List locked out AD accounts

Search-ADAccount -LockedOut