Skip to content

Instantly share code, notes, and snippets.

View tostka's full-sized avatar

Todd Kadrie tostka

View GitHub Profile
# comma-delimited server name array,
# foreach into logparser command
# Note: edit/update the logname string, to specify variant dates
# one-line follows (manually wrapped for clarity)
$CASs="US-HUBCAS1","US-HUBCAS2","US-HUBCAS3" ;
foreach ($CAS in $CASs){
write-host ("`n" + $CAS) ;
.\logparser.exe "SELECT cs(User-Agent) as Client, count(*) as Hits INTO $CAS-EWS-ALLClients.csv FROM '\\$CAS\e$\Weblogs\W3SVC1\ex130919*.log' WHERE cs-uri-stem LIKE '%/EWS/%' GROUP BY Client ORDER BY Hits DESC" -o:csv ;
}
# 1-line, wrapped at pipes and semi-colons for readability
$drvs="e","f","c" ; get-exchangeserver |
where{$_.isHubTransportServer -eq $true} |
foreach{
write-host $_ ;
foreach ($drv in $drvs) { if (test-path \\$_\$drv`$\scripts\) { break } } ;
copy \\SourceServer\e$\scripts\get-HT-MsgTrk-TopTraffic-LastXMin.ps1 \\$_\$drv`$\scripts\ -whatif ;
} ;
<# TRIMMED GIST #>
#*----------------v Function ProcessLogs() v----------------
Function ProcessLogs {
<# TRIMMED GIST #>
write-host -ForegroundColor White ((get-date).ToString("HH:mm:ss") + ": Site: " + $SiteName)
foreach ($Hub in $Hubs) {
write-host -foregroundcolor White ("-" * 10)
@tostka
tostka / append-x500LEDN-ToMbxEmailAddressess.ps1
Last active March 27, 2018 23:30
Exchange Script to splice in historical LEDN onto migrated mailboxes, to support reply-to etc on PST migrated email.
# append-x500LEDN-ToMbxEmailAddressess.ps1
<# key snippet from larger script...#>
if(test-path $InputCSV) {
write-verbose -verbose:$true "$((get-date).ToString('HH:mm:ss')):Loading Input file: $($InputCSV)" ;
$procMbxs=import-csv $InputCSV ;
foreach($pMbx in $procMbxs) {
if($tmbx = get-mailbox -identity "$($pMbx.WindowsEmailAddress)" -ea 0 ){
write-host -foregroundcolor green "$((get-date).ToString('HH:mm:ss')):MATCHED:$($pMbx.WindowsEmailAddress)($($pMbx.displayname))=>TO:$($tmbx.WindowsEmailAddress)($($tmbx.displayname))" ;
#check-ExchSvcStatusRpt.ps1
<# This gist is trimmed to just the core data gathering bits...
#>
#-------------------------------------------------
# do data collection here
<# trimmed #>
# Ex svcs
$svcs = (get-service -include *exchange* -computername $env:COMPUTERNAME | ?{$_.name -notmatch '^(Mimosa.*|wsbexchange)$'} | select name,DisplayName,status );
<# This gist is TRIMMED to just the core pieces #>
#*------v Function Test-Port() v------
function Test-Port {
# attempt to open a port (telnet xxx.yyy.zzz nnn)
# call: Test-Port $server $port
PARAM([parameter(Mandatory=$true)] [alias("s")] [string]$Server, [parameter(Mandatory=$true)][alias("p")]
[int]$port
) ;
$ErrorActionPreference = “SilentlyContinue” ;
<# Exchange HubTransport queue snippet for dumping queued external delivery domain details,
for all hub servers in the local AD Site. (Exchange 2010 version)
Update the $probdom to a target fqdn, and run it.
#>
$probdom='badmaildelivery.com' ;
$Site=[System.DirectoryServices.ActiveDirectory.ActiveDirectorySite]::GetComputerSite().Name ;
$Banner="== v Site:$($Site.toupper()) - MSGS QUEUED TO $($probdom) PER HUB: v ==" ;
write-host -foregroundcolor green "`n$((get-date).ToString('HH:mm:ss')):$($Banner)" ;
$hubsl=Get-ExchangeServer | where { $_.isHubTransportServer -eq $true -and $_.Site -match ".*\/$($Site)$"} | select -expand name ;
foreach($hub in $hubsl){ write-host -foregroundcolor green "$((get-date).ToString('HH:mm:ss')):----$($hub):" ;
<# Powershell snippet to retrieve details on top 3 queued domains on Exchange hubs in local AD site
I generally just paste the 1-liner version straight into a remote EMS console, for execution
#>
$TopDoms=3 ;
$Site=[System.DirectoryServices.ActiveDirectory.ActiveDirectorySite]::GetComputerSite().Name ;
$Banner="== v Site:$($Site.toupper()) - TOP $($TopDoms) QUEUED DOMAINS PER HUB: v ==" ;
write-host -foregroundcolor green "`n$((get-date).ToString('HH:mm:ss')):$($Banner)" ;
$hubsl=Get-ExchangeServer | where { $_.isHubTransportServer -eq $true -and $_.Site -match ".*\/$($Site)$"} | select -expand Name ;
foreach($hub in $hubsl){ write-host -foregroundcolor green "$((get-date).ToString('HH:mm:ss')):----$($hub):" ;
[console]::ForegroundColor = "yellow" ;
@tostka
tostka / convert-ToMp3.ps1
Last active March 28, 2018 00:09
convert-ToMp3.ps1 - Movie to Mp3 conversion wrapper script for ffmpeg or VLC player.
# convert-ToMp3.ps1
<# This gist is TRIMMED to ust the core pieces #>
#*================v FUNCTIONS v================
#*----------------v Function convert-ToMp3 v------
function convert-ToMp3 {
<# TRIMMED #>
@tostka
tostka / Get-IMDBSearch.ps1
Last active March 28, 2018 02:34
Interactive Imdb title lookup function, uses xml (html) parsing. Returns and lists closest matches in menu, then returns details of selected choice
<# TRIMMED GIST, SEE FULL Get-IMDBSearch.ps1 SCRIPT FOR DETAILS#>
#*------v Function Get-IMDBSearch v------
Function Get-IMDBSearch {
<# TRIMMED #>
$qryUrlRoot = "http://google.com/search?q=site:imdb.com/title" ;
$url = "$($qryUrlRoot) $($Title.trim())" ;