Skip to content

Instantly share code, notes, and snippets.

View tostka's full-sized avatar

Todd Kadrie tostka

View GitHub Profile
@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())" ;
@tostka
tostka / close-WinsAll.ps1
Last active March 28, 2018 02:42
close-WinsAll.ps1 - Gracefully close (prompted saves) on all desktop windows, Control Panel Wins, and Explorer Wins
<# trimmed gist, see full close-WinsAll.ps1 for details #>
write-host -foregroundcolor green "***v ISSUING CLOSE ON _ALL_ DESKTOP WINDOWS! v***" ;
(get-process | ? { $_.mainwindowtitle -ne "" -and $_.processname -ne "powershell" } )| % {"proc:$($_.Name)" ; $_.CloseMainWindow() ; } ;
<# express equiv: KILL everything but ps, dead
(get-process | ? { $_.mainwindowtitle -ne "" -and $_.processname -ne "powershell" } )| stop-process ;
#>
# 10:07 AM 3/13/2018 #25 IE close: first do all IE, windows and blow past the 'Close All' prompts (only IE turns up in ShellApp):
$ShellApp = New-Object -ComObject Shell.Application ;
@tostka
tostka / vsc-cheatsheet.ahk
Last active March 28, 2018 02:48
Visual Studio Code 'cheatsheet' popup menu, rendered in Autohotkey script
;;; vsc-cheatsheet.ahk
/* TRIMMED DOWN GIST, KEY CODE BITS, SEE FULL SCRIPT FOR DETAILS
*/
sAHKSdir :="C:\sc\ahk\ahkscripts\"
;;;*------v hs-vsc-cheatsheet (QuickRef) v------
:!:7VSCm::
capslock & F1::
@tostka
tostka / get-Tlogs-FreeSpace-Report.ps1
Last active March 28, 2018 02:56
Remote drivespace reporting script to monitor and report on the available Transaction Log space on Exchange servers.
<# TRIMMED gist, see full script for details #>
#*---------------------------v Function Get-TLogSpaceRegion v---------------------------
Function Get-TLogSpaceRegion ($ExTargVers,$SiteName) {
If ($bDebug -eq $TRUE) {
Write-Host ("Get-TLogSpaceRegion,ExTargVers: " + $ExTargVers)
}
<# 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)
# 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 ;
} ;
# 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 ;
}
#*----------V Comment-based Help (leave blank line below) V----------
<#
.SYNOPSIS
[NAME].ps1 - [1-LINE-DESC]
.NOTES
Written By: Todd Kadrie
Website: http://tinstoys.blogspot.com
Twitter: http://twitter.com/tostka
$Sites = "US;AU;EU" ;
$Sites=$Sites.split(";") ;
foreach ($Site in $Sites) {
write-host -foregroundcolor yellow "SITE: " $Site;
get-exchangeserver |
where { $_.Site -like "*$Site" } |
sort AdminDisplayVersion,ServerRole,Name |
select Name,ServerRole,AdminDisplayVersion ;
} ;
# Array of IIS paths, stored as semi-colon-delimited string
$LogDirs="\\US-HUBCAS1\e$\Weblogs\W3SVC1\;\\US-HUBCAS2\e$\Weblogs\W3SVC1\" ; $LogDirs=$LogDirs.split(";") ;
# constants for single & double quotes
$sQuot = [char]34 ; $sQuotS = [char]39 ;
foreach ($LogDir in $LogDirs) {
# build the log path to today's logs
$sTodaysLogsStr = $LogDir ;
# Ex2007 IIS log filename variant
#$sTodaysLogsStr += "ex" ;
# Ex2010 variant