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.Script Text
Archive for the ‘Computing’ Category
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:
This information is based on the instructions at: http://stackoverflow.com/questions/387453/how-do-you-display-code-snippets-in-ms-word-preserving-format-and-syntax-highlig
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 LyncScripts.zip, 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:
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
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 http://technet.microsoft.com/en-us/library/dn281793.aspx.
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 ^Z
They found the server pretty quickly.
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 www.portableapps.com 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 http://rejetto.com/hfs. 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.
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.
Actually the old days the mail client did it by initials so it looked like this:
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 Else Set rply = item.Reply End If rply.Display item.Close olDiscard Set rply = Nothing Set item = Nothing End Sub