Virtual Server – Windows module installer / Preparing to configure Windows reboot loop

So I usually keep my virtual servers all nice and backed up just in case something dies. My production servers are backed up nightly, databases more frequently…. You get the drill. Backup or die.

Today I died. I have a server that I reserve for IT use. Holds some tools that scan my network, keep an inventory and host an internal blog for notes and whatnot. I don’t back that one up. Stupid, stupid, stupid. I figured it wasn’t REALLY production. Not THAT important. When it died, I sure realized how important it became. Enough of berating myself. On the the issue!

So the server rebooted itself. One of my other monitoring tools (nagios) let me know it went down, then came up, then went down….

When I attempted to connect, nothing. no website access, no RDP. The console through Hyper-V manager didn’t fly either. I’d see the message “Windows module installer is loading” followed by “Preparing to configure Windows”. Then the server would reboot. Rinse repeat ad nauseum.

I googled around some and found a number of faux fixes that didn’t work for me. mostly boot into safe mode and remove the offending hotfix. No dice. Then I remembered that I had downloaded Microsoft Deployment and Recovery tools from Technet. I gave that a shot. The automated recovery tools didn’t work. So I loaded up the System manager from the tools menu and just disabled the windows module installer. Low and behold it worked. It did load once, then reboot though. I quickly backed up my databases and files and got the heck out of dodge. Data saved!

Just a note, I was able to attach the .vhd file to another functioning server to get direct access to the file structure. Its just SO much easier to do database backups from the tools themselves than moving the flat files.

Server 2008 R2 and IPV6 slowdown – powershell fix!

So the other day a few friends and I were discussing some odd behavior that IPV6 has. I noticed early on that it plays havoc with my DNS between IPv4 and IPv6 workstations and their respective connections to servers. Steve Murawski mentioned that he had problems with bandwidth regarding IPv6 and its desire to tunnel over IPv4. Now I don’t have all the details but disabling IPv6 and its attendant interface objects seems to solve both the DNS and network slowdown issue. I slapped a quick and dirty powershell script together that allowed me to quickly update my servers to remove the IPv6 suite. I should note that the commands are also courtesy of Steve. Thanks Steve!

Some of you may have seen where I made a mistake with my script. this has been updated on 12-23. You can still use my original commands so long as you do them live at the command window. As a script, it fails. So enter the commands one at a time and all is well. This doesn’t help much unless its a script though. So the second block of code is updated to work as a script.

Enter-PSSession PUT COMPUTER NAME HERE
Write-Host "Disabling isatap"
netsh interface isatap set state disabled
Write-Host "Disabling teredo"
netsh interface teredo set state disabled
write-host "Disabling 6TO4"
netsh interface 6TO4 set state disabled

Write-Host "Showing interfaces"

netsh.exe interface ipv6 show interfaces
ipconfig
ipconfig /registerdns
Exit-PSSession

Just a note for me, if you see the system.dns exception, remember to show hidden devices and remove the extra 6t04 and teredo adapters.
Use this section if you want to execute this as a script.

#* Filename: KillStupidIPV6.ps1
#*=====================================================================
#* Created: [12-21-10]
#* Author: Tim Lemmers
#* email: tim@liquidclever.com
#
#*=====================================================================
#get the remote computer name from User input

$Srv = Read-Host "Type Machine name"




$session = new-pssession -ComputerName $Srv 
Invoke-command -session $session -scriptblock { netsh interface isatap set state disabled }  
Invoke-command -session $session -scriptblock { netsh interface teredo set state disabled } 
Invoke-command -session $session -scriptblock { netsh interface 6TO4 set state disabled } 
Invoke-command -session $session -scriptblock { netsh.exe interface ipv6 show interfaces } 
Invoke-command -session $session -scriptblock {  ipconfig } 
Invoke-command -session $session -scriptblock { ipconfig /registerdns }

I nearly forgot! you may need to enable remote access to your servers. the best way I’ve found to do so is this:

Enable-PSRemoting 

Hyper-v remote mmc and the RPC server

