One Liners

What Modules are available for install in Powershell

Get-module -listavailable

Finding Failed Lync Replication

Get-CsManagementStoreReplicationStatus | Where-Object {$_.uptodate -like “false”}

Large files in directory

Get-ChildItem -Recurse | select -Property name, length, directory| sort-object length -Descending

Powershell onto remote server and run commands directly from that server

Enter-PSSession -ComputerName server1

Run a series of commands on against remote computers

Invoke-Command -ComputerName server1,server2,server3 {Get-CsWindowsService}

Short name for the above command is

Icm Server1,server2,server3

Shorthand for “WHERE OBJECT”

Get-csnetworksubnet | where NetworkSiteID – like “some site”

Compare two objects (

Compare-object $dhcp $subnet

Quickly find all ILO interfaces (this assumes the ILO interface has a DHCP address)

Get-DhcpServerv4Scope | get-dhcpserverv4lease | Where-Object {$_.hostname -like “ilo*”}

Find Number of EV Enabled users on a particular pool

(Get-Csuser | Where-Object {$_.registrarpool -like “NIAID-fepool-*” -and $_.EnterpriseVoice -eq “$true”}).count

Find Version of Powershell Running on Server


Find Lync Routing Group

get-csuserpoolinfo -identity

Mapping SID to AD Object

$SID = “somesid”
Get-ADObject -Server “someDomainController” -Filter “objectSid -eq ‘$sid'”

Enable Call Forwarding for Common Area Phones

C:\Program Files\Microsoft Lync Server 2013\ResKit>SEFAUtil.exe / /verbose /callanswerwaittime:20 / /enablefwdnoanswer

Query for DHCP Optoins for VOIP subnets

$ScopeIDs = Get-DhcpServerv4Scope -ComputerName somedhcpserver| ? {$ -like “*VOIP*” -or $ -like “*911*” -or $ -like “*AV*”}
foreach ($SCOPEID in $SCOPEIDs)
Get-DhcpServerv4OptionValue -ComputerName somedhcpsever -ScopeId $scopeID.scopeid.IPAddressToString | Format-table -AutoSize

Query DHCP Leases for Mac address (in this case CX5500 MAC)

Get-DhcpServerv4Scope | Get-DhcpServerv4Lease | ? {$_.ClientID -like “00-E0-DB-41*”}

Query for files in directory and move to another

$PATH = “\\someserver\e$\Polycom\”
$MovePath = “\\someserver\e$\Polycom\test”

Get-ChildItem -Path $PATH | ? {$ -like “*-app.log” -and – $_.length -eq 0} | Move-Item -Destination $movepath

Add multiple filters

get-csuser -Filter {(registrarpool -eq “somepool”) -and (ConferencingPolicy -eq “someconfpolicy”)}

Import Lync Phone Edition Firmware

Import-CsDeviceUpdate -Identity service:webserver:somelyncpool -FileName C:\lync\

Dumping Data for Lync User

debug-csaddressbookreplication –user lync.test –domaincontroller | fl


dbanalyze /sqlserver:localhost\rtclocal /report:user / > sometxtfile.txt

CMS Replication Master

Get-CsmanagementStoreReplicationStatus -CentralManagementStoreStatus

Bulk DNS Update

Must be ran from 2K12 Server or Windows 10
Required Headers in CSV File
IP, Name

IP Name Server1 Server2
$IPS = import-csv -Path C:\dns\1.csv
$ZONE = “someDNSZone”

Foreach ($IP in $IPS)

Add-DnsServerResourceRecordA -ComputerName $DNSSERVER -Name $ -zone $Zone -IPv4Address $IP.Ip -CreatePtr -Verbose


Create DHCP Server Policy

Set-DhcpServerv4Policy -MacAddress EQ,somemac1,somemac2-ComputerName somedhcpserver -Name “Some DHCP Policy” -Condition Or

Find Phrase in files

get-childitem C:\capture\syslog -Recurse -Filter * | Select-String “some string”



Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s