Monday, February 25, 2013

Powershell- I'm starting to like you...

Latest script that checks to see if a file has already been downloaded.

If the file is there, do nothing.

Else, download the file only IF it exists. This particular vendor does not upload their file on the same date/time every month, so it made it a little trickier.

$dMonth= (Get-Date).AddMonths(-1).ToString("yyyyMM")

$dMonth1= (Get-Date).AddMonths(-1).ToString("MMM")
$dYear= (Get-Date).AddMonths(-1).ToString("yyyy")

<# Download #>
If (Test-Path "E:\AutoCount\$dMonth.txt")
{
 Exit
}

Else
{
<# Set the Location #>
Set-Location -Path E:\AutoCount

<# The Webclient object does the downloading #>
$WebClient = New-Object System.Net.Webclient

<# File we want to download #>
$source = "https://downloads.autocount.com/AutoOneAC/$dMonth1 $dYear TX Statewide VehicleRegistrationsNoVIN.txt"

<# Where we want to download file to #>
$destination = "E:\AutoCount\$dMonth.txt"

<# Logon credentials #>
$WebClient.Credentials = New-Object System.Net.NetworkCredential("UserName","password")

$WebClient.DownloadFile($source,$destination)

Exit
}

Wednesday, January 2, 2013

Backups for Hyper-Visor Core Installation

One of the things I have been trying to wrap my head around is backing up our Hyper-Visor Core Server. The majority of Hyper-Visor installs are basically Windows Server with Hyper-Visor installed on top of it. In an attempt to improve performance, our current setup is just a physical server with Hyper-Visor "Core" installed on it and then we built the various virtual machines.

In Windows Server, it is an easy point-an-click task to setup backups using Windows Server Backup; however, Hyper-Visor Core is all command line (yay!!!!).

Once logged into the Hyper-Visor server, open a regular old command prompt and get ready to do the following:


  1. Install the backup command-line tools
  2. Setup your backup
To install the backup command-line tools, run the following command:

start /w ocsetup WindowsServerBackup

After a few seconds, the install will complete (there is no notification other than returning to the prompt) and you can now setup your backup. In my example, we want a full backup of EVERYTHING to our SAN everyday at 12:15 am. To set this up, type the following command:

wbadmin enable backup -addtarget:\\Location\Where\You\Want\To\Backup\To -schedule:00:15 -allCritical -systemState -vssFull -user:User_Account_for_Remote_Location -password:Password_For_Account -quiet

Press enter and you will see your backup being created. If everything went smoothly, you will see "The scheduled backup is enabled" confirming your settings.