On the server run this one command:
netsh advfirewall set allprofiles state off
Then I had to go to my desktop
The problem might have been on my Windows 7 PC
1) Goto run: dcomcnfg
2) Plus out Component Services -> Computers -> my computer
3) Right click on the My Computer in the left pane and select COM Security
4) Under edit limits for access permissions, click on Anonymous and allow Remote Access
Then I was able to connect to the Hyper-v manager!

Update that powershell

Found a pretty cool link from the Powershell User group I attend.
http://code.msdn.microsoft.com/PowerShellPack

Keep that powershell alive with some added functionality from this powershell pack.

Ubuntu and the VI editor

So I’ve been using linux for a fairly log time now. By the process of forced association I’ve picked up a few simple tricks to make working with your linux distro easier. I’ll begin by showing you a few things I do to every linux box I build to make my life easier. Most recently I’ve been using Ubuntu, but they should work just as well for most linux flavors.

The VI editor – ubuntu issues
In ubuntu vi this has some odd behavior. I cribbed this little fix from Falko Timme at howtoforge.com and it works great.

sudo aptitude install vim-nox

You still launch vi with “vi”.

vi

with a space and the file name.
all is as it was before.

Mythtv with Hauppauge 2250 on ubuntu 9.04

How to install Hauppauge 2250 with Mythtv and Ubuntu

Date of install: 10/14/09
Date for writeup of howto 10/20/09
Date of last update to this howto: 11/06/09
The dates are so you can tell how relevant this guide still is.

Operating system: ubuntu 9.04 Desktop

Download the desktop version. Burn the .iso to a CD.  When you boot to the CD just follow the on screen instructions. Accepting the defaults will usually work.  There are lots of how tos on installing ubuntu so I won’t go into that here.

You’ll know pretty quick if you are having problems with your equipment, either the video won’t load, you won’t have sound. Ubuntu today has little trouble with most standard drivers.

The video capture card is a bit different which is why I’m writting this “how to” in the first place!
 
Boot into your shiny new Ubuntu operating system and run updates from the terminal window. You’ll find it under applications in the menu.  Enter the following into your terminal window, entering the root password when prompted:

sudo apt-get update

and reboot

sudo reboot

or use the GUI menu to reboot.

Follow the instructions below that lowsky put together. This is where I make sure to give him his due.
You don’t have to follow the link, I’ve included his instructions below.

Instructions for using HVR-2250 in MythTV (also works on HVR-2200 or any video capture card using the SAA7164 chipset) you need to be running Ubuntu 8.10 or higher for these drivers.

Enter this into your Terminal it is the code for the firmware and to install it

wget http://www.steventoth.net/linux/hvr22xx/22xxdrv_27086.zip
wget http://www.steventoth.net/linux/hvr22xx/HVR-12x0-14x0-17x0_1_25_25271_WHQL.zip
wget http://www.steventoth.net/linux/hvr22xx/extract.shCode
sh extract.sh
sudo cp *fw /lib/firmware

you need to install mercurial and build essential for the next steps

sudo apt-get install mercurial build-essential

then we need the driver using this command to fetch

hg clone http://kernellabs.com/hg/saa7164-stable/

now change to the directory

cd saa7164-stablethen run make
make

that will take some time, go grab a drink and wait it out, when it completes run this command

sudo make install

wait for that to complete and reboot

from the command line

sudo reboot

Install mythv now. Easy with apt-get.

sudo apt-get install mythtv mythtplugins

Follow the on screen prompts. you’ll have to put in a password for the mysql database. remeber this one because you’ll be asked for it again later. That’s about it for installing mythtv. The backend should start by itself.

cleanup:

I added mythfrontend to the applications that start on boot, disabled the screensaver and other power options that might cause my backend to not record or the frontend to shut down.  The last step was to configure my remote. this used to be easy for me. I had the older hauppauge grey remote. Jerod Wilson had wonderfull instructions on how to complete that install.

Now that he is doing mythdora (a great app that does most mythtv stuff for you, but doesn’t seem to work with the 2250) finding just the part to install my remote has become a pain.  This time around I built my very own remote from scratch.

