Category Archives: Windows

MySQL Powershell Backup Script

This is easily one of my most commonly used Powershell scripts, and a variation on it runs on my servers at least once a day.  It is essentially a very simple script: it contacts a specified MySQL server and then generates a .SQL backup files for each database found.  It prefixes each backup filename with the day name (monday, tuesday etc.) so if you run it on daily basis, it gives you a seven day backup rotation for your databases.

As always, the use of this script and the accompanying files is done entirely at your own risk. No guarantee either direct or indirect is implied regarding the security, stability, reliability, impact or performance of this script.

The zip file includes copies of mysqldump.exe and mysql.data.dll that you may require.  For details on how to configure and use the script, please see below.

Download the script (ZIP file)

Configuration

There are a few items you will need to configure before you can use the script in anger.  All of the configuration options are presented at the top of the script, so you don’t need to delve into the main chunk of code.

Backup Store Folder

This is where the MySQL backup files will be placed.  Please enter the path here, but do not include any trailing ‘\’

MySQL User Account

You will require a MySQL user account that has SHOW DATABASES, SELECT, LOCK TABLES and RELOAD permissions.  It is also highly advised – especially if performing backups from a remote machine – that this user’s permissions are also limit to readonly.

mysqldump Path

mysqldump is the application that actually creates the backup file.  It is typically installed with MySQL, but if you are running the script remotely or don’t know the file’s location, mysqldump.exe is included in the ZIP file.

MySQL .Net Connector

The script requires the MySQL .Net Connector driver.  This can either be installed, or you can directly load the DLL file.

Using the connector

  1. Download and install the connector from http://dev.mysql.com/downloads/connector/net/
  2. Uncomment Line 38 of the script.  This should say system.reflection.assembly]::LoadWithPartialName(“MySql.Data”)
Loading the library directly (the default method)
If you don’t wish to install the .Net driver, you can directly load the DLL file instead.  The required DLL file is included as part of the ZIP file.
  1. Uncomment line 43 of the script.  This should say Add-Type -Path “C:\Data\Backups\MySQL\MySql.Data.dll”
  2. Amend the path of line 43 to point to the location of the DLL file

Running the script

You can either run the script manually (through Powershell), or automate it through Task Scheduler.  To make life a little easier I tend to create a batch file containing the Powershell command and then invoke the batch file through the task scheduler.

The general format of the command to include in the batch file is

%windir%\System32\WindowsPowerShell\v1.0\powershell.exe “c:\backups\Generic7DayBackup.ps1”

Lastly…

This is by design a very simple script.  If you have any suggestions on how to improve it, please let me know by posting a comment.

 

Getting HDMI sound working on an ASUS ATI/AMD 4350

When I built my HTPC earlier this year, I replaced the elderly graphics card within the old chassis I was using with an ASUS 4350.  I don’t pretend to be anywhere near an expert on graphics cards, but the limited research I did led me to believe that this card would be ideal.  Relatively cheap, passively cooled and delivered full HD via HDMI.

What I did not know then, but what I discovered following installation, is that this card does not output sound via HDMI without some driver jiggery-pokery.  You would see a message similar to this one in the Sound properties dialog within Windows.

In short, neither the supplier driver nor the updated Catalyst drivers from AMD/ATI include the relevant Realtek audio driver.  The solution is relatively simple: you download and install the latest HDMI audio driver from Realtek.

This is what I did earlier this year and my HTPC worked without a hitch until I mistakenly updated the AMD/ATI Catalyst drivers through Microsoft Update which promptly broke it.  Needless to say, I hadn’t written down how to get this working so I had to find out all over again from scratch.

