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 (http://technet.microsoft.com/en-us/library/ee156812.aspx)

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

$PSVersionTable.PSVersion


Find Lync Routing Group

get-csuserpoolinfo -identity sip:joe.lync@domain.com


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 /server:somepool@domain.com sip:somecommonareaphone@domain.com /verbose /callanswerwaittime:20 /setfwddestination:sip:someothercommonareaphone@domain.com /enablefwdnoanswer


Query for DHCP Optoins for VOIP subnets

$ScopeIDs = Get-DhcpServerv4Scope -ComputerName somedhcpserver| ? {$_.name -like “*VOIP*” -or $_.name -like “*911*” -or $_.name -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 | ? {$_.name -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\ucupdates.cab


Dumping Data for Lync User

debug-csaddressbookreplication –user lync.test –domaincontroller dc01.contoso.com | fl

Or

dbanalyze /sqlserver:localhost\rtclocal /report:user /user:soinso@contoso.com > 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
example:

IP Name
10.140.13.212 Server1
10.140.13.213 Server2
#>
$IPS = $NULL
$IPS = import-csv -Path C:\dns\1.csv
$ZONE = “someDNSZone”
$DNSSERVER = “somednsserver.domain.com”

Foreach ($IP in $IPS)
{

Add-DnsServerResourceRecordA -ComputerName $DNSSERVER -Name $IP.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:

WordPress.com Logo

You are commenting using your WordPress.com 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