Friday, October 13, 2017

I'm alright. Don't nobody worry 'bout me (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:
  1. Runs an automatic pause/delay when run on sub Win2012R2 OS's (to permit time for services to startup and come online naturally). 
  2. Locates a suitable local HubTransport role box to handle smtp report submissions. 
  3. Collects & reports on the state of key Exchange (2010) services by role.
  4. If it finds a key service in a non-Running state, it then makes up to 20 attempts (configurable) to start each failed service.
  5. In the case where it does attempt a service manual start, it then re-confirms post-status on the services. 
  6. It then runs a stock Test-ServiceHealth (redundant with the above, but more descriptive of role-specific status, with it's handy divided status layout). 
  7. For mailbox servers it then:
    1. Runs & reports on Test-ReplicationHealth
    2. Runs & reports on Get-MailboxDatabaseCopyStatus
    3. Collects a list of all suitable hubtransport servers and checks for mail queued to maildatabase's: In my case, they're named in a matchable pattern, so I just go after the names.
      It's also a simple prospect to collect them via something like...
      get-exchangeserver |?{$_.istransportserver -and $_.site -eq 'Sitename'}
      ...as well.
    4. Runs & reports on a pass of Test-MAPIConnectivity against a random mailbox in each database in the DAG.
  8. And for Transport servers, it runs & reports on the status of all queues (get-queue) on the box. 
It's posted pretty much exactly the way I use it (with servernames etc subbed out). So it's not particularly 'genericized' for ready public use. But it does run through a testing protocol, and the assembly of html formatted reports. Even if you can't use it as it sits, it provides some good examples on the process.

Also, I probably should add a block for CAS server reboots, to report on user-utilization levels for the various CAS IIS AppPool's etc. But that's something for another day.  :^D

This is a 900+line script, so I'm not going bore you displaying the full source.:P  But Here's PSHelp block from the top, with the revision spec and broad description
The full code & current revision can always be found at Github: check-ExchSvcStatusRpt.ps1

Thursday, September 28, 2017

Just let me know (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.

Here's the code

Static-source follows (for folks in RSS readers, or disabling scripting):
(check the linked Gist/Github links below for _current_ versions).

ping-RDP.ps1

# ping-RDP.ps1
<#
.SYNOPSIS
ping-RDP.ps1 - runs a dawdle loop polling for RDP port 3389 up on target server. Once avail launches an rdp (mstsc.exe /v:xxx) to the specified box.
.NOTES
Written By: Todd Kadrie
Website: http://tinstoys.blogspot.com
Twitter: http://twitter.com/tostka
Change Log
10:35 AM 9/28/2017 been running these for years in my profile, decided to wrap them up into a simple postable combo - very handy when running server maint reboots across multiple servers at once, and you want to get back into a given box as soon as it's accessible. (don't have to watch, it'll beep & pop open the tsc logon prompt)
.INPUTS
Accepts piped input.
.OUTPUTS
Returns an object with uptime data to the pipeline.
.EXAMPLE
ping-RDP USEA-MAILEXP | select Computername,Uptime
#>

#*------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” ; 
    $socket = new-object Net.Sockets.TcpClient ; 
    $socket.Connect($Server, $port) ; 
    if ($socket.Connected) {
        write-verbose -verbose:$true  "Successful connection to $($Server):$($port)"
        $socket.Close()
        return $True;
    } else {
        write-verbose -verbose:$true  "Failed to connect to $($Server):$($port)"
         return $False;
    } # if-block end
    $socket = $null
}#*------^ END Function Test-Port() ^------

#*======v SUB MAIN v======
$tsrvr=read-host -prompt "Server to be pinged until RDP available" ;
Do {write-host "." -NoNewLine;Start-Sleep -m (1000 * 5)} Until ((test-port $tsrvr 3389)) ;
 write-host "`a" ; # beep
 write-verbose -verbose:$true  "$((get-date).ToString('HH:mm:ss')):Launching rdp to $($tsrvr)..." ;
mstsc.exe /v:$($tsrvr) ;
#*======^ END SUBM MAIN ^======

And the current revision can always be found at Github: ping-RDP.ps1

Monday, September 25, 2017

Fool me twice, shame on me (Office 365/Office2016 Updates)


If you're like myself, and have *joined* the #clouduser stampede - (e.g. you've been forklifted to an 'Office 365' revision of Office) - you're probably extremely familiar with the above happy little popup, on your Word/Excel/Outlook/what-have-you chunk of MS Office.

Until very recently, as a busy admin, I've tended to get the 'Update now' clicked sooner rather than later, just to get this annoying banner out of my eye-space.

Well last week we had an informative *learnin'* oppurtunity round these parts, where some of the more recent #evergreen MS Outlook 2016 code changes -- or possibly Windows Update Win7patch -- Desktop folk are still working a case on the subject) -- has led to multiple Outlook issues for a fair swath of users:

Outlook2016's latest new #misfeature appears to be the ability to arbitrarily switch the client mail profile out of Cached-mode, at-will, and without warning. 

  • For enterprise deployments, with mail servers built around 'Cached-Mode' Outlook, and less-expensive storage infra, a significant chunk of users switching out of 'Cached Mode' could beat the heck out of the I/O capacity on mail servers. 8^.
  • And when it comes to flipping back from the setting (to cached-mode), with remote offices on WAN connections, this can be an absolute *nasty* outcome, if the subject user runs a couple of gb or more of mailbox, that gets freshly transferred back to the workstation when you finally get cached-mode re-enabled. 
And the other new Outlook2016 #misfeature, is the corruption of the user's mail profile, and concurrent-break in ability of local Outlook to run searches of mail content. Yea, that yields up some happy users (and is the first symptom we got this month of the array of fresh problems).

So, this morning, when I was greeted by o365's 'Update now' prompt, I instantly said, "No sir, I'm not going to take that risk. I like getting my work done, waaay too much". That update is going to age a bit before I become a routine early adopter of any new MS Office 365 code. #QaIsntOptional

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.

First snippet simply polls all Exchange Hub Transport servers in the local AD Site for the top 3 queued external destination domains, and dumps out summary specs on the queued domain.

Goal here is to rapidly spot queued items that are never going anywhere, to get them purged.

Here's the code

Thursday, June 15, 2017

Makin' Music (from movies, 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.

Here's the code

Wednesday, June 14, 2017

Get the Picture? (get-ImdbSearch.ps1 Powershell script)

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

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.

Two outputs: Default 'Summary': 


And '-Full':



Here's the code


And the current revision can always be found at Github: Get-IMDBSearch.ps1

Nuke the entire site from orbit (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!.

close-WinsAll.ps1 goes through and quickly does the following:
  • Issues a 'CloseWindow' on all visible desktop processes: Causing each to prompt for a save, if they're in an unsaved state, 
  • ... and then issues a 'Quit' on all Control Panel or  Explorer windows. 
Net result after a pass: Everything that can be closed, closes. And everything that needs an explicit save, is left with a save dialog popped. Confirm or cancel the save prompts,hit ctrl+alt+del, pick Reboot, and you're off to a Refreshening™ as fast as your wee little fingers can take you. :D

Here's the code

Thursday, February 2, 2017

Two is one, one is none

And this...
  ...is why I run both Google Drive & Dropbox. This morning Google Drive fired up on my laptop and promptly threw the prompt above, and refused to sync in the latest changes from home. 😒

I use drive sync'ing to pull daily changes in files back and forth between work & home. And I frequently hit the ground running in the morning, and don't have time to monkey with mandated forced-marches to, "The Latest Revision™", that the above reflects. *eyeroll*

All of which means, having my data concurrently synced into Dropbox as well as GDrive, keeps me rolling when one of the vendor's unilaterally decides to  fold it's tent. Keeping some fault-tolerance in critical links helps yield up a smooth, impact free, and productive work flow. Regardless of vendor mandates...

And don't get me started on the New-n-Improved™, "Patch & Regression-testing's for Weenies!",  methodology behind releasing half-baked patches for apps like Office 365, Windows-itself, and any number of 'modern' rolling apps. 😒

Sure, when it comes to security - for yer granny - Herd Immunity's a thing, and has statistical benefits across thousands to millions of folks. But that doesn't help much when you're the individual that got floored by the vaccine. 😜  And as a power-user, it's more important that I get my work done quickly and with minimal hurdles, than it is that I be 'protected' from clicking idiot-exploit links that I'd never go near with a 10-foot-pole...

Yea, it'd be nice to have some choice on the patch timing.Patching reboots and downtime per month seems to have _doubled_ now that Office 365 runs it's own patch requests, out of sync with desktop patching... Used to be one set of Black Tuesday patches per month could get'r all done neatly. Ahh, for those less-thrilling days of yesteryear. :D

Is it just me, or have vendors gotten awfully dictatorial in the last 5 years?  Heh, welcome to, "One Size WILL Fit All!"