Disclaimer: It is not generally recommended to download and install drivers directly from OEMs.  Your first port of call should be the company that manufacturered the product you are using (in this case ASUS).  If you follow these steps, you are doing so entirely at your own risk.

  1. (Optional) Head over to AMD and grab the latest Catalyst drivers for the card (http://support.amd.com/us/psearch/Pages/psearch.aspx?type=2.4.1&product=2.4.1.3.38&contentType=GPU+Download+Detail)
  2. Go to Realtek’ High Definition downloads site (http://www.realtek.com.tw/downloads/downloadsCheck.aspx?Langid=1&PNid=14&PFid=24&Level=4&Conn=3&DownTypeID=3&GetDown=false).
  3. Check/tick the option Iaccept to the above and then click on the Next button.
  4. Scroll down the list ofWindows drivers until you find the entry ATI HDMI Audio Device (it will be in red text).  Click on one of the three download links to the right to download the driver.
    • There are a couple of possible gotchas when downloading
      1. Last time I tried, none of the US download locations worked.  The links just redirected back to step 2 above
      2. The downloads are FTP transactions that can take upto several minutes to stat.  So don’t worry if nothing happens immediately.
  5. Once downloaded, install the driver.  You should be prompted to restart your computer once completed, if not, do so anyway.
  6. Upon restart, sound may still appear to be disabled.  The trick here  is to pull out the HDMI connection and then replace it.  Once this is done, the HDMI sound connection should be detected and work.

 

The moral of this particular story:  Sometimes, it is necessary to document things you do with your home systems.

 

Remotely managing disks on Windows 2008/Hyper-V Server R2

As I’m mooting some hardware upgrades to my bash’n’crash Hyper-V server, I wanted to check out a few things with regards to it’s performance and general health.  I duly fired up Server Manager, but was thwarted when I tried to use Disk Management and got the message of RPC Server is unavailable.  I checked the Firewall, and the requisite rules (see below) were enabled.  I recycled the Virtual Disk Service and still had no luck.

After hunting around a while I found a Technet Forum post that covered this.  You have to enable the necessary inbound rules both on the server being managed and the managing computer.  Once I had done this, and restarted Server Manager, I could access Disk Management.

For reference, the two rules that need to be enabled are:

Remote Volume Management – Virtual Disk Service (RPC)

Remote Volume Management – Virtual Disk Service Loader (RPC)

As per the Technet post, I found that you don’t need the Remote Volume Management (RPC-EPMAP) rule enabled.  Needless to say, I only enabled both rules for the Domain firewall profile.

Getting System Information from the command line or Powershell

Although there are any number of tools available to gather and collate information regarding the configuration and composition of a computer, these are often overkill when all you wish to learn is one or more basic details like the processor type, memory, computer name etc.

A quick shortcut is to gather this information from the command line or Powershell.  Windows XP and later includes in the systeminfo utility. Typing this at the command prompt will produce information similar to this:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
c:\systeminfo
Host Name:                 SOMEPC
OS Name:                   Microsoft Windows 7 Ultimate
OS Version:                6.1.7100 N/A Build 7100
OS Manufacturer:           Microsoft Corporation
OS Configuration:          Member Workstation
OS Build Type:             Multiprocessor Free
Registered Owner:          SomeOwner
Registered Organization:
Product ID:                00428-321-7001132-70186
Original Install Date:     04/05/2009, 10:29:33
System Boot Time:          28/09/2009, 13:50:08
System Manufacturer:       Dell Inc.
System Model:              Latitude D820
System Type:               X86-based PC
Processor(s):              1 Processor(s) Installed.
[01]: x86 Family 6 Model 14 Stepping 8 GenuineIntel ~2000 Mhz
BIOS Version:              Dell Inc. A09, 04/06/2008
Windows Directory:         C:\Windows
System Directory:          C:\Windows\system32
Boot Device:               \Device\HarddiskVolume2
System Locale:             en-gb;English (United Kingdom)
Input Locale:              en-gb;English (United Kingdom)
Time Zone:                 (UTC) Dublin, Edinburgh, Lisbon, London
Total Physical Memory:     3,326 MB
Available Physical Memory: 858 MB
Virtual Memory: Max Size:  8,313 MB
Virtual Memory: Available: 5,500 MB
Virtual Memory: In Use:    2,813 MB
Page File Location(s):     C:\pagefile.sys
Domain:                    somedomain.lan
Logon Server:              \\SOMEDC
Hotfix(s):                 4 Hotfix(s) Installed.
[01]: KB958830
[02]: KB969497
[03]: KB970789
[04]: KB970858
Network Card(s):           3 NIC(s) Installed.
[01]: Intel(R) PRO/Wireless 3945ABG Network Connection
Connection Name: Wireless Network Connection
DHCP Enabled:    Yes
DHCP Server:     10.10.0.1
IP address(es)
[01]: 10.10.0.100
[02]: fe80::901:8ac7:5a6b:1f56
[02]: Broadcom NetXtreme 57xx Gigabit Controller
Connection Name: Local Area Connection
Status:          Media disconnected

If you are using Powershell – if not, why not? – the get-wmiobject win32_computersystem command will return rudimentary details regarding the host PC.

1
2
3
4
5
6
7
PoSH>get-wmiobject win32_computersystem
Domain              : somedomain.lan
Manufacturer        : Dell Inc.
Model               : Latitude D820
Name                : SOMEPC
PrimaryOwnerName    : SomeOwner
TotalPhysicalMemory : 3487690752

Windows Task Scheduler Keyset does not exist Error

Task Scheduler is one of those great little components that once you set it, you tend to forget it. One of the Windows 2003 servers I tend has been running scheduled tasks flawlessly for over a year until they suddenly stopped one day. Every time I went to open/edit and individual task’s properties, a dialog with the following message appeared:

1
2
3
General page initialization failed.
The specific error is:0x80090016: Keyset does not exist
An error has occurred attempting to retrieve task account information. You may continue editing the task object, but will be unable to change task account information.

A solution to this problem is not readily apparent, more so after the ubiquitous net search returns results that relate to Windows 2000, not 2003. After some playing, and with reference to the MS KB article http://support.microsoft.com/default.aspx?scid=kb;en-us;246183, I got the Task Scheduler working again doing the following:

  1. Stop the Cryptographic service
  2. Delete the contents of the C:\Documents and Settings\All Users\Application Data\Microsoft\Crypto\RSA\S-1-5-18 folder – as a precaution, I made a backup first.
  3. Start the Cryptographic service (a server restart may be required)
  4. Re-assign the Run As user account for every required scheduled task

Virtual Server to Hyper-V: Parallel port driver service failed to start error

I’m currently migrating a substantial number of virtual machines (VMs) from Virtual Server to Hyper-V server.  Although this is a fairly painless process, a common error for Windows VMs relates to the parallel port service.  The system eventlog error goes something like:

The parallel port driver service failed to start due to the following error:  The service cannot be started, either because it was disabled or because it has no enabled devices associated with it.

The reason for this is quite simple:  Virtual Server supported parallel ports, whilst Hyper-V doesn’t.  Typically, any basic VM created through VS will incorporate a virtual parallel port even once the Hyper-V integration components includes in the new HAL are installed.

There are two options here, you can either manually hack your way through Windows removing all traces of the parallel port, or much simpler, completely disable the parallel port service.  The latter is somewhat easier, and may be accomplished in a matter of minutes:

  1. Backup your registry
  2. Open Regedit
  3. Go to HKLM > System > CurrentControlSet > Services > ParPort
  4. Change the start parameter value to 4.
  5. Restart your server – optional, but I do this to confirm this has worked.

That’s it.  Upon the next restart, you should not get any service  alert for the parallel port.

Converted to Windows 7. Nearly.

Over the past decade I have played with any number of operating systems in various states of completeness.  Windows, Unix, Linux, Mac and even once Solaris (I was really bored).  In very few cases I was surprised.  In most cases – especially with Betas – I was left with the realisation that several hours of work had resulted in a useless PC.

One golden rule that I had enforced throughout was that I would never perform any of these bash’n’crash installations on my principal computer.  This is a rule that I followed solemnly until the 5th May 2009 when I installed Windows 7 RC on my stalwart Dell laptop.

This was not an off-the-cuff decision.  I had been running Windows 7 Beta on another machine for some time, and unlike Vista on my Dell, it hadn’t crashed no matter what I threw at it.  Furthermore, I had gotten increasingly frustrated with Windows Vista, an operating system I had previously liked.  Dire file copying performance , intermittent video driver issues and an overall lack of general responsiveness had left me with two options: reinstall Vista or do something else.  Do Something Else won.

Installation was a doddle, with all the drivers being automatically installed bar one.  It even found a video driver that was better than the nVidia one I had previously been using.

Two weeks in, and Windows 7 has behaved flawlessly.  It is fluid, fast and above all stable.  No video problems.  Files move to and from my servers without any issues.

Now I know that I am currently in the honeymoon period.  Sooner or later, the inevitable WinRot will set in (where Windows progressively gums itself up)  but Windows 7 is currently ticking all the right boxes.  It has taken Microsoft far too long, but they appear to finally have produced a version of Windows for the 21st Century.

Internet Explorer 8

Internet Exploder Explorer 8 has finally arrived, and unlike the Beta version, it hasn’t crashed my computer.  Yet.

Even 5 years ago, the arrival of a new browser was a big event.  Nowadays, with the presence of Firefox, Safari and Chrome, its’ release is a little bit of an anticlimax.  One hopes that that IE8 will be the browser equivalent of Windows 7: good software as it should have been in the first place.  I’ve had too many “interesting” experiences with IE7 over the last couple of years.

So why, the fuss.  Well, I’m not going to repeat or perform an in-depth review of IE8.  There are plenty of other websites out there doing that and I simply haven’t spent that much time with it yet.  I’m looking forward to IE8 as it finally promises a browser from Microsoft that it is in some way consistent and compliant with various web standards.  As many web designers/developers out there will tell you, the CSS rendering in previous versions of IE7 is either fundamentally broken, wrong or just plain inconsistent.  I have spent far too much time making websites IE friendly with the resultant CSS stylesheets being a discordant mess.

This is not to say that IE is the the only perpetrator out there.  My favoured browser, Mozilla Firefox, still doesn’t pass the ACID3 test.  Neither does Google Chrome. I haven’t tested in Safari as my patience with Apple software evaporated many moons ago.  I can honestly say that I haven’t use Opera in many years.

Consistency has actually improved over the past decade though.  I can remember back to 2000/1 when the standard practice at the company I was then working for was to develop separate stylesheets for each browser.  Each website would programmatically detect the user’s browser and return the corresponding stylesheet.  Thankfully, things have moved on.  Back then, we only realistically worried about Internet Explorer and Netscape Navigator (remember that?).  Now we have a diverse range of browsers, and importantly, host operating systems and hardware platforms.

So, back to Internet Explorer 8.  I will continue to play with it over the next couple of weeks, and I will post an update with my various comments and opinions in the near future.  Will it ever replace Firefox?  No.  I am currently well and truly sold on the sheer extensibility of Firefox.  I would be completely lost without extensions like PDF Download and Download StatusBar.  If I’m honest, usage of IE8 will probably be restricted to Windows Update and the occasional download from Microsoft that requires a Windows Genuine Authentication check.

SBS 2003 / Exchange 2003 Shutdown Script

Microsoft is quite clear about Microsoft Exchange and Active Directory being installed on the same server: don’t do it, it isn’t supported.  The only exception to this rule is Small Business Server, where out of necessity you will find both running side by side.

Unfortunately, Microsoft didn’t feel the need to address one of the problems behind the bar in SBS: the shutdown hang.  There is a good chance that if you go Start | Shutdown on an SBS server without any prior actions, the entire shut down process may take anything between 15 minutes and infinity to completed.

There is an easy to prevent this from happening is to shutdown all Exchange services prior to running Start | Shut Down.  This is easy enough to do via a good old batch script, a copy of which is enclosed below.

To use, simply run the batch script prior to restarting or shutting down your SBS 2003 server.

ECHO Stopping Exchanging Services
net stop MSExchangeES
net stop IMAP4Svc
net stop POP3Svc
net stop RESvc
net stop MSExchangeSRS
net stop MSExchangeMGMT
net stop MSExchangeMTA
net stop MSExchangeIS   /Y
net stop MSExchangeSA   /Y
ECHO Services Stopped

Vista Update

A quick update on the Vista front.  I wrote a while back about I succumbed to some of my earlier opinions on Vista and installed it on one of my principal laptops.

Well, since then I have fairly thrashing the computer on which Vista runs.  I have used recently and a whole range of tasks from writing complex ASP.Net websites to building Virtual Machines and it has yet to crash on me.  Thanks to some help found online, I have solved the NVidia graphics card issue – the performance rating was actually slower with the that latest NVidia drivers from Dell.  A quick driver hack later and the graphics are now much better.

The only new annoyance so far is that Vista tends to be more hardware intensive which in turn increases the component temperature which in turn causes the laptop cooling fan to run more.