HOWTO: Backup and Restore FreeNAS Bootable USB Keys

I have several RAID5 NAS devices at home that are built upon the excellent FreeNAS.  One of the catches to using FreeNAS is that you must dedicate an entire drive to the operating system.  This means if you have say 3 1.5TB drives, you have to allocate (and therefore lose) 1.5TB of disk space to host a couple of hundred meg of operating system.  That’s obviously crazy and so the alternative is to simply boot off of USB.  I’ve been running this way for years and it’s been fantastic.  I got to thinking recently though – what happens if my USB key that I’m booting from fails?  I manually periodically backup the configuration so I can restore that but that only works once I’ve gone through all the trouble of rebuilding a new FreeNAS installation.  Wouldn’t it be easier if I could just clone the USB key and be done with it?

In my quest to do just this I discovered an excellent free piece of software called ImageUSB from Passmark. The software performed bit for bit duplication of a USB drive. It’s primary use case appears to be for mass duplication of USB drives (say to hand out at trade shows) but it has one feature in particular we want to take advantage of and that is the ability to save an image of a USB drive to a file.  Here’s how:

Continue reading

HOWTO: Quick and dirty Active Directory User Creation using Powershell

I had a situation where I needed to create a bunch of service accounts using pre-created complex passwords.  Now there are tons of Powershell scripts online to accomplish just this but in my brief searching they all seemed either too simplistic or far too complex.  So I decided instead to draft my own.  You can see the script is very simple.  You provide the username, password and description you want, run it and the accounts are automatically created and placed in the correct OU.

It’s beautiful in its simplicity. 🙂

Continue reading

HOWTO: Fix vRanger "The database transaction was rolled back" Error

Update: Andrew G in the comments posted a link to a newer version of this script for newer versions of vRanger.  You can find that link here:

http://en.community.dell.com/techcenter/data-protection/f/4784/t/19555569

This HOWTO describes how to resolve an issue with vRanger 6.0.1 whereby ALL jobs be it existing or new, incremental or full always fail with the same error: “The database transaction was rolled back” as demonstrated by this sample email log:

clip_image002

There are numerous possible causes for this error.  However, if you are having is for all backups, the most likely cause is your database is full. By default, vRanger 6.0.1 uses SQL 2005 Express MSDE.  Besides being free, it has the baked in limitation that no single database can exceed 4GB in size.  “The database transaction was rolled back” indicates you have maxed out your allocation.  How can you confirm this is your issue?

Continue reading

HOWTO: Automate Deployment of VMware Workstation VMs

This HOWTO describes the fastest way I’ve figured out thus far to deploy net-new Windows 2012 VMs using VMware Workstation for a Lab environment.  The first thing we need to do is build our "golden master" VM.  For our purposes, we will be using the Windows 2012 R2 180 Trial ISO which is freely available to download from Microsoft.  (Note, this script assumes you have already created a domain controller.  If you have not, then the domain joining functionality of this script will fail obviously.  I’ll likely create a new post on how to automate the deployment of that too at some point.)

  • Once you have the ISO, build a new VM and install Windows 2012 on the VM as you normally would
  • Run all windows updates on the VM to make it as current as possible
  • Make any other configuration changes you’d like.  My changes included:
  • Install Dot Net since many things will require it anyway
  • Set Keyboard refresh rate
  • Allow ICMP through the firewall
  • Disable IE Security Configuration
  • Enable Hidden files and file extensions
  • Add Notepad2 to the right click context menu
  • Copy my standalone tools folder to c:\bin
  • And more…

Continue reading

HOWTO: Cheap way to perform offsite backups to your own cloud

