Monday, April 23, 2018

The Big Picture (Powershell log-spanning event script)

4/23/2018: This is a quick 1-liner script aimed at pulling all eventlog events over a specific time span, across multiple logs. Gives you the 'high-view' timeline of the sequence of events, when you're trying to correlate that odd issue to a root cause.

Sure you can check each constituent log - System, Application, and a Crimson/App-log one by one, and mentally compare the time sequence across the logs.

But the handy bit to this chunk of code is that it quickly & neatly pulls all of the events together into one csv, sorted into time sequence, ready for quick review: Pop the Csv open, and you can directly see the events that occurred just ahead of your app's issues - possibly spot the OS/System-level item that actually was the actual root of the problem. :)

Thursday, April 5, 2018

Exchange newest mailbox redistribution script (move-MailboxesMostRecent.ps1)

4/5/2018: This script leverages the Exchange-2010+ 'Automatic Mailbox Provisioning' (AMP) feature, wherein, if you don't designate a specific destination database for a mailbox move, AMP will pick one at random for you (following some predictable rules, covered below).

When moving mailboxes, to redistribute load, the most 'easy-to-move' of the bunch, are boxes that are brand new, or those only in use for a very limited amount of time.

Thursday, March 29, 2018

PS template - Splatted update snippet

3/29/2018: Over the years of working with Powershell for quick admin work, I've become a sizable fan of splatting powershell commands.

First a 'Splat' Introduction:


For folks late to the party, "splatting' leverages standard hashtables to encapsulate 'sets' of parameters for commandlets. The short form is that you take all the parameters you'll be feeding to a given commandlet, configure them by matching name->value combos into a hash varable, and then, by specifying the hash variable with an 'at' (@) prefix rather than dollar-sign ($), Powershell & the commandlet interpret your splatted hash table as the set of parameters with which to execute your desired command.

Powershell script: Check HP Array Config Utility CLI

3/29/2018: Script that can be used to collect drive-failure errors out of HP Array Config Utility (via the CLI tool).

I'm in the process of migrating my firm's core mail assets to Exchange Online. But, in the interrum, I've still got some aging original hardware holding users. Which, naturally with increasing hours of uptime, sheds old drives on a regular basis.

I generally like to have SCOM watching & alerting on this type of material.  But some of these systems run in locations that are somewhat 'adverse' to going deep on monitoring infrastructure and overhead.

So, when faced with a challenge, we roll up our sleeves and roll-our-own ad-hoc solutions to keep those old boys propped vertical, at least until I can finish draining the hosted users online. :D

Sunday, January 7, 2018

Exchange script: Fix broken migrated email addresses by splicing the historical LEDN in as a new X500 address

1/7/2018: I was working on a mail migration and needed to dust off and use this script, so I figured I'd go ahead and post it.

The underlying purpose for this script is, to workaround and suppress...
    # 550 5.1.1 RESOLVER.ADR.ExRecipNotFound; Not found'
... errors for users replying to email that has been migrated from an external mail system.

Friday, October 13, 2017

Exchange post-reboot emailed status confirmation script

10/13/2017: If you've got a lot of servers to keep track of - whether doing maintenance (patching), or experiencing the inevitable random reboots/unscheduled-virtualization-burps/what-have-you - you want to know the full status of the system, as quickly as possible IMMEDIATELY after it comes back online. To that purpose, this script is the current rev of a series I've been using for the niche since 2007 or before.

In this case, it's the Exchange-specific version. I generally configure it as a Scheduled Task triggered by the OnBoot event (with a fire-delay for Win2012R2+). The script logs a transcripted file & emails an html-format report, covering the following tests & status:

Thursday, September 28, 2017

Powershell server RDP ping availability script

9/28/2017: Just a quicky today: A couple of quick bits I keep in my profile, and routinely leverage for server maintenance. Run ping-RDP.ps1, it will prompt you for a target server, and then run a looping port-test (1sec interval), until it detects the RDP port 3389 is up on the target box. At that point it launches an RDP session (mstsc.exe /v:$($tsrvr). Pretty simple, but handy when you're doing concurrent maintenance across multiple boxes.

Friday, September 22, 2017

Exchange Hub Top Queued Domains (Powershell Snippets)

9/22/2017: Here's a couple of quick code snippets for Exchange Server: I use this when I see external delivery domains piling up (in my running get-HtQueuesMonitor.ps1) , to quickly pull out the details on the problem child external domains.

Thursday, June 15, 2017

convert-ToMp3.ps1 Powershell script for ffmpeg or vlc player

6/15/2017: Sometimes, you just need to convert that video into an mp3 file. You, know, something to take along in the car. Something to spin at your next 'rave' (ho-hum). :P

So what I have here, is a Powershell 'wrapper' for ffmpeg or VLC Player's native ability to convert video's to Mp3. Sure, you could use ffmpeg's command line, (or VLC's Media > Convert\Save menu). But sometimes you want to convert a whole batch, or directory, or recursive directory tree! And that is exactly where this .ps1 comes in.

All you need to do is download and install one or both of the above. I've found that ffmpeg works more consistently and bug-free than VLC. But take your pick. And then get-content c:\path-to-videos\. and pipeline them into the script, and you're off to the mp3 races. Docs and examples are in the script comments.

Wednesday, June 14, 2017

get-ImdbSearch.ps1 Imdb search script

6/14/2017: Two Posts in a day! And both're scripts to-boot!

Source Updates (reflected at Github):
  • # 2:35 PM 3/24/2018 country: failing, they've dropped space after colon, make it optional; Language same issue; duration.innertext coming through blank, pretest and use duration.datetime instead,
  • # 9:20 PM 9/12/2017 typo fix; shifted a bunch of items to 2-stage: they were passing and handing back blank values, when matches failed. 

I like movies. A lot. Last time we moved, I donated piles of dvd's! 

Wonderful thing, moving. Clears the head!  Gives you massive perspective.
Makes you want to donate 300-400 books, and hundreds of dvd's, JUST BECAUSE YOU NEVER WANT TO MOVE THEM AGAIN! :D Ever!. Really. :^S

Anyway, on to today's script: This one runs an interactive Imdb title search (using Google - smaht!) for near-miss title-matching, then returns a console menu of the Google hits, from which to pick. Pick a movie from the menu, and it pulls some fairly decent amounts of info on the chosen flick from Imdb.

Shut 'em all down: close-WinsAll.ps1 Powershell script

6/14/2017: One of the distinct 'costs' of running Office 365/Office 2016 at the office, seems to be that I spend a lot more time:
  1. Shutting down my work box for patching (now that both centralized patch management AND Office 365, independently do their own self-scheduled patching passes),
  2. and, much more frequently and defensively rebooting my box to try to scrape a few more ounces of performance from Word/Excel2016's bloated mass and resource sucking appetite.  
Both of which motivations naturally mean I'm trying to get faster reboots through on my box -- and this is coming from a guy that for the last 4-5 years has consistently hibernated his laptop at each day's end, to try to hit the ground running the next day, from the point I left off. :^|

Anyway, needless to say, the prospects and days of running a given 'up' session of Win7 for, "a couple of weeks" a stretch, appear to be long, long gone. Well, until they hand me a 36gb laptop (and some down time from work burn, to reinstall everything back to spec). But I digress....

So what's the point of this post? Simple: I've got a small and handy script I use, to get my box knocked down and into a reboot POST-HASTE!.