Category: Microsoft

Remote Software Scanner

I was writing a script that would scan remote Windows systems and return their installed software, complete with version information (a requirement), and quickly discovered that the process was more arduous than I had originally anticipated.  How to pull it?  WMI?  Use PowerShell?  Glean the information from the registry?  I fiddled with each and, given that I was working with a broad array of OS levels and a mix of 32 and 64 bit, each option had its annoying pitfalls.

Sometimes it’s better to let someone else do the work.  This is one of those times.

I found the EMCO Network Software Scanner, which does exactly what I need and much more, and amazingly enough is also free!

So much props to EMCO.  I’ll be keeping their commercial products in mind down the road.

Export Windows Services to a CSV

Another nice trick – exporting a list of Windows Services to a CSV.  Using Powershell:

Or get fancy and pull based on status:

 

Windows 2003 Terminal Services Restriction

File this under Simple Stuff I Forget.

  1. Open Terminal Services Configuration in Administrative Tools
  2. In the left pane select Connections.  In the right pane, right click on RDP-Tcp and choose Properties
  3. Under the Permissions tab add or remove as necessary

I recommend utilizing the Remote Desktop Users security group builtin for good administrative karma.

 

Battling XP

I was given an old (old!) laptop to rebuild – Dell Latitude D630 – and short of putting Linux on it XP was the only way to go.  I dusted off an ancient XP Pro SP 3 disc and got to work.  Lo and behold after install I could not get it to run updates (“the website has encountered a problem”).  Hitting the site produced an error every time.  I downloaded and installed IE 8 to no avail.  I downloaded what one site claimed was the latest Windows Update package and it also produced an error.  I ran a variety of Microsoft’s “Fix-its,” none of which found any problems.

What I wound up doing is turning on Automatic Updates and then forcing a detection via a command prompt with:

wuauclt  /detectnow

This allowed it to pull enough to update the, er, Updater and get me over the hump.  It still wouldn’t pull updates from the site (rather than erroring it spun forever), so I headed to the MS fixit site:

http://support.microsoft.com/fixit/

And chose Windows, Install or Upgrade Software or Hardware, and Windows Update and then downloaded and ran the first Fix-it in the list (“Fix the problem with Microsoft Windows Update that is not working”).  This repaired 2 problems and allowed updates to begin working.

Kind of ridiculous, no?

Windows 7 “Black Screen of Death”

Upon logging into a friends Windows 7 laptop I was given to get working again I was presented with a solid black background and a navigation window opened to Computer.  No taskbar.  No desktop icons.  I figured explorer.exe wasn’t running, but a check in task manager proved me wrong.  I Googled around and discovered that though I hadn’t seen this problem before, it was not uncommon.  The fix turned out to be easy:

  1. Get into the registry via regedit.exe. You can launch regedit via task manager (which you can launch via ctrl+alt+esc or ctrl+alt+del and  then choosing it) by doing a File > Run.
  2. Head to HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon.
  3. Delete the Shell key.
  4. Reboot.

 

Sending an email with Task Scheduler using Powershell

Today at work I had a need to query a bunch of databases for a particular, er, thing, and then send that thing, if found, to myself via email.  I needed this to happen every morning. I decided, since we’re talking about a MS SQL and Windows 2003/2008 environment, that Powershell was the way to go.  And it was – until I popped it into scheduler.

When executed as a scheduled task, the email didn’t send.  Things before and after the email routine worked – the arrays populated, the log file filled – but the email didn’t go.  Firing it from a Powershell manually, everything went fine.

Being the stubborn arse I am, rather than get to Googling I started ripping things apart.  I had the query dump its results into a temp file that a separately scheduled script would open, parse, email and then clear.  Same result: run manually everything worked peachy. Scheduled, no email.

In the end the problem was irritatingly simple.  For some reason, when run as a scheduled task the script didn’t keep the socket open to the SMTP server long enough for a successful transmission.  I added a Start-Sleep -s 5 right after the SMTP command to give it a 5 second breather before continuing on.  Voila – email success.  How silly.

I think I’m going to like Powershell just fine.  Other than quirks like this, and getting used to the syntax, it’s easy enough – and it seems a lot of Windows specific stuff is streamlined, at least in comparison to my old go-to admin scripting languages.

0 Day Java Exploit. How to disable Java in your browser.

A JRE exploit has reportedly hit the wild. Context here.  Some kind Redditor has posted instructions on disabling the JRE in various browsers:

  • In Firefox : Press Firefox button -> Add-ons, go to Plugins and click the “Disable” button next to anything named “Java”.
  • In Chrome : Type in: “chrome://plugins/” into the address bar (no quotes). Scroll down to Java and click disable.
  • In Opera: Type in “opera:plugins” into the address bar (no quotes). Scroll down to:
    • Java(TM) Platform <click on> Disable.
    • Java Deployment Toolkit <click on> Disable.
  • In Internet Explorer:
    • Disable UAC (if enabled) and restart.
    • Open the Java app in Control Panel.
    • Go to advanced tab.
    • Expand Default Java for browsers.
    • The checkbox next to IE is grayed out.  Select Microsoft Internet Explorer and press spacebar. Click OK.
    • You can re-enable UAC and restart now.

 

“Expanding” a vmdk in VirtualBox

When I created my vmdk for my work virt in VirtualBox I made the mistaken assumption that by “dynamic” they meant the drive size would expand as necessary.  What they really meant was that the drive would expand as necessary within the limits of the initial drive size setting – which I stupidly set to 20 gig.

Expanding your vmdk for VirtualBox is really a misnomer.  You have to create a new one of the size you want and then clone your old one over to it.  It’s a little time consuming, but not hard.  Disclosure:  My host is running Windows 7 64 and my VM is running Windows 7 32.  Why bother?  It’s a security thing.

  1. Shut down your VM (obivously)
  2. Within the VirtualBox Manager, open the Settings for your existing VM, then choose Storage.
  3. Add a hard disk to the controller.  Make it the same type as your current disk, and make it the size you need.
  4. Once it’s created open a command prompt and head to the directory containing vboxmanage.exe – typically in C:\Program Files\Oracle\VirtualBox\
  5. Run the following, altering the paths to match your current and new vmdk files: 
  6. Twiddle thumbs.
  7. Once that’s complete, reopen the VirtualBox Manager and head back to Settings > Storage.  Add an existing hard disk to your controller, choosing your new drive.  Disconnect your original drive.
  8. Fire up your VM, from within it navigate to disk management, and expand away.