March 31st was World Backup Day (http://www.worldbackupday.com)  This special date is intended to help raise awareness to the importance of having backups of your data.  In my case, having served in the role of a Systems Administrator for many years now, I’ve repeatedly been saved by some kind of backup in my professional life and so have translated that knowledge into backing up the data of my personal life.

When you start thinking about and trying to implement backups in the home however, one issue quickly becomes apparent.  You can run all the backups in the world, but if you’re just writing to other places in your house, your data will still be lost in the event of a fire or burglary.  That’s when you start thinking about off-site backups.  Now this is a lot easier than it used to be thanks to the proliferation of cloud based file and backup services.  But any of these services require by definition that you place your faith into the continued operation and security of a third party entity.  For many people, this is a more than acceptable compromise considering to the ease of use of these products.  But what do you do if you are one of those people that would sleep better at night if you knew you had complete control over the hardware on the other end? 

The next problem that raises its head as you venture into the world of offsite backups is network bandwidth.  The reality is, it almost doesn’t matter if said cloud provider is offering you 10TB of space on their servers if you only have a 10mbit Internet connection as it simply takes far, far too long to move the data around at those speeds to be practical.  But that’s fine because for a large number of users, if they analyze the contents of their hard drives, they will find most of it can be replaced from other sources.  Operating System files can be reinstalled from an ISO, Steam games can be redownloaded, movies and music can be re-downloaded from the source you obtained them from.  Really, when you get down to it, you’ll likely find that your data requirements are likely much smaller than your used disk space would suggest.  If you then do a risk assessment on what you don’t want to lose versus cannot lose, you’ll likely find that you have a handful of documents, spreadsheets, and pictures that you consider truly irreplaceable.

Now that we’ve dropped the file size requirements down considerably, some new avenues for off-site backups begin to emerge and that is what brings us to the purpose of today’s HOWTO.

Chances are, we all know someone with an internet connection.  It could be a family member, a relative or a friend.  Chances are also good that this person has a 4 port router for their Internet and that it has 1 or more ports free.  What if we could with an incredibly minimal foot print leverage one of these ports for our offsite backups?  That’s what I’m going to show you how to do right now.

Continue reading

HOWTO: Easily add Powershell code to a WordPress Blog Post using Windows Live Writer

Have you ever wanted to publish Powershell code (or other languages) directly to a WordPress blog such that it automatically is syntax colored and line numbered?  Now you can!  Here’s how:

image

Continue reading

HOWTO: Remove inherited permissions from Symantec Enterprise Vault Archive

First let me say that I take back everything nice I ever said about Enterprise Vault.  It’s a Symantec product and that heritage shines through.

I was tasked with removing two permissions from an EV archive for  let’s call him “A User”.  Simple, right?  Ha!

I connected to our EV Server and opened the Admin Console.  I browsed to Archives, found A Users account, double clicked on it and went to permissions.  I find a SID and along with two additional users that I’d like to remove.  I select each of them and press remove. It tells me it can’t because “the permissions are automatically set“.

image

Continue reading

HOWTO: Auto add revision number to script with Subversion

As I have gotten increasingly comfortable with subversion and have started to develop a work flow, I ran into a problem. Most of the scripts I have added to my repository thus far have been self-contained scripts that’d I’d typically run straight from the repository folder.

But I recently ran into a use case where this doesn’t work. For the PowerGUI addon that I wrote, the production files must reside in %AppData%. This is of course not my repository folder so I needed a way to centrally manage my script in subversion and deploy to this new folder when I was ready.
The copy part was simple enough. I wrote a powershell script and placed it in the same SVN folder. It looks like this:

# Force copies files from repository to destination
# Copy; Deploy;

$SourcePath “c:\SVNScripts\Development\addon-scriptbrowser\”
$SourceFiles = @(“scriptbrowser.ps1”, “backuprepo.ps1”)
$DestPath “$Env:APPDATA\Quest Software\PowerGUI\Add-ons\Add-on.ScriptBrowser”
ForEach($File in $SourceFiles{ Copy-Item $SourcePath$File $DestPath -Force }

 

That’s easy enough. But for the centrally managed part, I realized that I could quickly run into confusion wondering if the version in the %AppData% folder was the most recent or not. Wouldn’t it be great if I could embed the version number directly into the file?  It turns out you can! Although it’s worth noting that it will be a little different than what you may be expecting at first blush.

Continue reading

HOWTO: Automated DHCP Backups

I created the script below to back up the DHCP servers in our environment, set it up as a nightly scheduled task and then frankly forgot about it.  That is until a few days ago when due to a power outage, we lost a DHCP server that refused to boot once power was restored.  Thanks to this script, restoring my DHCP server was trivially easy.  Since it so greatly saved the day for me, I wanted to make it available to you as well.

 

To restore from these backups, complete the following few steps:

1) Copy the backup file to the DHCP server you wish to restore to
2) Ensure the DHCP role is installed
3) open an administrative command prompt and run the following command:
netsh dhcp server import [path to file] all

The DHCP scope, configuration and lease information should now be restored.

Oh and I almost forgot to mention the best part.  This script does not require configuration.  Just run it and it’ll automatically go out and find all of the Active Directory authorized DHCP servers in your entire Domain and back them all up automatically to a central store.  (Ok, so you have to define that).  This worked especially well when after I rebuilt my new DHCP server I was surprised to discover it had already been backed up!

Continue reading

HOWTO: Implement Source Version Control for Powershell Scripts with PowerGUI

As my knowledge of Powershell has increased, so too has the length and complexity of the scripts I create. My current record for example is a 387 line script. How did I keep track of all of the changes in a script of this length?

Not very well I’m afraid. I knew there had to be a better way. I was familiar with the concept of Source Control from the likes of Team Foundation Server but had never looked into it. As I sat down to figure out what my solution would look like, I identified the following requirements:

  • The source control system, whatever it is must be integrated with PowerGUI as that is my editor of choice
  • It must offer some kind of online component either that I host myself or is hosted by a third party so I can maintain a single repository from both work and home

As you can see, my requirements are rather universal and I’m sure are shared by other aspiring Powershell script writers around the world. So you can imagine my surprise then when upon starting my research into options I was surprised to find remarkably little information on this subject. There were pockets of information but they were scattered at best and others simply did not seem to exist.

That’s why I created this HOWTO. It represents many, many hours of trial and error on my part to come up with a Powershell centric source management system. Not only will this guide identify what you need and explain HOW to install it but it will also delve into WHY it is configured this way. My pain is your gain. So with that out of the way, let’s get started!

Continue reading