Tuesday, 3 December 2013

Hyper-V 2012 R2 Export / Backup Script

Our backup tool of choice for our virtual infrastructure is Acronis Backup and Recovery Virtual Edition 11.5. However recently we had issues with it on our new Hyper-V 2012 R2 Servers.

We needed some backups while we fixed the issues with Acronis so I created this powershell script to export all the vms on each of our Hyper-V servers.

The script loops through all virtual machines on the local Hyper-V server and exports the virtual machine to the backup location specified in $path. The exported files are stored in a folder named with todays date inside a folder with the name of the virtual machine.

Example \\[path backup location]\testVM\2013-12-03\

--Start of script--

$path = ""
$vms = Get-VM
foreach ($vm in $vms) {
    $date = Get-Date -format “yyyy-MM-dd”
    $vmname = $vm.Name
    New-Item -ItemType Directory -Path $path\$vmname\$date -Force
    Export-VM -Name $vmname -Path $path\$vmname\$date\

--End of script--


This script has only been used on Hyper-V 2012 R2 servers as this version allows virtual machines to be exported while the virtual machine is running.

I have had to run the script on the local Hyper-V server. It doesn't work when ran from a remote console.

As with any script please test it before using in production as there is no warranty with this script.

Hope it helps some one.

Tuesday, 3 July 2012

Access 2000 web page showing HTTP 500 internal server error

We had to move our web server to a new Windows 2008 R2 server.

Everything copied over ok using Web Deploy to copy over IIS settings.

We had a problem with a website that had an Access 2000 backend database.

  • Connection issues
  • HTTP 500 internal server errror


Connection issues

Firstly it wouldn't connect at all. We found that this was due to the Win 2008 not having the correct Jet drivers. (It has changed to ACE).

HTTP 500 internal server errror

The next issue was that some pages were showing Server 500 errors when users clicked on them. It looked to be when users were trying to modify the database. In one case the issue was due to the database file becoming read only when it was moved to the new server. and in the other case it was because the lock file (.ldb) file had been copied over with the main database file. Once the lock file was deleted it all started to work as it should.

Hope this saves people some time

Sunday, 3 June 2012

Plain text email not wrapping correctly

It has been a while!

Now that summer have finally arrived in the UK I thought I should come out of my blogging hibernation.

Here is an interesting one to start with.

At work i have been developing a system that requires a log to be emailed to users. For this particular application I was developing in Delphi but the same problem seems to occur with many other languages.

The problem was that any emails that were sent from my system were stripped of there line breaks. At first I thought that the issue was in Delphi. After a bit of debugging I found that delphi was send the information correctly as separate lines. Even the outlook notification was displaying the line breaks correctly. However when the full email was opened all text appeared on one continious line.

After a frustrating few hours I found a stackoverflow post.

Some of the solutions suggested were:
  • Convert the email to HTML format so that '
    ' breaks can be inserted when required.
  • Add extra \r\n at the end of each line
  • Add %0D%0A at the end of each line
  • Add a (.) dot at the end of each line.
  • Re instated line breaks in Outlook by going into Format -> Unwrap text when viewing the email.
I decieded to go for the dot solution and it worked fine.

Hope this helps someone.

Friday, 12 August 2011

Windows Server 2008 File Share Clustering and OSX 10.4

At work we had to bring a Apple Mac back into service. Since decommissioning the Mac we have moved to a clustered file server on Windows 2008 R2.

We tried to get onto some shares on the Windows 2008 R2 clustered file server and got an error saying directory or file does not exist. Looking on the web we found that there were a number of people with the same problem. It seemed to be an issue with clustered file servers because we successfully connected to shares on non clustered file servers.

Our Apple Mac is on OSX 10.4 but the problem seemed to be more previlant on 10.5 AND 10.6.

We found a few posts that said that you could get around the problem by typing the port number in the 'Connect to server' option.

For example 'smb://[servername]:139/[share]' however this didn't solve our problem.

We finally found a work around by using a hidden ($) share in the path to the shared folder.

For example 'smb://[servername]/X$/path/to/share'

Hopefully this will help someone as it was an odd issue that took a bit of solving

Friday, 13 May 2011

Generate list of non repeating numbers in Excel

At work we had to create a list of new telephone numbers for employees.

We had a list of employees and had to assign a list of telephone extensions to the names. This had to be random and each number could only be used once.

The we did this was to copy the list of names into Excel. Then we used the RAND function to assign a random number between 0 and 1 to each name. After this we sorted the list by the newly created random number column. This gave us a random list of users. Finally we copied in the sorted list of telephone extensions into a column next to the employee name column. This gave a random list of telephone extensions to employee names without any any repetition.

Below is an example of what we did:

With a column for your list of names and a column for the random number you can randomise your list of names by simply ordering the list by the random number column. When you are happy with the random list of names then all you have to do is enter your sequential list of numbers into another column.