I use a mceusb2 IR reciever. mostly because its got a nice long cord and has a better look than the IR recievers that come with most cards. I should note that I wasn’t able to

get the IR reciever that comes with the 2250 to work. At the time of this howto that portion of the driver doesn’t seem to work.
I ended up using irrecord to build my lirc.conf file from scratch. I just ran the program

irrecord

and followed the on screen instructions. The app will warn you some, but basically you have to hit “enter” twice before you start mashing buttons on your remote. Push all the buttons so you can see if any of them won’t work for you. Each button press will display some dots, apparently the number of dots varies for different remotes.

When that is complete, you’ll be prompted to enter a name for a button on your remote. I just used the lables for each button on my remote. this makes it a bit easier. When complete, don’t enter any more names and hit enter. The file irrecord.txt will be built for you in /etc/lirc.  Here’s the original mythv lircrc file that I got for the old hauppauge remote.

future link to file

I then edited it with “vi” and replaced the old name with the new ones I created for each function. Each function actually maps to the keyboard commands for mythtv. I have to admit, when I created my own file the remote is much easier to use than some of the prebuilt configurations I’ve used the the past. One last reboot and I was up and running. Let me know if you have any questions.

Powershell and Wsus client reset

Recently I had an issue with my Wsus server. I had to reinstall the software while keeping my old database. I noticed that some of my clients wouldn’t populate in the wsus server. They all seemed to be getting updates though. My first thought was to force the client to check in by running the following on the client machine.

wuauclt.exe /detectnow

Usually that would cause a client to detect the settings it got from the Group Policy I have set up. Then something really odd happened. The “missing” client would show up for a moment or two when I refreshed the wsus console, then dissapear again. The total device count in the wsus console would not increment.

After some banging around I found that I needed to reset the authorization on the client. My guess is that when I reinstalled the Wsus console some of the clients had invalid IDs.

The fix goes like this:
Remove the Registry value for HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate
-SusClientId
-SusClientIdValidation
Restart the Automatic Updates service (wuauserv)
Run

wuauclt.exe /resetauthorization /detectnow

from the command line

This solved my issue by re-adding the clients to the Wsus server. problem solved, right? Hardly! I had about 80 of these to do. I’ve been doing some powershell scripting with Steve over at MindOfRoot. I thought this would be a good chance to try writting a script on my own. What I came up with is clumsy and even spits out some errors but works like a charm. Feel free to post comments about how to clean it up.

#* Filename: DelRegValuesRemote.ps1
#*=====================================================================
#* Created: [3-31-10]
#* Author: Tim Lemmers
#* 
#
#*=====================================================================
#get the remote computer name from User input
$Srv = Read-Host "Type Machine name"

#define registry location
$key = "SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate"

#set registry hive HKLM
$type = [Microsoft.Win32.RegistryHive]::LocalMachine
$regKey = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey($type, $Srv)
$regKey = $regKey.OpenSubKey($key,$true)

#show the server and values found from the registry
Write-Host
Write-host "Server name"
Write-host "------"
$Srv
Write-Host
Write-Host "Values Before Delete"
Write-Host "------"
Foreach($val in $regKey.GetValueNames()){$val}
Read-Host “Press enter to continue”

#Delete the values found above
Foreach($val in $regKey.GetValueNames()){$regKey.DeleteValue($val)}

#show values after deletion to make sure they are gone
Write-Host
Write-Host "Values After Delete"
Write-Host "------"
Foreach($val in $regKey.GetValueNames()){$val}

#Restart the automatic updates service
(Get-WmiObject -computer $Srv Win32_Service -Filter "Name='wuauserv'").InvokeMethod("StopService",$null)
#pause a moment to let snarky services stop - I'm not sure this is needed
Start-Sleep -s 4

(Get-WmiObject -computer $Srv Win32_Service -Filter "Name='wuauserv'").InvokeMethod("StartService",$null)

cmd /c psexec.exe \\$Srv -d C:\windows\system32\wuauclt.exe /resetauthorization /detectnow

Write-Host “This AU client will now check for the Updates on the Local WSUS Server.”
Read-Host “Press enter to continue”
Return top