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.

Friday, December 7, 2012

Windows Server Backups with Synology

We have had a problem performing backups of our Server 2008 R2 servers to our Synology Diskstation. For once, Windows actually had some good information on the problem.

Windows Server Backup failed with error "The version does not support this version of the file format" - Microsoft Reduce Customer Effort Center - Site Home - TechNet Blogs:

'via Blog this'

For those not familiar with Synology, it is a NAS device that basically runs on a pre-installed flavor of Linux and has a web-based desktop you can log into.

To apply the fix suggested by Microsoft:

  1. Login to the Synology box via Putty (login is as root)
  2. Copy smb.conf prior to making any changes
    1. cp /usr/syno/etc/smb.conf /usr/syno/etc/smb.conf.sav
  3. Edit the smb.conf file
    1. vi /usr/syno/etc/smb.conf
    2. Press i to enter insert mode
    3. Enter strict allocate = yes to the end of the [global] section
    4. Press Esc to exit insert mode
    5. Enter :x to save your changes
  4. Restart Samba
    1. Enter /usr/syno/etc/rc.d/S80samba.sh restart
  5. Run a test backup

Tuesday, November 20, 2012

Goodman NAS is running Ubuntu Server 12.10

Just finished doing some upgrades on the Dell Poweredge SC1425 I bought a few weeks back. Threw in an extra 2 TB and 500 GB hard drive I had lying around. It's tough only having one Internet connection in this place (the new house will be all wired-up), so I am at a stopping point for now.

The next thing to do is upgrade the BIOS, which is currently 2 versions behind. This will allow me to put in up to 16GB of RAM when it is done. After that, I'll turn on the Webmin and do some other boring stuff. Eventually all my movies will be put on this thing.

For anyone who is interested, I will be following this guide when upgrading the BIOS: http://bigbrovar.wordpress.com/2008/12/07/upgrade-downgrade-your-dell-bios-on-ubuntu/

UPDATE: used this guide http://www.ducea.com/2007/08/27/dell-bios-firmware-updates-on-debian/

and this one as well: http://www.naveoss.com/site/141/tutorials/linux/how-to-update-dell-bios-from-ubuntu

The BIOS upgrade for an SC1425 (version A03) is located here: http://linux.dell.com/repo/firmware/bios-hdrs/system_bios_ven_0x1028_dev_0x019a_version_a03/

Tuesday, October 16, 2012

Adding Hyper-V Powershell cmdlets

I'm brand-new to the virtualization game and this is a great step-by-step for enabling the Powershell cmdlets for Hyper-V.

Virtualization Admin

Wednesday, October 10, 2012

Powering-up The PowerShell

I have never, ever...ever-ever-ever used PowerShell before as I tend to hate all things programming. I've created basic batch files to delete backups, but those are relatively straightforward. For the task I was trying to tackle today, we need to download the differential backup files for one of our databases, unzip them, and then load them into SQL. I wrote this PowerShell script to do everything except the last part (loading into SQL), but tomorrow is a new day. Just a quick note beforehand- you have to use a program like 7-Zip for .bak files because the built-in extractor will not work (trust me, I tried). This is being done on Windows Server 2008 R2 using the latest version of PowerShell. &lf; > I am sure there is a prettier way to do this, but it works and I've got time to refine if it need be.


I have never, ever...ever-ever-ever used PowerShell before as I tend to hate all things programming. I've created basic batch files to delete backups, but those are relatively straightforward.

For the task I was trying to tackle today, we need to download the differential backup files for one of our databases, unzip them, and then load them into SQL. I wrote this PowerShell script to do everything except the last part (loading into SQL), but tomorrow is a new day.

Just a quick note beforehand- you have to use a program like 7-Zip for .bak files because the built-in extractor will not work (trust me, I tried). This is being done on Windows Server 2008 R2 using the latest version of PowerShell.


Set-Location -Path E:\folder\$dtoday

$dToday = Get-Date -Format "yyyyMMdd"

New-Item E:\folder\$dtoday -type directory -Force

$WebClient = New-Object System.Net.Webclient

$source = "http://www.SiteIWantToDownloadFrom.com"

$destination = "E:\folder\$dtoday\Diff.zip"

$WebClient.Credentials = New-Object System.Net.NetworkCredential("username","password")

$WebClient.DownloadFile($source,$destination)

$shell=new-object -com shell.application

$CurrentLocation=get-location

$CurrentPath=$CurrentLocation.path

$Location=$shell.namespace($CurrentPath)

C:\7z.exe x $destination -pMy7zipPassword -oE:\folder\$dtoday </script>

I am sure there is a prettier way to do this, but it works and I've got time to refine if it need be.