Useful PowerShell One-Liners for Lync
Below are some one-liners I use often in administering Lync systems, so I thought I would share this as a reference. These should be run from a Lync PowerShell Instance, unless otherwise indicated:
List a User's Response Group
Memberships
get-csrgsagentgroup
| Where-Object {$_.AgentsByUri -like "sip:first.last@domain.com"} |
Select name
Get users in
specific OU and output to csv (run from Exchange Powershell)
get-mailbox
-OrganizationalUnit
"ou=YourOU,dc=DOMAIN,dc=COM"
-resultsize unlimited | select-object
DisplayName,SamAccountName,PrimarySmtpAddress | Export-CSV
e:\files\DomainUsers.csv
Invoking CMS Replication
Invoke-CSManagementStoreReplication
Getting CMS Replication Status of only Lync Servers
Invoke-CSManagementStoreReplication
Getting CMS Replication Status of only Lync Servers
Get-CsManagementStoreReplicationStatus
| Where-Object {$_.ReplicaFqdn -match "ServerNamingConvention" -Or $_.ReplicaFqdn
-match "SBANamingConvention"} | Select ReplicaFqdn, UpToDate
Get users where External
Access is…
get-csuser | Where
{$_.ExternalAccessPolicy -like "PolicyName"}
Counting users who
have a telephone number set in Lync
get-csuser |
Sort-Object LineURI | where {$_.LineURI -ne ""} | Measure-Object
Finding AD Disabled Accounts
Who are Still Lync Enabled
Get-CsAdUser |
?{$_.UserAccountControl -match "AccountDisabled"
-and $_.Enabled -eq $true} | ft Name,Enabled,SipAddress -auto
Counting AD Disabled
Accounts Who are Still Lync Enabled
Get-CsAdUser |
?{$_.UserAccountControl -match "AccountDisabled"
-and $_.Enabled -eq $true} | Measure-Object
List all users in a pool
get-csuser |
where-object {$_.RegistrarPool -like
"lyncpoolfqdn"}
| Select-Object DisplayName, LineUri
List all Common Area Phones
in a pool
get-cscommonareaphone
| where-object {$_.RegistrarPool -like
"lyncpoolfqdn"}
| Select-Object DisplayName, LineUri
List all Analog Devices in a
pool
get-csanalogdevice |
where-object {$_.RegistrarPool -like
"lyncpoolfqdn"} | Select-Object DisplayName,
LineUri
Count How Many Users are on
Lync
(Get-CsUser
-OnLyncServer).Count
Get PowerShell Version (run from any PowerShell Session)
$PSVersionTable.PSVersion.Major
Or
Get-Host |
Select-Object Version
Getting Relative Dates (run from any PowerShell Session)
Here's a quick and
fast way of generating relative dates in any format:
(Get-Date).AddDays(-1).ToString('yyyy-MM-dd')<?xml:namespace
prefix = o ns = "urn:schemas-microsoft-com:office:office"/>
This returns
all error events from the System event log in the past 48 hours: (run from any PowerShell Session)
Get-EventLog
-LogName System -EntryType Error -After (Get-Date).AddDays(-2)
I'll add more as need arises. Hope these are helpful.
No comments:
Post a Comment
Thanks for reading and commenting. I look forward to it.