Archive for category PowerShell

Rename Multiple Restored Avamar SQL BAK Files

Posted by on Thursday, 5 January, 2012

This is a simple one liner that can be used to rename the default Avamar SQL Restored BAK from f-0 for multiple databases.

The Problem:

When restoring a database to a BAK file from Avamar it automatically restores the file into a folder named the Database and a file called “f-0”. That isn’t very helpful, especially if you have multiple databases you have restored. So I wrote a one line powershell script that you can use to rename every BAK file to the name of the database.

Get-ChildItemC:\RestoredDBs\ | foreach {Rename-Item-Path“C:\RestoredDBs\$_\f-0”-NewName“$_.bak”}

Script Steps:

1.       Make sure and change the directory where your restored BAK files/folders are located.

2.       The script just gets a list of all the directories in the folder and then performs a rename on the file inside called “f-0” to the foldername.bak.

3.       E.g., I have a database that I restored located at C:\ResotredDBs\DB1. Inside of this folder you have a file called “f-0”. This script will rename the “f-0” file to DB1.bak.

Hopefully you find this useful.

~Lane

Avamar Failed Backup Query Script–SQL

Posted by on Thursday, 2 June, 2011

Avamar is a great product, I love the backup technology, however, it is lacking in a few areas when it comes to data mining/reporting. I’m assuming DPA makes up for this lack of information gathering, but currently I do not have that luxury. I’ve had to come up with a different way to extract the required data from our Avamar environment. I do this using all the resources available from an Avamar perspective.

The issue I have tackled in this blog post is extracting data from SQL Agent Backups that have “Completed with Exceptions” (status_code 30005). In our environment our DBA’s take databases offline constantly, causing our backups to “Complete with Exceptions”. The problem is Avamar does not have a way to report on the client logs…meaning I had no way to see which databases were offline unless I opened each client log (remotely or via the Avamar GUI) and search through it for the word “offline”. Well not anymore, I wrote the following PowerShell script to automate this process. You can download it by clicking here.

Read the rest of this entry »

Automated Cisco UCS Server Provisioning part 2 (the meat!)

Posted by on Friday, 22 April, 2011

I have been working on this concept for a couple of months off and on in my spare time. The thought process was to create a script that performs the manual processes required to deploy an ESX (or Windows) server using Cisco UCS blades. This includes everything from generating the Service Profile to Storage Configuration to Installing the OS. Just like in my Part 1 post below are the script steps.

 Script Steps:

1. Generate Server from Cisco UCS Service Profile 

2. Gather WWNN, WWPN, and MAC of eth0 (eth0 is my 3rd boot option under boot policy)

3. Generate zoning configuration/push to MDS 9509

4. Create boot LUN

5. Create storage group

6. Create initiator record for new server on the boot hba/fabric (in my case its Fabric B)

7. Add initiator/server to storage group

8. Add boot LUN to storage group

9. Generate pxelinux.cfg and kickstart files

10. Boot Service Profile/Initiate PXE install

I am happy to say I have successfully completed all steps in the above process. Below is a high level breakdown of what the script is doing. I believe I have broken down the script process within each section well enough for you to understand what is happening, if not let me know and I will be happy to describe it in more detail. At the end I have a video of the process in action. Please note I did this more to see if it was possible, so in order to make this script perform multiple installs at the same time you will need to make some modifications, but it does work for a single deploy. You can download the Server Build Script by clicking here. You can download the bundle of scripts by clicking here.

Read the rest of this entry »

Simple DNS Zone Creation Script

Posted by on Friday, 22 April, 2011

This is a really simple DNS Zone Creation script, but since I don’t have a space limitation (ha, 5KB really matters) I thought I would put it here.

The Problem:

I needed an automated way to create primary zones in one of my 3 forests while creating conditional forward domains in my other 2 forests.

Read the rest of this entry »

Automate Cisco UCS Server Provisioning part 1

Posted by on Friday, 22 April, 2011

I was going to wait to post this script until it was 100% complete, but I realized that it might help people as is. I will continue to update this post (or make new ones) as I add the other sections to this script. Below is the final script algorithm I am going to implement.

Script Steps:

1.       Generate Server from Cisco UCS Service Profile

2.       Gather WWNN, WWPN, and MAC of eth0

3.       Generate zoning configuration/push to MDS 9509

4.       Create boot LUN

5.       Create storage group

6.       Create initiator record for new server on boot hba/fabric

7.       Add initiator/server to storage group

8.       Add boot LUN to storage group

9.       Generate pxelinux.cfg and kickstart files

10.   Boot Service Profile/Initiate PXE install

So now you kind of understand the process here is the pudding. Below this script generates the service profile from the service template and then generates the zoning configuration and puts it into text files.

Read the rest of this entry »

Automate EMC Avamar Client Install

Posted by on Friday, 22 April, 2011

Ever needed to deploy multiple EMC Avamar clients without having a deployment management software like SCCM? Well I had this scenario happen last week during my installation of our new EMC Avamar Grids. Looking around I found very little on this subject, so once again I decided to figure out a solution myself.

The approach is very straight forward and quite rudimentary but it got the job done. Below are the steps I used and the way I performed the install. However, this can be adapted to your use case quite easily, and the PowerShell script could be expanded to include Active Directory queries for a server list and then run the install on each host.

The Setup:

1.       Download PSExec from Sysinternals, and put it somewhere that is your path so it can be called from command window.

 

2.       Download all the different Avamar clients you need put them in a directory called C:\Avamar (on the box you will run the script from). The ones I use are:

·         Windows 32-bit (32bit.msi)

·         Windows 32-bit/System State Install (SystemState.msi)

·         Windows 64-bit (64bit.msi)

·         Windows 32-bit SQL (32bit-sql.msi)

·         Windows 64-bit SQL (64bit-sql.msi)

·         Windows 32-bit Exchange 2003 (exchange2k3.msi)

·         Windows 64-bit Exchange 2007/2010 (exchange2k7-2k10.msi)

 

You can name the files whatever you want, just make sure that they are set correctly in the PowerShell Script.

 

3.       Go find the avregister.bat file located in the C:\Program Files\avs\bin directory and copy it to the C:\Avamar directory.

a.       Edit the lines that reference “avagent” and change it to include the full path: “C:\Program Files\avs\bin\avagent.exe”

b.      This is because when psexec.exe runs it needs absolute file paths.

 

4.       Download the script and put it in your C:\Avamar directory, edit the script and change the $avamarUtilityNode variable to match your Avamar Utility Node hostname. You can download the script by click here.

Read the rest of this entry »

Automated Cisco UCS Backup

Posted by on Friday, 22 April, 2011

Recently my cohort and I have implemented a new Cisco UCS system. The system consists of dual chassis and multiple B200 M2 blade servers. As we were going through the initial install I noticed something that Cisco had left out….a scheduling engine for UCS Backups. Since I didn’t want to rely on manually backing the system up on a regular basis I decided to tackle this head on. Below is that journey..

Need to Know:

1.       The Cisco UCS backup jobs are named the hostname you enter as the backup target.

2.       This script does have a hard-coded Cisco UCS username/password (I’m working on figuring out if I can pass the logged in credential to Cisco UCS)

3.       I use an SCP server (Linux box) as the target, but this could be adapted using FTP or the other transfer protocols the UCS allows.

4.       4 backup types exist within Cisco UCS, you can run all of them or choose one. To see the different backup types click here.

Read the rest of this entry »