PS Commands

My list of handy UC PowerShell Commands I like to keep handy, as I’m terrible for memorizing them all.  If you have a good one to contribute, let me know and I’ll add it.

Discover Federated Domains – (run on Edge server)
Get-EventLog “lync server” | ? {$_.eventid -eq 14601} | Select eventid,message -First 1 | fl *

Dang Ellipsis – setting the following string gets rid of them for the session
$FormatEnumerationLimit = -1

Finding Skype Online Users where the SIPAddress and UPN do not match – requires remote powershell SkypeOnline module
get-csonlineuser | where {$_.SipAddress -ne “sip:”+ $_.userprincipalname} | fl DisplayName,UserPrincipalName,Sip*

Finding users with certain Dial Plans, Conferencing Policy’s…
Get-CsUser -Filter {dialplan -ne $null} | FL DisplayName,DialPlan
Get-CsUser -Filter {dialplan -eq “NA-CA-International”}

Get-CsUser -Filter {ConferencingPolicy -ne $null} | FL DisplayName,ConferencingPolicy
Get-CsUser -Filter {ConferencingPolicy -eq “Policy 2 (Medium High)”}
Get-CsUser -Filter {ConferencingPolicy -ne $null} | Grant-CsConferencingPolicy -PolicyName $NULL

Get-CsUser -Filter {ExternalAccessPolicy -ne $null} | FL DisplayName,ExternalAccessPolicy
Get-CsUser -Filter {ExternalAccessPolicy -eq “Allow Federation+Outside Access”}
Get-CsUser -Filter {ExternalAccessPolicy -ne $null} | Grant-CsExternalAccessPolicy -PolicyName $NULL

Management Store Replication Status Summary
Get-CsManagementStoreReplicationStatus | ft UpToDate, ReplicaFqdn, Last* -AutoSize

UM Mailbox commands
Get-UMMailbox | where { $_.Extensions -eq “7770” } | ft -autosize
Get-UMMailbox |ft Name,Extensions -autosize
Get-UMMailbox | where {$_.UMMailboxPolicy -eq “CCMailbox”}

DCDiag Quick Health Check summary
dcdiag /e /c /v /f:c:\temp\dcdiag1.txt

NETSTAT – credit Michael LaMontagne
netstat -anob  Displays all connections, numerical form, with Process ID and executable
netstat -an    Displays all connections, numerical form.

Elevated Accounts that are Enabled for Skype/Lync – credit Pat Richard
(Get-ADGroupMember “Domain Admins”).DistinguishedName | Get-CsUser -ErrorAction SilentlyContinue | Format-Table DisplayName,SipAddress

Finding AD Disabled Accounts still Skype/Lync Enabled – credit Pat Richard
Get-CsAdUser -ResultSize Unlimited | Where-Object {$_.UserAccountControl -match “AccountDisabled” -and $_.Enabled -eq $true} | Format-Table Name,Enabled,SipAddress -auto

optionally can also disable them too but run the command above to “check first”
Get-CsAdUser -ResultSize Unlimited | Where-Object {$_.UserAccountControl -match “AccountDisabled” -and $_.Enabled} | Disable-CsUser

Finding accounts where the SMTP and SIP address do not match – credit Pat Richard
Get-CsAdUser | Where-Object {($_.WindowsEmailAddress -and $_.SipAddress) -and ($_.WindowsEmailAddress -ne ($_.SipAddress -replace “sip:”,””))} | Select-Object DisplayName,WindowsEmailAddress,SIPAddress

Std Edition Servers, setting the RTCSRV service to be dependent on the Local SQL instances to be up and running
CMD Prompt only: