Alan's Blog

"Yeah. I wrote a script that will do that."

Get Downtime Using PowerShell

Posted on February 25th, 2017

I have been having problem with a computer with random reboots, and hanging on restart.  I wanted to know how long the computer had been unavailable.   I decided to use System Event ID 12 as the startup event for the purposes of my calculations.  The script takes these steps: 1) connect to the remote system and get the oldest event from the System Log.  Use this as the earliest start date for queries.  2) Collect all the startup events from user selected date.  3) For each startup event, collect the event immediately previous by record number.  4) Calculate the difference.

Get-DownTime.ps1 is the advanced function which gets the information.  It is the first function I have written which includes A Dot Source Reminder for Advanced Functions.

Script Text

Filed under Computing, Functions, PowerShell, Scripting, Windows Administration | No Comments »

Adding Code to Outlook Mail Messages

Posted on April 18th, 2016

I frequently send short PowerShell scripts in the body of Outlook messages.  The spell checker makes the text look lousy.  This tip will allow you to copy code from the PowerShell ISE (or other code editor) and insert it into an Outlook message with color intact and without spell checking:

  • Create a new email.  Set the format to HTML or Rich Text Format
  • Go to “insert” tab, click “object” button (it’s on the right)
  • Choose “OpenDocument Text” which will open a new embedded word document
  • Copy and paste your code

An example will look like this:

Outlook Code Example

This information is based on the instructions at:

Filed under Computing, General | No Comments »

Lync 2010 and Powershell – Toggle Mute, Export Participants

Posted on April 19th, 2015

I spent a lot of time in Lync conferences. There are two things about the Lync 2010 client which drive me nuts. The first is that there is no way to toggle your mute on and off without clicking on the microphone.  The second is that there is no easy way to export the list of participants without using OneNote.  Not until Lync 2013 you can toggle the mute button with Windows logo key+F4.

Being a scripting guy, I decided to try to solve both of these issues.  Some web searching led me to the Lync 2013 Software Developers Kit (SDK), which appears to have a method to mute and unmute.  I have Lync 2010, and so I downloaded the 2010 Lync SDK — which did not contain this method.  I was undeterred.  Why not try the 2013 SDK?  Well, it won’t install on your computer unless you have Lync 2013 (aka “Skype for Business”) installed on your computer.

I am a stubborn and determined man.  I watched the install steps using ProcMon, and found a setup file in a temp folder which I was able to launch.  With the 2013 SDK finally installed, I began looking at the interfaces for first the mute script, and then the participant script.  I was happy to see that the 2013 SDK works just fine with Lync 2010.

As far as I can tell no one else has been successful in scripting these two things with PowerShell.  I wrote Toggle-LyncMute.ps1, which toggles the Lync Mute on and off. Get-LyncParticipants.ps1 sends the participant list to your clipboard, including the phone numbers of dial in callers.  The updated (5/16/15) zip also includes Set-BRBAndLock.ps1, which sets your status to “Be Right Back” and locks your computer.  The files are in, which contains the necessary Microsoft SDK files from the Lync SDK and the scripts.

Extract the files in the “Files” folder to your computer so that the Lync-2013-SDK folder is found in the same location as the PowerShell PS1 files, example:

C:\MyUserName\My Documents\Scripts\

You may, but are not required to keep the files in the “Scripts” folder, so long as you keep the SDK files in the same folder as the script.

Then run the “Make Lync Shortcuts.vbs” script by double-clicking on it.  This will create shortcuts on your desktop to the PowerShell scripts.  Technical note: The shortcuts run with the -bypass parameter to ensure they run even if your executionpolicy is otherwise restricted.

Important note:  PowerShell uses the trusted locations from Internet Explorer. Some people have had problems running this when installing to a folder off the root of their local drive.  If you install to a restricted directory, you will get an error: HRESULT: 0x80131515.  I know that “..\My Documents\Scripts\” works.

As always, the scripts are commented.  The SDK files are signed by Microsoft.  You don’t have to understand PowerShell or vbScripts to make this work for you.

You may delete the “Make Lync Shortcuts.vbs” scripts after you are setup.

Script Zip

Tags: ,
Filed under Alan's Favorites, Computing, PowerShell, Scripting, VbScript | No Comments »

Upgrading from Server 2008 to Server 2012 R2 – Lessons Learned

Posted on August 16th, 2014

I am a member of a terrific IT User group, Carolina IT Professional Group.  This group is focused on educating its members, and giving back to the community.  But what really keeps people to the end are the terrific door prizes.  At the July meeting, I won a copy of Server 2012 R2.  I had been running Server 2008 on my home network and decided that it was time to upgrade.  The first lesson is this:  Server 2008 is the Vista codebase, and Server 2012 R2 is the Windows 8.1 codebase.  You can’t upgrade from Vista to 8.1, nor can you upgrade to 2012 R2 from 2008.

A fresh OS install on my old domain controller — and fresh drives – was appropriate.  I downloaded an evaluation copy of Server 2012 R2 and installed it on one of my more capable workstations.  I installed the appropriate roles, moving AD and DNS over to it.  No problem. After migrating the home directories onto a 2TB drive,  I went on and installed a boot disk to replace the aging mirrored 500GB drives in the old DC.

I then installed my licensed copy of 2012 R2, and went looking for my home directories.   To make a long story short,  lesson two is remembering about the necessity of importing “foreign drives” when you move a disk between Windows installs.  Somehow along the way the security for the home drive folders got hosed, and I took a significant amount of time resetting the ACLs.

I have installed AD and DNS on my permanent DC, and am waiting for things to calm down before I remove those roles from the temporary DC.

The last lesson is this:  Server 2012 R2 has the same idiot UI as 8 and 8.1.  I was happy to find that Classic Shell works just fine at restoring a traditional start menu to Server 2012 R2.  For my thoughts on 8.1 and Classic Shell, visit this blog post.

Update: I have installed the “Windows Server Essentials Experience” which allows me to remotely backup all my workstations.  For more information, visit

Filed under Active Directory, Computing, Windows Administration | No Comments »

Get User Information

Posted on March 3rd, 2013

NTUserInfo.vbs is a script based on Ralph Montgomery’s NTUser.wsf file. It gives a good summary about a user account, including user name, description, password status, and more.   I have made a number of changes, including the ability to copy the results to the clipboard using IE.  Rename from .txt to .vbs. New version 10/23/2009 allows entry of user name by samaccount name or UPN.   This entry was originally posted on March 23, 2009.  The new (3/3/13) alternative version, NTUserInfo_IE.vbs outputs to IE instead of a MSGBox.  This way you can copy the information to your clipboard.


Filed under Alan's Favorites, Computing, Scripting, VbScript, Windows Administration | No Comments »

Beep! Beep! Using the Bell to Locate a Server

Posted on June 21st, 2012

I got a message from a datacenter recently.  They were looking for a server.  Apparently the location information was mis-recorded (or forgotten).  They asked me whether I could make the computer beep so it could be located.  The DOS bell is CTRL-G.  Typing CTRL-G (ASCII 7) was easy in DOS days, but is a little challenging in Windows land.  I solved this by dusting off the WordPerfect Editor (see post here).  The resulting batch file beep.cmd loops the bell until you break or close the window.

You can also create a file from the command line with the bell:

copy con bell.bat
@echo off
echo ^G


They found the server pretty quickly.

Filed under Computing, Windows Administration | No Comments »

PortableApps and HFS, the HTTP File Server

Posted on June 9th, 2012

If you carry around a USB drive, or any device with USB storage (for example, your phone), you should be running PortableApps.  PortableApps is a menu of applications you like to take with you.  Visit if you have not already loaded up your USB drive.

Today, however, I wanted to take a moment to sing the praises of HFS, the HTTP File Server.  You can find it at  HFS is a very small (560KB) single file HTTP file server.  Do you need to quickly move a file from your PC to another PC or your tablet? Fire up HFS and in a few moments you will have a file server running on  your computer from which you can download files.  I use it to move files from my laptop to my tablet.

HFS is freeware, with no ads.  It has 5 stars from CNET and Softpedia.  You can make a donation,  via PayPal.  I did, and recommend that you do the same.

Tags: ,
Filed under Computing | 1 Comment »

Can’t find %HOMESHARE%\Favorites\.

Posted on December 12th, 2011

I tried to update Adobe Reader using my domain based admin account for elevation, and got this installer error “Can’t Find %HOMESHARE%\Favorites\.”  To fix it I opened RegEdit, navigated to HKCU\Environment, and added a new expandable string value named HOMESHARE, and pointed it to the proper location.

Filed under Computing, Windows Administration | No Comments »

Snooze via VBScript

Posted on May 25th, 2011

Snooze.vbs is the VBScript implementation of the VBA code I previously published to snooze pending Outlook reminders until 1 minutes before start time.

Filed under Computing, VbScript | No Comments »

Outlook VBA: Reply to All as Text

Posted on May 24th, 2011

I am a messaging old-timer, going back to the days of PINE and ELM and RBBSMail.  I like to reply to message like this:

>You said
I reply.

Actually the old days the mail client did it by initials so it looked like this:

YS>You said
AK>I reply.

I get a lot of HTML mail, which I see a a waste of storage. I reply as text with the the following code:

Sub ReplyAsText()
    Dim rply As Outlook.MailItem
    Dim item As Outlook.MailItem
    Dim retval As Integer
    Set item = GetCurrentItem()
    item.BodyFormat = olFormatPlain
    retval = MsgBox("Reply to all as text? No is just sender.", _
    vbYesNoCancel + vbQuestion + vbSystemModal, _
    "Reply to All?")
    If retval = vbCancel Then Exit Sub
    If retval = vbYes Then
        Set rply = item.ReplyAll
        Set rply = item.Reply
    End If

    item.Close olDiscard

    Set rply = Nothing
    Set item = Nothing
End Sub

Tags: ,
Filed under Computing | No Comments »

Please Note

All the scripts are saved as .txt files. Newer files have a "View Script" button which will let you save or open a script in notepad. For earlier posts, the easiest way to download with IE is to right click on the link and use "Save Target As". Rename file from Name_ext.txt to Name.ext.

To see a full post after searching, please click on the title.

PowerShell Scripts were written with Version 3 or 4.

https connections are supported.

All new users accounts must be approved, as are comments. Please be patient. It is pretty easy to figure out my email address from the scripts, and you are welcome to contact me that way.

Site Search



SQL Site

Bad Behavior has blocked 262 access attempts in the last 7 days.