Script - Create Source and Destination volumes, export NFS and mount to ESXi hosts

by on ‎2013-03-13 02:13 PM - edited on ‎2014-09-25 03:26 PM by allison Former NetApp Employee

This script started as a repeatable process to create a NetApp volume with our standard options.  From there, it morphed into not only creating the volume, but also creating the NFS exports, adding it the the ESX hosts, and setting up QSM to a DR Filer.  There are a few assumptions made in the script that work for our environment.  They will likely need to be tweaked for your individual environment, but thought I would put this out there for others to use.

The defaults for this script are to create a qtree for each volume with the same name, set no_atime_update to on and fractional_reserve to 0, set create_ and convert_ucode to on, set autogrow to vol size +200g with 20g growth, create hidden CIFS share.  For the DR side, it will suggest some defaults (such as appending sm_ to beginning of volume name, 105% vol size, mirror 1 hour after source snapshot, destination snapshot 1 hour after mirror, run both source and destination ASIS at same time if both are selected in the script.

Some options you may want to change are:

Lines 49-50 (path to text files with Filer lists)

Line 301 (default source hourly snapshots to keep)

Lines 430, 437, 444 (NFS export details)

Line 460 (default auto add vCenter datastores)

Lines 1118-1136 (ESX datastore creation selection)

Line 1333 (default DR volume name)

Line 1334 (default DR volume size)

Line 1404 (default DR hourly snapshots to keep)

Line 1422, 1457, 1484 (default DR ASIS on, compression and inline compress on 64-bit aggrs)

Lines 1748-1773 (default DR snapshot schedule - 1 hour after QSM)

Lines 2097-2122 (default DR ASIS schedule - same as source schedule)

Lines 2421-2446 (default QSM schedule - 1 hour after source snapshot)

Line 2630 (default autogrow max - vol size +200g)

Lines 2666-2668 (NFS export details)

Lines 2674-2682 (default source volume options)

Line 2697 (default autogrow increment - +20g)

Lines 2704-2717 (ESX datastore details)

Line 2753 (default DR autogrow max - vol size +200g)

Lines 2791-2799 (default DR volume options)

###############################################################################
#
# Volume Creation Script - Created by Stephen Kiser - 3/1/13                 ##
#
# Create Source and DR volumes with QSM and ESX datastore creation options  ##
#
##############################################################################

## NECESSARY SYSTEM CALLS ##
[void] [System.Reflection.Assembly]::LoadWithPartialName("System.Drawing")

[void] [System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms")

# Check for NetApp and VMware PowerShell modules/snapins
Function Load_Module($name) {

    If (!(Get-Module -Name $name)) {

        If (Get-Module -ListAvailable | Where { $_.name -eq $name })

            {Import-Module $name;Return $true}

        Else

            {Return $false;$global:x="2"}

    }

    Else

    {Return $true}

}

$moduleName = "DataONTAP"

$VMwareLoaded=$False

$snapIn = "VMware*"

Try {

    If (Load_Module $moduleName) {Write-Host "Loaded Module: $moduleName";$OnTAPLoaded=$true}

    Else {

        Write-Host "Failed to load $moduleName."

        Write-Host "You can install it from G:\Systems\Virtualization\Scripts\PowerShellAddIns"

        Write-Host "Unzip the DataONTAP.zip file to C:\Windows\System32\WindowsPowerShell\v1.0\Modules"

        Write-Host "Aborting script."}

}

Catch {Write-Host "Exception caught: $_"}

Add-PSSnapin $snapIn -ErrorAction SilentlyContinue

If ((Get-PSSnapin $snapIn) -eq $null) {

    Write-Host "This script requires VMware PowerCLI, but it was not found on this system."

    Write-Host "You can install it from G:\Systems\Virtualization\Scripts\PowerShellAddIns"

    Write-Host "Run the latest version of the VMware-PowerCLI executable"

    Write-Host "Aborting script."

    $global:x = "2"

}

Else {

    $vmware = $snapIn.substring(0,(($snapIn.length)-1))+" PowerCLI"

    Write-Host "Loaded SnapIn: $vmware"

    $VMwareLoaded=$true

}

# Continue if both required modules/snapins are loaded
If ($OnTAPLoaded -and $VMwareLoaded) {

    ## Filer List Variables
    $Filers = GC "C:\Scripts\Vol_Create\filers.txt"

    $DR_filers = GC "C:\Scripts\Vol_Create\dr_filers.txt"

    ## FUNCTIONS ##
    Function Select_Filer ($Filers) {

        # Get the Filer to create the source volume on
        $form = New-Object System.Windows.Forms.Form

        $form.Text = "Filer Selection"

        $form.Size = New-Object System.Drawing.Size(300,200)

        $form.StartPosition = "CenterScreen"

        $L_Filer = New-Object System.Windows.Forms.Label

        $L_Filer.Location = New-Object System.Drawing.Size(10,20)

        $L_Filer.Size = New-Object System.Drawing.Size(280,20)

        $L_Filer.Text = "What Filer do you want to create the volume on?"

        $form.Controls.Add($L_Filer)

        $CB_Filer = New-Object System.Windows.Forms.ComboBox

        $CB_Filer.DropDownStyle = "DropDownList"

        ForEach ($Filer in $Filers) {$CB_Filer.Items.Add($Filer)}

        $CB_Filer.Location = New-Object System.Drawing.Size(10,40)

        $CB_Filer.Size = New-Object System.Drawing.Size(260,20)

        $form.Controls.Add($CB_Filer)

        $OKButton = New-Object System.Windows.Forms.Button

        $OKButton.Location = New-Object System.Drawing.Size(75,120)

        $OKButton.Size = New-Object System.Drawing.Size(75,23)

        $OKButton.Text = "OK"

        $OKButton.Add_Click({$global:MyFiler=($CB_Filer.SelectedItem.ToLower()).ToString();$global:x="0";$form.Close()})

        $form.Controls.Add($OKButton)

        $CancelButton = New-Object System.Windows.Forms.Button

        $CancelButton.Location = New-Object System.Drawing.Size(150,120)

        $CancelButton.Size = New-Object System.Drawing.Size(75,23)

        $CancelButton.Text = "Cancel"

        $CancelButton.Add_Click({$global:x="2";$form.Close()})

        $form.Controls.Add($CancelButton)

        $form.KeyPreview = $True

        $form.Add_KeyDown({if ($_.KeyCode -eq "Enter")

            {$global:MyFiler=($CB_Filer.SelectedItem.ToLower()).ToString();$global:x="0";$form.Close()}})

        $form.Add_KeyDown({if ($_.KeyCode -eq "Escape")

            {$global:x="2";$form.Close()}})

        $form.Topmost = $True

        $form.Add_Shown({$form.Activate()})

        [void] $form.ShowDialog()

    }

    Function Select_Aggr ($aggr1, $aggrs) {

        # Get the aggregate to create the volume on
        # Function Variables
        $agrList = $aggr1

        $agrList1=$aggrs

        # Function Definitions
        $form = New-Object System.Windows.Forms.Form

        $tlp_MainTable = New-Object System.Windows.Forms.TableLayoutPanel

        $gb_SelectAggr = New-Object System.Windows.Forms.GroupBox

        $cb_Aggr = New-Object System.Windows.Forms.ComboBox

        $gb_AggrList = New-Object System.Windows.Forms.GroupBox

        $tb_Aggrs = New-Object System.Windows.Forms.RichTextBox

        $OKButton = New-Object System.Windows.Forms.Button

        $CancelButton = New-Object System.Windows.Forms.Button

        $tlp_MainTable.SuspendLayout()

        $gb_SelectAggr.SuspendLayout()

        $gb_AggrList.SuspendLayout()

        $form.SuspendLayout()

        #tlp_MainTable
        $tlp_MainTable.ColumnCount = 1

        [void]$tlp_MainTable.ColumnStyles.Add((New-Object System.Windows.Forms.ColumnStyle([System.Windows.Forms.SizeType]::Percent, 100)))

        $tlp_MainTable.Controls.Add($gb_SelectAggr, 0, 0)

        $tlp_MainTable.Controls.Add($gb_AggrList, 0, 1)

        $tlp_MainTable.Controls.Add($OKButton, 0, 2)

        $tlp_MainTable.Dock = [System.Windows.Forms.DockStyle]::Fill

        $tlp_MainTable.Location = New-Object System.Drawing.Point(0, 0)

        $tlp_MainTable.Name = "tlp_MainTable"

        $tlp_MainTable.RowCount = 3

        [void]$tlp_MainTable.RowStyles.Add((New-Object System.Windows.Forms.RowStyle([System.Windows.Forms.SizeType]::Percent, 15)))

        [void]$tlp_MainTable.RowStyles.Add((New-Object System.Windows.Forms.RowStyle([System.Windows.Forms.SizeType]::Percent, 75)))

        [void]$tlp_MainTable.RowStyles.Add((New-Object System.Windows.Forms.RowStyle([System.Windows.Forms.SizeType]::Percent, 10)))

        $tlp_MainTable.Size = New-Object System.Drawing.Size(650, 500)

        #gb_SelectAggr
        $gb_SelectAggr.Controls.Add($cb_Aggr)

        $gb_SelectAggr.Dock = [System.Windows.Forms.DockStyle]::Fill

        $gb_SelectAggr.Location = New-Object System.Drawing.Point(3, 3)

        $gb_SelectAggr.Name = "gb_SelectAggr"

        $gb_SelectAggr.Size = New-Object System.Drawing.Size(600, 20)

        $gb_SelectAggr.TabStop = $false

        $gb_SelectAggr.Text = "Select Aggregate To Create The New Volume On"

        #$cb_Aggr
        $cb_Aggr.AutoSize = $true

        $cb_Aggr.Location = New-Object System.Drawing.Point(6, 20)

        $cb_Aggr.Name = "cb_Aggr"

        $cb_Aggr.DropDownStyle = "DropDownList"

        $cb_Aggr.Size = New-Object System.Drawing.Size(260, 20)

        $cb_Aggr.TabIndex = 1

        ForEach ($ag in $agrList1 | Sort Name) {$cb_Aggr.Items.Add($ag.Name)}

        #gb_AggrList
        $gb_AggrList.Controls.Add($tb_Aggrs)

        $gb_AggrList.Dock = [System.Windows.Forms.DockStyle]::Fill

        $gb_AggrList.Location = New-Object System.Drawing.Point(3, 40)

        $gb_AggrList.Name = "tb_AggrList"

        $gb_AggrList.Size = New-Object System.Drawing.Size(600, 300)

        $gb_AggrList.TabStop = $false

        $gb_AggrList.Text = "List Of Available Aggregates"

        #tb_Aggrs
        $tb_Aggrs.AutoSize = $True

        $tb_Aggrs.Location = New-Object System.Drawing.Point(6, 20)

        $tb_Aggrs.Dock = [System.Windows.Forms.DockStyle]::Fill

        $tb_Aggrs.Name = "tb_Aggrs"

        $tb_Aggrs.Font = New-Object System.Drawing.Font("Lucida Console",9.5)

        $tb_Aggrs.Size = New-Object System.Drawing.Size(600, 300)

        $tb_Aggrs.TabStop = $false

        $tb_Aggrs.ReadOnly = $true

        $tb_Aggrs.AppendText("`nAggregate Name`tAvailable Size (GB)`tTotal Size (GB)`tBlock Type`n")

        $tb_Aggrs.AppendText("--------------`t-------------------`t---------------`t----------`n")

        ForEach ($agr in $agrList) {

            If($agr.BlockType -ne "64_bit") {$agr.BlockType = "32_bit"}

            $len = $agr.Name.Length

            If ($len -lt 7) {$tb_Aggrs.AppendText($agr.Name+"`t`t`t"+[Math]::Truncate($agr.SizeAvailable / 1GB)+"`t`t`t`t"+[Math]::Truncate($agr.SizeTotal / 1GB)+"`t`t`t"+$agr.BlockType+"`n")}

            ElseIf ($len -gt 11) {$tb_Aggrs.AppendText($agr.Name+"`t"+[Math]::Truncate($agr.SizeAvailable / 1GB)+"`t`t`t`t"+[Math]::Truncate($agr.SizeTotal / 1GB)+"`t`t`t"+$agr.BlockType+"`n")}

            Else {$tb_Aggrs.AppendText($agr.Name+"`t`t"+[Math]::Truncate($agr.SizeAvailable / 1GB)+"`t`t`t`t"+[Math]::Truncate($agr.SizeTotal / 1GB)+"`t`t`t"+$agr.BlockType+"`n")}

        }

        #OKButton
        $form.Controls.Add($OKButton)

        $OKButton.Location = New-Object System.Drawing.Point(250,425)

        $OKButton.Size = New-Object System.Drawing.Size(75,23)

        $OKButton.Text = "OK"

        $OKButton.TabIndex = 2

        $OKButton.Add_Click({$global:MyAggr=($cb_Aggr.SelectedItem.ToLower()).ToString();$global:x="0";$form.Close()})

        #CancelButton
        $CancelButton.Location = New-Object System.Drawing.Point(325,425)

        $CancelButton.Size = New-Object System.Drawing.Size(75,23)

        $CancelButton.Text = "Cancel"

        $CancelButton.TabIndex = 3

        $CancelButton.Add_Click({$global:x="2";$form.Close()})

        $form.Controls.Add($CancelButton)

        #Form
        $form.AutoScaleDimensions = New-Object System.Drawing.SizeF(6, 13)

        $form.AutoScaleMode = [System.Windows.Forms.AutoScaleMode]::Font

        $form.AutoSize = $True

        $form.ClientSize = New-Object System.Drawing.Size(600, 450)

        $form.Controls.Add($tlp_MainTable)

        $form.Name = "Form"

        $form.StartPosition = "CenterScreen"

        $form.Text = "Aggregate Selection"

        #Final Layout
        $form.KeyPreview = $True

        $form.Add_KeyDown({if ($_.KeyCode -eq "Enter")

            {$global:MyAggr=$cb_Aggr.SelectedItem.ToString();$global:x="0";$form.Close()}})

        $form.Add_KeyDown({if ($_.KeyCode -eq "Escape")

            {$global:x="2";$form.Close()}})

        $tlp_MainTable.ResumeLayout($false)

        $tlp_MainTable.PerformLayout()

        $gb_SelectAggr.ResumeLayout($false)

        $gb_SelectAggr.PerformLayout()

        $gb_AggrList.ResumeLayout($false)

        $gb_AggrList.PerformLayout()

        $form.ResumeLayout($false)

        [void]$form.ShowDialog()

    }

    Function Vol_Details (){

        # Get the volume details
        $form = New-Object System.Windows.Forms.Form

        $form.Text = "Volume Details"

        $form.Size = New-Object System.Drawing.Size(295,320)

        $form.StartPosition = "CenterScreen"

        $L_VName = New-Object System.Windows.Forms.Label

        $L_VName.Location = New-Object System.Drawing.Size(10,10)

        $L_VName.Size = New-Object System.Drawing.Size(280,20)

        $L_VName.Text = "What name do you want to give to the volume?"

        $form.Controls.Add($L_VName)

        $TB_VName = New-Object System.Windows.Forms.TextBox

        $TB_VName.Location = New-Object System.Drawing.Size(10,30)

        $TB_VName.Size = New-Object System.Drawing.Size(260,20)

        $form.Controls.Add($TB_VName)

        $L_VSize = New-Object System.Windows.Forms.Label

        $L_VSize.Location = New-Object System.Drawing.Size(10,50)

        $L_VSize.Size = New-Object System.Drawing.Size(280,20)

        $L_VSize.Text = "How large (in GB) do you want the volume to be?"

        $form.Controls.Add($L_VSize)

        $TB_VSize = New-Object System.Windows.Forms.TextBox

        $TB_VSize.Location = New-Object System.Drawing.Size(10,70)

        $TB_VSize.Size = New-Object System.Drawing.Size(260,20)

        $form.Controls.Add($TB_VSize)

        $L_SnapRes = New-Object System.Windows.Forms.Label

        $L_SnapRes.Location = New-Object System.Drawing.Size(10,90)

        $L_SnapRes.Size = New-Object System.Drawing.Size(280,20)

        $L_SnapRes.Text = "What % of the vol should be reserved for SnapShots?"

        $form.Controls.Add($L_SnapRes)

        $TB_SnapRes = New-Object System.Windows.Forms.TextBox

        $TB_SnapRes.Location = New-Object System.Drawing.Size(10,110)

        $TB_SnapRes.Size = New-Object System.Drawing.Size(260,20)

        $TB_SnapRes.Text="0"

        $form.Controls.Add($TB_SnapRes)

        $L_SnapSched = New-Object System.Windows.Forms.Label

        $L_SnapSched.Location = New-Object System.Drawing.Size(10,130)

        $L_SnapSched.Size = New-Object System.Drawing.Size(280,20)

        $L_SnapSched.Text = "How many SnapShots do you want to keep?"

        $form.Controls.Add($L_SnapSched)

        $L_SnapW = New-Object System.Windows.Forms.Label

        $L_SnapW.Location = New-Object System.Drawing.Size(10,152)

        $L_SnapW.Size = New-Object System.Drawing.Size(46,20)

        $L_SnapW.Text = "Weekly:"

        $form.Controls.Add($L_SnapW)

        $TB_SnapW = New-Object System.Windows.Forms.TextBox

        $TB_SnapW.Location = New-Object System.Drawing.Size(56,150)

        $TB_SnapW.Size = New-Object System.Drawing.Size(25,20)

        $TB_SnapW.Text="0"

        $form.Controls.Add($TB_SnapW)

        $L_SnapN = New-Object System.Windows.Forms.Label

        $L_SnapN.Location = New-Object System.Drawing.Size(100,152)

        $L_SnapN.Size = New-Object System.Drawing.Size(45,20)

        $L_SnapN.Text = "Nightly:"

        $form.Controls.Add($L_SnapN)

        $TB_SnapN = New-Object System.Windows.Forms.TextBox

        $TB_SnapN.Location = New-Object System.Drawing.Size(145,150)

        $TB_SnapN.Size = New-Object System.Drawing.Size(25,20)

        $TB_SnapN.Text="0"

        $form.Controls.Add($TB_SnapN)

        $L_SnapH = New-Object System.Windows.Forms.Label

        $L_SnapH.Location = New-Object System.Drawing.Size(185,152)

        $L_SnapH.Size = New-Object System.Drawing.Size(45,20)

        $L_SnapH.Text = "Hourly:"

        $form.Controls.Add($L_SnapH)

        $TB_SnapH = New-Object System.Windows.Forms.TextBox

        $TB_SnapH.Location = New-Object System.Drawing.Size(230,150)

        $TB_SnapH.Size = New-Object System.Drawing.Size(25,20)

        $TB_SnapH.Text="8"

        $form.Controls.Add($TB_SnapH)

        $L_Export = New-Object System.Windows.Forms.Label

        $L_Export.Location = New-Object System.Drawing.Size(10,180)

        $L_Export.Size = New-Object System.Drawing.Size(120,20)

        $L_Export.Text = "Create NFS Export?"

        $form.Controls.Add($L_Export)

        $L_YesExp = New-Object System.Windows.Forms.Label

        $L_YesExp.Location = New-Object System.Drawing.Size(165,180)

        $L_YesExp.Size = New-Object System.Drawing.Size(30,20)

        $L_YesExp.Text = "Yes"

        $form.Controls.Add($L_YesExp)

        $C_YesExp = New-Object System.Windows.Forms.CheckBox

        $C_YesExp.Location = New-Object System.Drawing.Size(195,178)

        $C_YesExp.Size = New-Object System.Drawing.Size(20,20)

        $C_YesExp.UseVisualStyleBackColor = $True

        $C_YesExp.DataBindings.DefaultDataSourceUpdateMode = 0

        $form.Controls.Add($C_YesExp)

        $L_NoExp = New-Object System.Windows.Forms.Label

        $L_NoExp.Location = New-Object System.Drawing.Size(220,180)

        $L_NoExp.Size = New-Object System.Drawing.Size(30,20)

        $L_NoExp.Text = "No"

        $form.Controls.Add($L_NoExp)

        $C_NoExp = New-Object System.Windows.Forms.CheckBox

        $C_NoExp.Location = New-Object System.Drawing.Size(250,178)

        $C_NoExp.Size = New-Object System.Drawing.Size(20,20)

        $C_NoExp.UseVisualStyleBackColor = $True

        $C_NoExp.DataBindings.DefaultDataSourceUpdateMode = 0

        $form.Controls.Add($C_NoExp)

        $L_Asis = New-Object System.Windows.Forms.Label

        $L_Asis.Location = New-Object System.Drawing.Size(10,200)

        $L_Asis.Size = New-Object System.Drawing.Size(140,20)

        $L_Asis.Text = "Enable Storage Efficiency?"

        $form.Controls.Add($L_Asis)

        $L_YesAsis = New-Object System.Windows.Forms.Label

        $L_YesAsis.Location = New-Object System.Drawing.Size(165,200)

        $L_YesAsis.Size = New-Object System.Drawing.Size(30,20)

        $L_YesAsis.Text = "Yes"

        $form.Controls.Add($L_YesAsis)

        $C_YesAsis = New-Object System.Windows.Forms.CheckBox

        $C_YesAsis.Location = New-Object System.Drawing.Size(195,198)

        $C_YesAsis.Size = New-Object System.Drawing.Size(20,20)

        $C_YesAsis.UseVisualStyleBackColor = $True

        $C_YesAsis.DataBindings.DefaultDataSourceUpdateMode = 0

        $form.Controls.Add($C_YesAsis)

        $L_NoAsis = New-Object System.Windows.Forms.Label

        $L_NoAsis.Location = New-Object System.Drawing.Size(220,200)

        $L_NoAsis.Size = New-Object System.Drawing.Size(30,20)

        $L_NoAsis.Text = "No"

        $form.Controls.Add($L_NoAsis)

        $C_NoAsis = New-Object System.Windows.Forms.CheckBox

        $C_NoAsis.Location = New-Object System.Drawing.Size(250,198)

        $C_NoAsis.Size = New-Object System.Drawing.Size(20,20)

        $C_NoAsis.UseVisualStyleBackColor = $True

        $C_NoAsis.DataBindings.DefaultDataSourceUpdateMode = 0

        $form.Controls.Add($C_NoAsis)

        $OKButton = New-Object System.Windows.Forms.Button

        $OKButton.Location = New-Object System.Drawing.Size(68,230)

        $OKButton.Size = New-Object System.Drawing.Size(75,23)

        $OKButton.Text = "OK"

        $OKButton.Add_Click({

            $global:vName=$TB_VName.Text;

            $global:vSize=$TB_VSize.Text;

            $global:snapRes=$TB_SnapRes.Text;

            $global:snapW=$TB_SnapW.Text;

            $global:snapN=$TB_SnapN.Text;

            $global:snapH=$TB_SnapH.Text;

            $global:x="0";

            If ($C_YesExp.CheckState -eq "1") {$global:YesExp = "1"} Else {$global:YesExp = "0"};

            If ($C_YesAsis.CheckState -eq "1") {$global:YesAsis = "1"} Else {$global:YesAsis = "0"};

            $form.Close()})

        $form.Controls.Add($OKButton)

        $CancelButton = New-Object System.Windows.Forms.Button

        $CancelButton.Location = New-Object System.Drawing.Size(145,230)

        $CancelButton.Size = New-Object System.Drawing.Size(75,23)

        $CancelButton.Text = "Cancel"

        $CancelButton.Add_Click({$global:x="2";$form.Close()})

        $form.Controls.Add($CancelButton)

        $form.KeyPreview = $True

        $form.Add_KeyDown({if ($_.KeyCode -eq "Enter"){

            $global:vName=$TB_VName.Text;

            $global:vSize=$TB_VSize.Text;

            $global:snapRes=$TB_SnapRes.Text;

            $global:snapW=$TB_SnapW.Text;

            $global:snapN=$TB_SnapN.Text;

            $global:snapH=$TB_SnapH.Text;

            $global:x="0";

            If ($C_YesExp.CheckState -eq "1") {$global:YesExp = "1"} Else {$global:YesExp = "0"};

            If ($C_YesAsis.CheckState -eq "1") {$global:YesAsis = "1"} Else {$global:YesAsis = "0"};

            $form.Close()}})

        $form.Add_KeyDown({if ($_.KeyCode -eq "Escape")

            {$global:x="2";$form.Close()}})

        $form.Topmost = $True

        $form.Add_Shown({$form.Activate()})

        [void] $form.ShowDialog()

    }

    Function ExportNFS () {

        # Get which VLANs to export the qtree to
        $form = New-Object System.Windows.Forms.Form

        $form.Text = "NFS Export Details"

        $form.Size = New-Object System.Drawing.Size(270,220)

        $form.StartPosition = "CenterScreen"

        $L_exports = New-Object System.Windows.Forms.Label

        $L_exports.Location = New-Object System.Drawing.Point(0,10)

        $L_exports.Size = New-Object System.Drawing.Size(250,20)

        $L_exports.TextAlign = 2

        $L_exports.Text = "What VLANs do you want to export to?"

        $form.Controls.Add($L_exports)

        $C_Irv = New-Object System.Windows.Forms.CheckBox

        $C_Irv.Location = New-Object System.Drawing.Point(50,30)

        $C_Irv.Size = New-Object System.Drawing.Size(125,20)

        $C_Irv.UseVisualStyleBackColor = $True

        $C_Irv.Text = "DC1 (110, 128)"

        $form.Controls.Add($C_Irv)

        $C_HQ = New-Object System.Windows.Forms.CheckBox

        $C_HQ.Location = New-Object System.Drawing.Point(50,50)

        $C_HQ.Size = New-Object System.Drawing.Size(125,20)

        $C_HQ.UseVisualStyleBackColor = $True

        $C_HQ.Text = "DC2 (128, 162)"

        $form.Controls.Add($C_HQ)

        $C_V = New-Object System.Windows.Forms.CheckBox

        $C_V.Location = New-Object System.Drawing.Point(50,70)

        $C_V.Size = New-Object System.Drawing.Size(125,20)

        $C_V.UseVisualStyleBackColor = $True

        $C_V.Text = "View (110, 128)"

        $form.Controls.Add($C_V)

        $L_VC = New-Object System.Windows.Forms.Label

        $L_VC.Location = New-Object System.Drawing.Point(0,100)

        $L_VC.Size = New-Object System.Drawing.Size(250,20)

        $L_VC.TextAlign = 2

        $L_VC.Text = "Automatically add to ESX Hosts?"

        $form.Controls.Add($L_VC)

        $C_YesVC = New-Object System.Windows.Forms.CheckBox

        $C_YesVC.Location = New-Object System.Drawing.Point(55,120)

        $C_YesVC.Size = New-Object System.Drawing.Size(50,20)

        $C_YesVC.UseVisualStyleBackColor = $True

        $C_YesVC.Name = "YesVC"

        $C_YesVC.Text = "Yes"

        $C_YesVC.CheckState = 1

        $form.Controls.Add($C_YesVC)

        $C_NoVC = New-Object System.Windows.Forms.CheckBox

        $C_NoVC.Location = New-Object System.Drawing.Point(160,120)

        $C_NoVC.Size = New-Object System.Drawing.Size(40,20)

        $C_NoVC.UseVisualStyleBackColor = $True

        $C_NoVC.Name = "NoVC"

        $C_NoVC.Text = "No"

        $form.Controls.Add($C_NoVC)

        $OKButton = New-Object System.Windows.Forms.Button

        $OKButton.Location = New-Object System.Drawing.Point(55,145)

        $OKButton.Size = New-Object System.Drawing.Size(75,23)

        $OKButton.Text = "OK"

        $OKButton.Add_Click({

            If ($C_Irv.CheckState -eq "1") {$global:Irv = "1"} Else {$global:Irv = "0"};

            If ($C_HQ.CheckState -eq "1") {$global:HQ = "1"} Else {$global:HQ = "0"};

            If ($C_V.CheckState -eq "1") {$global:V = "1"} Else {$global:V = "0"};

            If ($C_YesVC.CheckState -eq "1") {$global:ExpVC = "1"} Else {$global:ExpVC = "0"};

            $global:x="0";$form.Close()})

        $form.Controls.Add($OKButton)

        $CancelButton = New-Object System.Windows.Forms.Button

        $CancelButton.Location = New-Object System.Drawing.Size(130,145)

        $CancelButton.Size = New-Object System.Drawing.Size(75,23)

        $CancelButton.Text = "Cancel"

        $CancelButton.Add_Click({$global:x="0";$form.Close()})

        $form.Controls.Add($CancelButton)

        Function Export_CheckChanged{

            # Don't allow both yes and no checkboxes to be selected
            Param([object]$Sender, [System.EventArgs]$Arguments)

            If ($Sender.Name -eq "YesVC" -and $Sender.Checked){

                $C_NoVC.Checked = $False

                $C_NoVC.Enabled = $False

            }

            ElseIf ($Sender.Name -eq "NoVC" -and $Sender.Checked){

                $C_YesVC.Checked = $False

                $C_YesVC.Enabled = $False

            }

            Else{

                $C_YesVC.Enabled = $true

                $C_NoVC.Enabled = $true

            }

        }

        $C_YesVC.Add_CheckedChanged({Export_CheckChanged $this $_})

        $C_NoVC.Add_CheckedChanged({Export_CheckChanged $this $_})

        $form.KeyPreview = $True

        $form.Add_KeyDown({if ($_.KeyCode -eq "Enter") {

            If ($C_Irv.CheckState -eq "1") {$global:Irv = "1"} Else {$global:Irv = "0"};

            If ($C_HQ.CheckState -eq "1") {$global:HQ = "1"} Else {$global:HQ = "0"};

            If ($C_V.CheckState -eq "1") {$global:V = "1"} Else {$global:V = "0"};

            If ($C_YesVC.CheckState -eq "1") {$global:ExpVC = "1"} Else {$global:ExpVC = "0"};

            $global:x="0";$form.Close()}})

        $form.Add_KeyDown({if ($_.KeyCode -eq "Escape")

            {$global:x="2";$form.Close()}})

        $form.Topmost = $True

        $form.Add_Shown({$form.Activate()})

        [void] $form.ShowDialog()

    }

    Function Get_SnapHours (){

        $form = New-Object System.Windows.Forms.Form

        $form.Text = "Snapshot Details"

        $form.Size = New-Object System.Drawing.Size(270,275)

        $form.StartPosition = "CenterScreen"

        $L_Hours = New-Object System.Windows.Forms.Label

        $L_Hours.Location = New-Object System.Drawing.Point(0,20)

        $L_Hours.Size = New-Object System.Drawing.Size(260,20)

        $L_Hours.TextAlign = 2

        $L_Hours.Text = "On what hours should snapshots be taken?"

        $form.Controls.Add($L_Hours)

        $L_am = New-Object System.Windows.Forms.Label

        $L_am.Location = New-Object System.Drawing.Point(53,40)

        $L_am.Size = New-Object System.Drawing.Size(40,20)

        $L_am.Text = "AM"

        $form.Controls.Add($L_am)

        $L_pm = New-Object System.Windows.Forms.Label

        $L_pm.Location = New-Object System.Drawing.Point(178,40)

        $L_pm.Size = New-Object System.Drawing.Size(40,20)

        $L_pm.Text = "PM"

        $form.Controls.Add($L_pm)

        $C_12a = New-Object System.Windows.Forms.CheckBox

        $C_12a.Location = New-Object System.Drawing.Point(20,58)

        $C_12a.Size = New-Object System.Drawing.Size(40,20)

        $C_12a.UseVisualStyleBackColor = $True

        $C_12a.Text = "12"

        $form.Controls.Add($C_12a)

        $C_6a = New-Object System.Windows.Forms.CheckBox

        $C_6a.Location = New-Object System.Drawing.Point(80,58)

        $C_6a.Size = New-Object System.Drawing.Size(40,20)

        $C_6a.UseVisualStyleBackColor = $True

        $C_6a.Text = "6"

        $form.Controls.Add($C_6a)

        $C_12p = New-Object System.Windows.Forms.CheckBox

        $C_12p.Location = New-Object System.Drawing.Point(150,58)

        $C_12p.Size = New-Object System.Drawing.Size(40,20)

        $C_12p.UseVisualStyleBackColor = $True

        $C_12p.Text = "12"

        $form.Controls.Add($C_12p)

        $C_6p = New-Object System.Windows.Forms.CheckBox

        $C_6p.Location = New-Object System.Drawing.Point(200,58)

        $C_6p.Size = New-Object System.Drawing.Size(40,20)

        $C_6p.UseVisualStyleBackColor = $True

        $C_6p.Text = "6"

        $form.Controls.Add($C_6p)

        $C_1a = New-Object System.Windows.Forms.CheckBox

        $C_1a.Location = New-Object System.Drawing.Point(20,78)

        $C_1a.Size = New-Object System.Drawing.Size(40,20)

        $C_1a.UseVisualStyleBackColor = $True

        $C_1a.Text = "1"

        $form.Controls.Add($C_1a)

        $C_7a = New-Object System.Windows.Forms.CheckBox

        $C_7a.Location = New-Object System.Drawing.Point(80,78)

        $C_7a.Size = New-Object System.Drawing.Size(40,20)

        $C_7a.UseVisualStyleBackColor = $True

        $C_7a.Text = "7"

        $form.Controls.Add($C_7a)

        $C_1p = New-Object System.Windows.Forms.CheckBox

        $C_1p.Location = New-Object System.Drawing.Point(150,78)

        $C_1p.Size = New-Object System.Drawing.Size(40,20)

        $C_1p.UseVisualStyleBackColor = $True

        $C_1p.Text = "1"

        $form.Controls.Add($C_1p)

        $C_7p = New-Object System.Windows.Forms.CheckBox

        $C_7p.Location = New-Object System.Drawing.Point(200,78)

        $C_7p.Size = New-Object System.Drawing.Size(40,20)

        $C_7p.UseVisualStyleBackColor = $True

        $C_7p.Text = "7"

        $form.Controls.Add($C_7p)

        $C_2a = New-Object System.Windows.Forms.CheckBox

        $C_2a.Location = New-Object System.Drawing.Point(20,98)

        $C_2a.Size = New-Object System.Drawing.Size(40,20)

        $C_2a.UseVisualStyleBackColor = $True

        $C_2a.Text = "2"

        $form.Controls.Add($C_2a)

        $C_8a = New-Object System.Windows.Forms.CheckBox

        $C_8a.Location = New-Object System.Drawing.Point(80,98)

        $C_8a.Size = New-Object System.Drawing.Size(40,20)

        $C_8a.UseVisualStyleBackColor = $True

        $C_8a.Text = "8"

        $form.Controls.Add($C_8a)

        $C_2p = New-Object System.Windows.Forms.CheckBox

        $C_2p.Location = New-Object System.Drawing.Point(150,98)

        $C_2p.Size = New-Object System.Drawing.Size(40,20)

        $C_2p.UseVisualStyleBackColor = $True

        $C_2p.Text = "2"

        $form.Controls.Add($C_2p)

        $C_8p = New-Object System.Windows.Forms.CheckBox

        $C_8p.Location = New-Object System.Drawing.Point(200,98)

        $C_8p.Size = New-Object System.Drawing.Size(40,20)

        $C_8p.UseVisualStyleBackColor = $True

        $C_8p.Text = "8"

        $form.Controls.Add($C_8p)

        $C_3a = New-Object System.Windows.Forms.CheckBox

        $C_3a.Location = New-Object System.Drawing.Point(20,118)

        $C_3a.Size = New-Object System.Drawing.Size(40,20)

        $C_3a.UseVisualStyleBackColor = $True

        $C_3a.Text = "3"

        $form.Controls.Add($C_3a)

        $C_9a = New-Object System.Windows.Forms.CheckBox

        $C_9a.Location = New-Object System.Drawing.Point(80,118)

        $C_9a.Size = New-Object System.Drawing.Size(40,20)

        $C_9a.UseVisualStyleBackColor = $True

        $C_9a.Text = "9"

        $form.Controls.Add($C_9a)

        $C_3p = New-Object System.Windows.Forms.CheckBox

        $C_3p.Location = New-Object System.Drawing.Point(150,118)

        $C_3p.Size = New-Object System.Drawing.Size(40,20)

        $C_3p.UseVisualStyleBackColor = $True

        $C_3p.Text = "3"

        $form.Controls.Add($C_3p)

        $C_9p = New-Object System.Windows.Forms.CheckBox

        $C_9p.Location = New-Object System.Drawing.Point(200,118)

        $C_9p.Size = New-Object System.Drawing.Size(40,20)

        $C_9p.UseVisualStyleBackColor = $True

        $C_9p.Text = "9"

        $form.Controls.Add($C_9p)

        $C_4a = New-Object System.Windows.Forms.CheckBox

        $C_4a.Location = New-Object System.Drawing.Point(20,138)

        $C_4a.Size = New-Object System.Drawing.Size(40,20)

        $C_4a.UseVisualStyleBackColor = $True

        $C_4a.Text = "4"

        $form.Controls.Add($C_4a)

        $C_10a = New-Object System.Windows.Forms.CheckBox

        $C_10a.Location = New-Object System.Drawing.Point(80,138)

        $C_10a.Size = New-Object System.Drawing.Size(40,20)

        $C_10a.UseVisualStyleBackColor = $True

        $C_10a.Text = "10"

        $form.Controls.Add($C_10a)

        $C_4p = New-Object System.Windows.Forms.CheckBox

        $C_4p.Location = New-Object System.Drawing.Point(150,138)

        $C_4p.Size = New-Object System.Drawing.Size(40,20)

        $C_4p.UseVisualStyleBackColor = $True

        $C_4p.Text = "4"

        $form.Controls.Add($C_4p)

        $C_10p = New-Object System.Windows.Forms.CheckBox

        $C_10p.Location = New-Object System.Drawing.Point(200,138)

        $C_10p.Size = New-Object System.Drawing.Size(40,20)

        $C_10p.UseVisualStyleBackColor = $True

        $C_10p.Text = "10"

        $form.Controls.Add($C_10p)

        $C_5a = New-Object System.Windows.Forms.CheckBox

        $C_5a.Location = New-Object System.Drawing.Point(20,158)

        $C_5a.Size = New-Object System.Drawing.Size(40,20)

        $C_5a.UseVisualStyleBackColor = $True

        $C_5a.Text = "5"

        $form.Controls.Add($C_5a)

        $C_11a = New-Object System.Windows.Forms.CheckBox

        $C_11a.Location = New-Object System.Drawing.Point(80,158)

        $C_11a.Size = New-Object System.Drawing.Size(40,20)

        $C_11a.UseVisualStyleBackColor = $True

        $C_11a.Text = "11"

        $form.Controls.Add($C_11a)

        $C_5p = New-Object System.Windows.Forms.CheckBox

        $C_5p.Location = New-Object System.Drawing.Point(150,158)

        $C_5p.Size = New-Object System.Drawing.Size(40,20)

        $C_5p.UseVisualStyleBackColor = $True

        $C_5p.Text = "5"

        $form.Controls.Add($C_5p)

        $C_11p = New-Object System.Windows.Forms.CheckBox

        $C_11p.Location = New-Object System.Drawing.Point(200,158)

        $C_11p.Size = New-Object System.Drawing.Size(40,20)

        $C_11p.UseVisualStyleBackColor = $True

        $C_11p.Text = "11"

        $form.Controls.Add($C_11p)

        $OKButton = New-Object System.Windows.Forms.Button

        $OKButton.Location = New-Object System.Drawing.Point(55,200)

        $OKButton.Size = New-Object System.Drawing.Size(75,23)

        $OKButton.Text = "OK"

        $OKButton.Add_Click({

            If ($C_12a.CheckState -eq "1") {$h12a = "0";$global:sourceSnapH = "0"} Else {$h12a = ""};

            If ($C_1a.CheckState -eq "1") {$h1a = "1";$global:sourceSnapH = "1"} Else {$h1a = ""};

            If ($C_2a.CheckState -eq "1") {$h2a = "2";$global:sourceSnapH = "2"} Else {$h2a = ""};

            If ($C_3a.CheckState -eq "1") {$h3a = "3";$global:sourceSnapH = "3"} Else {$h3a = ""};

            If ($C_4a.CheckState -eq "1") {$h4a = "4";$global:sourceSnapH = "4"} Else {$h4a = ""};

            If ($C_5a.CheckState -eq "1") {$h5a = "5";$global:sourceSnapH = "5"} Else {$h5a = ""};

            If ($C_6a.CheckState -eq "1") {$h6a = "6";$global:sourceSnapH = "6"} Else {$h6a = ""};

            If ($C_7a.CheckState -eq "1") {$h7a = "7";$global:sourceSnapH = "7"} Else {$h7a = ""};

            If ($C_8a.CheckState -eq "1") {$h8a = "8";$global:sourceSnapH = "8"} Else {$h8a = ""};

            If ($C_9a.CheckState -eq "1") {$h9a = "9";$global:sourceSnapH = "9"} Else {$h9a = ""};

            If ($C_10a.CheckState -eq "1") {$h10a = "10";$global:sourceSnapH = "10"} Else {$h10a = ""};

            If ($C_11a.CheckState -eq "1") {$h11a = "11";$global:sourceSnapH = "11"} Else {$h11a = ""};

            If ($C_12p.CheckState -eq "1") {$h12p = "12";$global:sourceSnapH = "12"} Else {$h12p = ""};

            If ($C_1p.CheckState -eq "1") {$h1p = "13";$sglobal:ourceSnapH = "13"} Else {$h1p = ""};

            If ($C_2p.CheckState -eq "1") {$h2p = "14";$global:sourceSnapH = "14"} Else {$h2p = ""};

            If ($C_3p.CheckState -eq "1") {$h3p = "15";$global:sourceSnapH = "15"} Else {$h3p = ""};

            If ($C_4p.CheckState -eq "1") {$h4p = "16";$global:sourceSnapH = "16"} Else {$h4p = ""};

            If ($C_5p.CheckState -eq "1") {$h5p = "17";$global:sourceSnapH = "17"} Else {$h5p = ""};

            If ($C_6p.CheckState -eq "1") {$h6p = "18";$global:sourceSnapH = "18"} Else {$h6p = ""};

            If ($C_7p.CheckState -eq "1") {$h7p = "19";$global:sourceSnapH = "19"} Else {$h7p = ""};

            If ($C_8p.CheckState -eq "1") {$h8p = "20";$global:sourceSnapH = "20"} Else {$h8p = ""};

            If ($C_9p.CheckState -eq "1") {$h9p = "21";$global:sourceSnapH = "21"} Else {$h9p = ""};

            If ($C_10p.CheckState -eq "1") {$h10p = "22";$global:sourceSnapH = "22"} Else {$h10p = ""};

            If ($C_11p.CheckState -eq "1") {$h11p = "23";$global:sourceSnapH = "23"} Else {$h11p = ""};

            $global:x="0";$form.Close()})

        $form.Controls.Add($OKButton)

        $CancelButton = New-Object System.Windows.Forms.Button

        $CancelButton.Location = New-Object System.Drawing.Point(130,200)

        $CancelButton.Size = New-Object System.Drawing.Size(75,23)

        $CancelButton.Text = "Cancel"

        $CancelButton.Add_Click({$global:x="2";$form.Close()})

        $form.Controls.Add($CancelButton)

        $form.KeyPreview = $True

        $form.Add_KeyDown({if ($_.KeyCode -eq "Enter") {

            If ($C_12a.CheckState -eq "1") {$h12a = "0";$global:sourceSnapH = "0"} Else {$h12a = ""};

            If ($C_1a.CheckState -eq "1") {$h1a = "1";$global:sourceSnapH = "1"} Else {$h1a = ""};

            If ($C_2a.CheckState -eq "1") {$h2a = "2";$global:sourceSnapH = "2"} Else {$h2a = ""};

            If ($C_3a.CheckState -eq "1") {$h3a = "3";$global:sourceSnapH = "3"} Else {$h3a = ""};

            If ($C_4a.CheckState -eq "1") {$h4a = "4";$global:sourceSnapH = "4"} Else {$h4a = ""};

            If ($C_5a.CheckState -eq "1") {$h5a = "5";$global:sourceSnapH = "5"} Else {$h5a = ""};

            If ($C_6a.CheckState -eq "1") {$h6a = "6";$global:sourceSnapH = "6"} Else {$h6a = ""};

            If ($C_7a.CheckState -eq "1") {$h7a = "7";$global:sourceSnapH = "7"} Else {$h7a = ""};

            If ($C_8a.CheckState -eq "1") {$h8a = "8";$global:sourceSnapH = "8"} Else {$h8a = ""};

            If ($C_9a.CheckState -eq "1") {$h9a = "9";$global:sourceSnapH = "9"} Else {$h9a = ""};

            If ($C_10a.CheckState -eq "1") {$h10a = "10";$global:sourceSnapH = "10"} Else {$h10a = ""};

            If ($C_11a.CheckState -eq "1") {$h11a = "11";$global:sourceSnapH = "11"} Else {$h11a = ""};

            If ($C_12p.CheckState -eq "1") {$h12p = "12";$global:sourceSnapH = "12"} Else {$h12p = ""};

            If ($C_1p.CheckState -eq "1") {$h1p = "13";$sglobal:ourceSnapH = "13"} Else {$h1p = ""};

            If ($C_2p.CheckState -eq "1") {$h2p = "14";$global:sourceSnapH = "14"} Else {$h2p = ""};

            If ($C_3p.CheckState -eq "1") {$h3p = "15";$global:sourceSnapH = "15"} Else {$h3p = ""};

            If ($C_4p.CheckState -eq "1") {$h4p = "16";$global:sourceSnapH = "16"} Else {$h4p = ""};

            If ($C_5p.CheckState -eq "1") {$h5p = "17";$global:sourceSnapH = "17"} Else {$h5p = ""};

            If ($C_6p.CheckState -eq "1") {$h6p = "18";$global:sourceSnapH = "18"} Else {$h6p = ""};

            If ($C_7p.CheckState -eq "1") {$h7p = "19";$global:sourceSnapH = "19"} Else {$h7p = ""};

            If ($C_8p.CheckState -eq "1") {$h8p = "20";$global:sourceSnapH = "20"} Else {$h8p = ""};

            If ($C_9p.CheckState -eq "1") {$h9p = "21";$global:sourceSnapH = "21"} Else {$h9p = ""};

            If ($C_10p.CheckState -eq "1") {$h10p = "22";$global:sourceSnapH = "22"} Else {$h10p = ""};

            If ($C_11p.CheckState -eq "1") {$h11p = "23";$global:sourceSnapH = "23"} Else {$h11p = ""};

            $global:x="0";$form.Close()}})

        $form.Add_KeyDown({if ($_.KeyCode -eq "Escape")

            {$global:x="2";$form.Close()}})

        $form.Topmost = $True

        $form.Add_Shown({$form.Activate()})

        [void] $form.ShowDialog()

        If ($h12a -ne "") {$h12a += ","}

        If ($h1a -ne "") {$h1a += ","}

        If ($h2a -ne "") {$h2a += ","}

        If ($h3a -ne "") {$h3a += ","}

        If ($h4a -ne "") {$h4a += ","}

        If ($h5a -ne "") {$h5a += ","}

        If ($h6a -ne "") {$h6a += ","}

        If ($h7a -ne "") {$h7a += ","}

        If ($h8a -ne "") {$h8a += ","}

        If ($h9a -ne "") {$h9a += ","}

        If ($h10a -ne "") {$h10a += ","}

        If ($h11a -ne "") {$h11a += ","}

        If ($h12p -ne "") {$h12p += ","}

        If ($h1p -ne "") {$h1p += ","}

        If ($h2p -ne "") {$h2p += ","}

        If ($h3p -ne "") {$h3p += ","}

        If ($h4p -ne "") {$h4p += ","}

        If ($h5p -ne "") {$h5p += ","}

        If ($h6p -ne "") {$h6p += ","}

        If ($h7p -ne "") {$h7p += ","}

        If ($h8p -ne "") {$h8p += ","}

        If ($h9p -ne "") {$h9p += ","}

        If ($h10p -ne "") {$h10p += ","}

        $snapHours1 = $h12a+$h1a+$h2a+$h3a+$h4a+$h5a+$h6a+$h7a+$h8a+$h9a+$h10a+$h11a+$h12p+$h1p+$h2p+$h3p+$h4p+$h5p+$h6p+$h7p+$h8p+$h9p+$h10p+$h11p

        If ($snapHours1.substring((($snapHours1.length) -1), 1) -eq ",") {$global:snapHours = $snapHours1.substring(0,(($snapHours1.length) -1))} Else {$global:snapHours=$snapHours1}

    }

    Function Get_Asis () {

        $form = New-Object System.Windows.Forms.Form

        $form.Text = "ASIS Details"

        $form.Size = New-Object System.Drawing.Size(270,275)

        $form.StartPosition = "CenterScreen"

        $L_Hours = New-Object System.Windows.Forms.Label

        $L_Hours.Location = New-Object System.Drawing.Point(0,10)

        $L_Hours.Size = New-Object System.Drawing.Size(260,30)

        $L_Hours.TextAlign = 2

        $L_Hours.Text = "On what hour should Storage Efficiency run?`n(this should be after hours)"

        $form.Controls.Add($L_Hours)

        $L_am = New-Object System.Windows.Forms.Label

        $L_am.Location = New-Object System.Drawing.Point(53,40)

        $L_am.Size = New-Object System.Drawing.Size(40,20)

        $L_am.Text = "AM"

        $form.Controls.Add($L_am)

        $L_pm = New-Object System.Windows.Forms.Label

        $L_pm.Location = New-Object System.Drawing.Point(178,40)

        $L_pm.Size = New-Object System.Drawing.Size(40,20)

        $L_pm.Text = "PM"

        $form.Controls.Add($L_pm)

        $C_12a = New-Object System.Windows.Forms.CheckBox

        $C_12a.Location = New-Object System.Drawing.Point(20,58)

        $C_12a.Size = New-Object System.Drawing.Size(40,20)

        $C_12a.UseVisualStyleBackColor = $True

        $C_12a.Text = "12"

        $form.Controls.Add($C_12a)

        $C_6a = New-Object System.Windows.Forms.CheckBox

        $C_6a.Location = New-Object System.Drawing.Point(80,58)

        $C_6a.Size = New-Object System.Drawing.Size(40,20)

        $C_6a.UseVisualStyleBackColor = $True

        $C_6a.Text = "6"

        $form.Controls.Add($C_6a)

        $C_12p = New-Object System.Windows.Forms.CheckBox

        $C_12p.Location = New-Object System.Drawing.Point(150,58)

        $C_12p.Size = New-Object System.Drawing.Size(40,20)

        $C_12p.UseVisualStyleBackColor = $True

        $C_12p.Text = "12"

        $form.Controls.Add($C_12p)

        $C_6p = New-Object System.Windows.Forms.CheckBox

        $C_6p.Location = New-Object System.Drawing.Point(200,58)

        $C_6p.Size = New-Object System.Drawing.Size(40,20)

        $C_6p.UseVisualStyleBackColor = $True

        $C_6p.Text = "6"

        $form.Controls.Add($C_6p)

        $C_1a = New-Object System.Windows.Forms.CheckBox

        $C_1a.Location = New-Object System.Drawing.Point(20,78)

        $C_1a.Size = New-Object System.Drawing.Size(40,20)

        $C_1a.UseVisualStyleBackColor = $True

        $C_1a.Text = "1"

        $form.Controls.Add($C_1a)

        $C_7a = New-Object System.Windows.Forms.CheckBox

        $C_7a.Location = New-Object System.Drawing.Point(80,78)

        $C_7a.Size = New-Object System.Drawing.Size(40,20)

        $C_7a.UseVisualStyleBackColor = $True

        $C_7a.Text = "7"

        $form.Controls.Add($C_7a)

        $C_1p = New-Object System.Windows.Forms.CheckBox

        $C_1p.Location = New-Object System.Drawing.Point(150,78)

        $C_1p.Size = New-Object System.Drawing.Size(40,20)

        $C_1p.UseVisualStyleBackColor = $True

        $C_1p.Text = "1"

        $form.Controls.Add($C_1p)

        $C_7p = New-Object System.Windows.Forms.CheckBox

        $C_7p.Location = New-Object System.Drawing.Point(200,78)

        $C_7p.Size = New-Object System.Drawing.Size(40,20)

        $C_7p.UseVisualStyleBackColor = $True

        $C_7p.Text = "7"

        $form.Controls.Add($C_7p)

        $C_2a = New-Object System.Windows.Forms.CheckBox

        $C_2a.Location = New-Object System.Drawing.Point(20,98)

        $C_2a.Size = New-Object System.Drawing.Size(40,20)

        $C_2a.UseVisualStyleBackColor = $True

        $C_2a.Text = "2"

        $form.Controls.Add($C_2a)

        $C_8a = New-Object System.Windows.Forms.CheckBox

        $C_8a.Location = New-Object System.Drawing.Point(80,98)

        $C_8a.Size = New-Object System.Drawing.Size(40,20)

        $C_8a.UseVisualStyleBackColor = $True

        $C_8a.Text = "8"

        $form.Controls.Add($C_8a)

        $C_2p = New-Object System.Windows.Forms.CheckBox

        $C_2p.Location = New-Object System.Drawing.Point(150,98)

        $C_2p.Size = New-Object System.Drawing.Size(40,20)

        $C_2p.UseVisualStyleBackColor = $True

        $C_2p.Text = "2"

        $form.Controls.Add($C_2p)

        $C_8p = New-Object System.Windows.Forms.CheckBox

        $C_8p.Location = New-Object System.Drawing.Point(200,98)

        $C_8p.Size = New-Object System.Drawing.Size(40,20)

        $C_8p.UseVisualStyleBackColor = $True

        $C_8p.Text = "8"

        $form.Controls.Add($C_8p)

        $C_3a = New-Object System.Windows.Forms.CheckBox

        $C_3a.Location = New-Object System.Drawing.Point(20,118)

        $C_3a.Size = New-Object System.Drawing.Size(40,20)

        $C_3a.UseVisualStyleBackColor = $True

        $C_3a.Text = "3"

        $form.Controls.Add($C_3a)

        $C_9a = New-Object System.Windows.Forms.CheckBox

        $C_9a.Location = New-Object System.Drawing.Point(80,118)

        $C_9a.Size = New-Object System.Drawing.Size(40,20)

        $C_9a.UseVisualStyleBackColor = $True

        $C_9a.Text = "9"

        $form.Controls.Add($C_9a)

        $C_3p = New-Object System.Windows.Forms.CheckBox

        $C_3p.Location = New-Object System.Drawing.Point(150,118)

        $C_3p.Size = New-Object System.Drawing.Size(40,20)

        $C_3p.UseVisualStyleBackColor = $True

        $C_3p.Text = "3"

        $form.Controls.Add($C_3p)

        $C_9p = New-Object System.Windows.Forms.CheckBox

        $C_9p.Location = New-Object System.Drawing.Point(200,118)

        $C_9p.Size = New-Object System.Drawing.Size(40,20)

        $C_9p.UseVisualStyleBackColor = $True

        $C_9p.Text = "9"

        $form.Controls.Add($C_9p)

        $C_4a = New-Object System.Windows.Forms.CheckBox

        $C_4a.Location = New-Object System.Drawing.Point(20,138)

        $C_4a.Size = New-Object System.Drawing.Size(40,20)

        $C_4a.UseVisualStyleBackColor = $True

        $C_4a.Text = "4"

        $form.Controls.Add($C_4a)

        $C_10a = New-Object System.Windows.Forms.CheckBox

        $C_10a.Location = New-Object System.Drawing.Point(80,138)

        $C_10a.Size = New-Object System.Drawing.Size(40,20)

        $C_10a.UseVisualStyleBackColor = $True

        $C_10a.Text = "10"

        $form.Controls.Add($C_10a)

        $C_4p = New-Object System.Windows.Forms.CheckBox

        $C_4p.Location = New-Object System.Drawing.Point(150,138)

        $C_4p.Size = New-Object System.Drawing.Size(40,20)

        $C_4p.UseVisualStyleBackColor = $True

        $C_4p.Text = "4"

        $form.Controls.Add($C_4p)

        $C_10p = New-Object System.Windows.Forms.CheckBox

        $C_10p.Location = New-Object System.Drawing.Point(200,138)

        $C_10p.Size = New-Object System.Drawing.Size(40,20)

        $C_10p.UseVisualStyleBackColor = $True

        $C_10p.Text = "10"

        $form.Controls.Add($C_10p)

        $C_5a = New-Object System.Windows.Forms.CheckBox

        $C_5a.Location = New-Object System.Drawing.Point(20,158)

        $C_5a.Size = New-Object System.Drawing.Size(40,20)

        $C_5a.UseVisualStyleBackColor = $True

        $C_5a.Text = "5"

        $form.Controls.Add($C_5a)

        $C_11a = New-Object System.Windows.Forms.CheckBox

        $C_11a.Location = New-Object System.Drawing.Point(80,158)

        $C_11a.Size = New-Object System.Drawing.Size(40,20)

        $C_11a.UseVisualStyleBackColor = $True

        $C_11a.Text = "11"

        $form.Controls.Add($C_11a)

        $C_5p = New-Object System.Windows.Forms.CheckBox

        $C_5p.Location = New-Object System.Drawing.Point(150,158)

        $C_5p.Size = New-Object System.Drawing.Size(40,20)

        $C_5p.UseVisualStyleBackColor = $True

        $C_5p.Text = "5"

        $form.Controls.Add($C_5p)

        $C_11p = New-Object System.Windows.Forms.CheckBox

        $C_11p.Location = New-Object System.Drawing.Point(200,158)

        $C_11p.Size = New-Object System.Drawing.Size(40,20)

        $C_11p.UseVisualStyleBackColor = $True

        $C_11p.Text = "11"

        $form.Controls.Add($C_11p)

        $OKButton = New-Object System.Windows.Forms.Button

        $OKButton.Location = New-Object System.Drawing.Point(55,200)

        $OKButton.Size = New-Object System.Drawing.Size(75,23)

        $OKButton.Text = "OK"

        $OKButton.Add_Click({

            If ($C_12a.CheckState -eq "1") {$h12a = "0";$global:sourceASISH = "0"} Else {$h12a = ""};

            If ($C_1a.CheckState -eq "1") {$h1a = "1";$global:sourceASISH = "1"} Else {$h1a = ""};

            If ($C_2a.CheckState -eq "1") {$h2a = "2";$global:sourceASISH = "2"} Else {$h2a = ""};

            If ($C_3a.CheckState -eq "1") {$h3a = "3";$global:sourceASISH = "3"} Else {$h3a = ""};

            If ($C_4a.CheckState -eq "1") {$h4a = "4";$global:sourceASISH = "4"} Else {$h4a = ""};

            If ($C_5a.CheckState -eq "1") {$h5a = "5";$global:sourceASISH = "5"} Else {$h5a = ""};

            If ($C_6a.CheckState -eq "1") {$h6a = "6";$global:sourceASISH = "6"} Else {$h6a = ""};

            If ($C_7a.CheckState -eq "1") {$h7a = "7";$global:sourceASISH = "7"} Else {$h7a = ""};

            If ($C_8a.CheckState -eq "1") {$h8a = "8";$global:sourceASISH = "8"} Else {$h8a = ""};

            If ($C_9a.CheckState -eq "1") {$h9a = "9";$global:sourceASISH = "9"} Else {$h9a = ""};

            If ($C_10a.CheckState -eq "1") {$h10a = "10";$global:sourceASISH = "10"} Else {$h10a = ""};

            If ($C_11a.CheckState -eq "1") {$h11a = "11";$global:sourceASISH = "11"} Else {$h11a = ""};

            If ($C_12p.CheckState -eq "1") {$h12p = "12";$global:sourceASISH = "12"} Else {$h12p = ""};

            If ($C_1p.CheckState -eq "1") {$h1p = "13";$sglobal:ourceSnapH = "13"} Else {$h1p = ""};

            If ($C_2p.CheckState -eq "1") {$h2p = "14";$global:sourceASISH = "14"} Else {$h2p = ""};

            If ($C_3p.CheckState -eq "1") {$h3p = "15";$global:sourceASISH = "15"} Else {$h3p = ""};

            If ($C_4p.CheckState -eq "1") {$h4p = "16";$global:sourceASISH = "16"} Else {$h4p = ""};

            If ($C_5p.CheckState -eq "1") {$h5p = "17";$global:sourceASISH = "17"} Else {$h5p = ""};

            If ($C_6p.CheckState -eq "1") {$h6p = "18";$global:sourceASISH = "18"} Else {$h6p = ""};

            If ($C_7p.CheckState -eq "1") {$h7p = "19";$global:sourceASISH = "19"} Else {$h7p = ""};

            If ($C_8p.CheckState -eq "1") {$h8p = "20";$global:sourceASISH = "20"} Else {$h8p = ""};

            If ($C_9p.CheckState -eq "1") {$h9p = "21";$global:sourceASISH = "21"} Else {$h9p = ""};

            If ($C_10p.CheckState -eq "1") {$h10p = "22";$global:sourceASISH = "22"} Else {$h10p = ""};

            If ($C_11p.CheckState -eq "1") {$h11p = "23";$global:sourceASISH = "23"} Else {$h11p = ""};

            $global:x="0";$form.Close()})

        $form.Controls.Add($OKButton)

        $CancelButton = New-Object System.Windows.Forms.Button

        $CancelButton.Location = New-Object System.Drawing.Point(130,200)

        $CancelButton.Size = New-Object System.Drawing.Size(75,23)

        $CancelButton.Text = "Cancel"

        $CancelButton.Add_Click({$global:x="2";$form.Close()})

        $form.Controls.Add($CancelButton)

        $form.KeyPreview = $True

        $form.Add_KeyDown({if ($_.KeyCode -eq "Enter") {

            If ($C_12a.CheckState -eq "1") {$h12a = "0";$global:sourceASISH = "0"} Else {$h12a = ""};

            If ($C_1a.CheckState -eq "1") {$h1a = "1";$global:sourceASISH = "1"} Else {$h1a = ""};

            If ($C_2a.CheckState -eq "1") {$h2a = "2";$global:sourceASISH = "2"} Else {$h2a = ""};

            If ($C_3a.CheckState -eq "1") {$h3a = "3";$global:sourceASISH = "3"} Else {$h3a = ""};

            If ($C_4a.CheckState -eq "1") {$h4a = "4";$global:sourceASISH = "4"} Else {$h4a = ""};

            If ($C_5a.CheckState -eq "1") {$h5a = "5";$global:sourceASISH = "5"} Else {$h5a = ""};

            If ($C_6a.CheckState -eq "1") {$h6a = "6";$global:sourceASISH = "6"} Else {$h6a = ""};

            If ($C_7a.CheckState -eq "1") {$h7a = "7";$global:sourceASISH = "7"} Else {$h7a = ""};

            If ($C_8a.CheckState -eq "1") {$h8a = "8";$global:sourceASISH = "8"} Else {$h8a = ""};

            If ($C_9a.CheckState -eq "1") {$h9a = "9";$global:sourceASISH = "9"} Else {$h9a = ""};

            If ($C_10a.CheckState -eq "1") {$h10a = "10";$global:sourceASISH = "10"} Else {$h10a = ""};

            If ($C_11a.CheckState -eq "1") {$h11a = "11";$global:sourceASISH = "11"} Else {$h11a = ""};

            If ($C_12p.CheckState -eq "1") {$h12p = "12";$global:sourceASISH = "12"} Else {$h12p = ""};

            If ($C_1p.CheckState -eq "1") {$h1p = "13";$sglobal:ourceSnapH = "13"} Else {$h1p = ""};

            If ($C_2p.CheckState -eq "1") {$h2p = "14";$global:sourceASISH = "14"} Else {$h2p = ""};

            If ($C_3p.CheckState -eq "1") {$h3p = "15";$global:sourceASISH = "15"} Else {$h3p = ""};

            If ($C_4p.CheckState -eq "1") {$h4p = "16";$global:sourceASISH = "16"} Else {$h4p = ""};

            If ($C_5p.CheckState -eq "1") {$h5p = "17";$global:sourceASISH = "17"} Else {$h5p = ""};

            If ($C_6p.CheckState -eq "1") {$h6p = "18";$global:sourceASISH = "18"} Else {$h6p = ""};

            If ($C_7p.CheckState -eq "1") {$h7p = "19";$global:sourceASISH = "19"} Else {$h7p = ""};

            If ($C_8p.CheckState -eq "1") {$h8p = "20";$global:sourceASISH = "20"} Else {$h8p = ""};

            If ($C_9p.CheckState -eq "1") {$h9p = "21";$global:sourceASISH = "21"} Else {$h9p = ""};

            If ($C_10p.CheckState -eq "1") {$h10p = "22";$global:sourceASISH = "22"} Else {$h10p = ""};

            If ($C_11p.CheckState -eq "1") {$h11p = "23";$global:sourceASISH = "23"} Else {$h11p = ""};

            $global:x="0";$form.Close()}})

        $form.Add_KeyDown({if ($_.KeyCode -eq "Escape")

            {$global:x="2";$form.Close()}})

        $form.Topmost = $True

        $form.Add_Shown({$form.Activate()})

        [void] $form.ShowDialog()

        If ($h12a -ne "") {$h12a += ","}

        If ($h1a -ne "") {$h1a += ","}

        If ($h2a -ne "") {$h2a += ","}

        If ($h3a -ne "") {$h3a += ","}

        If ($h4a -ne "") {$h4a += ","}

        If ($h5a -ne "") {$h5a += ","}

        If ($h6a -ne "") {$h6a += ","}

        If ($h7a -ne "") {$h7a += ","}

        If ($h8a -ne "") {$h8a += ","}

        If ($h9a -ne "") {$h9a += ","}

        If ($h10a -ne "") {$h10a += ","}

        If ($h11a -ne "") {$h11a += ","}

        If ($h12p -ne "") {$h12p += ","}

        If ($h1p -ne "") {$h1p += ","}

        If ($h2p -ne "") {$h2p += ","}

        If ($h3p -ne "") {$h3p += ","}

        If ($h4p -ne "") {$h4p += ","}

        If ($h5p -ne "") {$h5p += ","}

        If ($h6p -ne "") {$h6p += ","}

        If ($h7p -ne "") {$h7p += ","}

        If ($h8p -ne "") {$h8p += ","}

        If ($h9p -ne "") {$h9p += ","}

        If ($h10p -ne "") {$h10p += ","}

        If ($h11p -ne "") {$h11p += ","}

        $asisHours1 = $h12a+$h1a+$h2a+$h3a+$h4a+$h5a+$h6a+$h7a+$h8a+$h9a+$h10a+$h11a+$h12p+$h1p+$h2p+$h3p+$h4p+$h5p+$h6p+$h7p+$h8p+$h9p+$h10p+$h11p

        If ($asisHours1.substring((($asisHours1.length) -1), 1) -eq ",") {$global:asisHours = $asisHours1.substring(0,(($asisHours1.length) -1))} Else {$global:asisHours=$asisHours1}   

    }

    Function ExportESX ($MyDC,$vName,$path,$NFShost) {

        # Get all hosts in selected location and add NFS datastore to them
        $VC_DC = $MyDC

        If ($VC_DC -eq "DC1") {

            $vcen = Connect-VIServer "vcen01" | Out-Null

            $ESXhosts = Get-VMHost -Location "DC1" | Select Name | ForEach {$_.Name}

            ForEach ($esx in $ESXhosts) {

                New-Datastore -VMHost $esx -Nfs -Name $vName -Path $path -NfsHost $NFShost | Out-Null

            }

        }

        If ($VC_DC -eq "DC2") {

            $vcen = Connect-VIServer "vcen02" | Out-Null

            $ESXhosts = Get-VMHost -Location "DC2" | Select Name | ForEach {$_.Name}

            ForEach ($esx in $ESXhosts) {

                New-Datastore -VMHost $esx -Nfs -Name $vName -Path $path -NfsHost $NFShost | Out-Null

            }

        }

        If ($VC_DC -eq "View") {

            $vcen = Connect-VIServer "vcen03" | Out-Null

            $ESXhosts = Get-VMHost -Location "View" | Select Name | ForEach {$_.Name}

            ForEach ($esx in $ESXhosts) {

                New-Datastore -VMHost $esx -Nfs -Name $vName -Path $path -NfsHost $NFShost | Out-Null

            }

        }

    }

    Function NoNFS ($MyFiler) {

        $form = New-Object System.Windows.Forms.Form

        $form.Text = "No NFS IP"

        $form.Size = New-Object System.Drawing.Size(240,120)

        $form.StartPosition = "CenterScreen"

        $Label = New-Object System.Windows.Forms.Label

        $Label.Location = New-Object System.Drawing.Size(0,10)

        $Label.Size = New-Object System.Drawing.Size(225,40)

        $Label.TextAlign = 2

        $Label.Text = "Unable to find NFS IP for $MyFiler`nExport was not added to ESX hosts!"

        $form.Controls.Add($Label)

        $OKButton = New-Object System.Windows.Forms.Button

        $OKButton.Location = New-Object System.Drawing.Size(75,50)

        $OKButton.Size = New-Object System.Drawing.Size(75,25)

        $OKButton.Text = "OK"

        $OKButton.Add_Click({$global:x="0";$form.Close()})

        $form.Controls.Add($OKButton)

        $form.Topmost = $True

        $form.Add_Shown({$form.Activate()})

        [void] $form.ShowDialog()

    }

    Function Select_DRFiler ($DR_filers) {

        $form = New-Object System.Windows.Forms.Form

        $form.Text = "Filer Selection"

        $form.Size = New-Object System.Drawing.Size(300,200)

        $form.StartPosition = "CenterScreen"

        $L_Filer = New-Object System.Windows.Forms.Label

        $L_Filer.Location = New-Object System.Drawing.Size(10,20)

        $L_Filer.Size = New-Object System.Drawing.Size(280,20)

        $L_Filer.Text = "What Filer do you want to create the backup volume on?"

        $form.Controls.Add($L_Filer)

        $CB_Filer = New-Object System.Windows.Forms.ComboBox

        foreach ($Filer in $DR_filers) {$CB_Filer.Items.Add($Filer)}

        $CB_Filer.Location = New-Object System.Drawing.Size(10,40)

        $CB_Filer.Size = New-Object System.Drawing.Size(260,20)

        $form.Controls.Add($CB_Filer)

        $OKButton = New-Object System.Windows.Forms.Button

        $OKButton.Location = New-Object System.Drawing.Size(75,120)

        $OKButton.Size = New-Object System.Drawing.Size(75,23)

        $OKButton.Text = "OK"

        $OKButton.Add_Click({$global:MyDRFiler=($CB_Filer.SelectedItem.ToLower()).ToString();$global:x="1";$form.Close()})

        $form.Controls.Add($OKButton)

        $CancelButton = New-Object System.Windows.Forms.Button

        $CancelButton.Location = New-Object System.Drawing.Size(150,120)

        $CancelButton.Size = New-Object System.Drawing.Size(75,23)

        $CancelButton.Text = "Cancel"

        $CancelButton.Add_Click({$global:x="2";$form.Close()})

        $form.Controls.Add($CancelButton)

        $form.KeyPreview = $True

        $form.Add_KeyDown({if ($_.KeyCode -eq "Enter")

            {$global:MyDRFiler=($CB_Filer.SelectedItem.ToLower()).ToString();$global:x="1";$form.Close()}})

        $form.Add_KeyDown({if ($_.KeyCode -eq "Escape")

            {$global:x="2";$form.Close()}})

        $form.Topmost = $True

        $form.Add_Shown({$form.Activate()})

        [void] $form.ShowDialog()

    }

    Function Select_DRAggr ($dr_aggr1, $dr_aggrs) {

        #Variables
        $agrList = $dr_aggr1

        $agrList1=$dr_aggrs

        #Definitions
        $form = New-Object System.Windows.Forms.Form

        $tlp_MainTable = New-Object System.Windows.Forms.TableLayoutPanel

        $gb_SelectAggr = New-Object System.Windows.Forms.GroupBox

        $cb_Aggr = New-Object System.Windows.Forms.ComboBox

        $gb_AggrList = New-Object System.Windows.Forms.GroupBox

        $tb_Aggrs = New-Object System.Windows.Forms.RichTextBox

        $OKButton = New-Object System.Windows.Forms.Button

        $CancelButton = New-Object System.Windows.Forms.Button

        $tlp_MainTable.SuspendLayout()

        $gb_SelectAggr.SuspendLayout()

        $gb_AggrList.SuspendLayout()

        $form.SuspendLayout()

        #tlp_MainTable
        $tlp_MainTable.ColumnCount = 1

        [void]$tlp_MainTable.ColumnStyles.Add((New-Object System.Windows.Forms.ColumnStyle([System.Windows.Forms.SizeType]::Percent, 100)))

        $tlp_MainTable.Controls.Add($gb_SelectAggr, 0, 0)

        $tlp_MainTable.Controls.Add($gb_AggrList, 0, 1)

        $tlp_MainTable.Controls.Add($OKButton, 1, 2)

        $tlp_MainTable.Dock = [System.Windows.Forms.DockStyle]::Fill

        $tlp_MainTable.Location = New-Object System.Drawing.Point(0, 0)

        $tlp_MainTable.Name = "tlp_MainTable"

        $tlp_MainTable.RowCount = 3

        [void]$tlp_MainTable.RowStyles.Add((New-Object System.Windows.Forms.RowStyle([System.Windows.Forms.SizeType]::Percent, 15)))

        [void]$tlp_MainTable.RowStyles.Add((New-Object System.Windows.Forms.RowStyle([System.Windows.Forms.SizeType]::Percent, 75)))

        [void]$tlp_MainTable.RowStyles.Add((New-Object System.Windows.Forms.RowStyle([System.Windows.Forms.SizeType]::Percent, 10)))

        $tlp_MainTable.Size = New-Object System.Drawing.Size(650, 500)

        #gb_SelectAggr
        $gb_SelectAggr.Controls.Add($cb_Aggr)

        $gb_SelectAggr.Dock = [System.Windows.Forms.DockStyle]::Fill

        $gb_SelectAggr.Location = New-Object System.Drawing.Point(3, 3)

        $gb_SelectAggr.Name = "gb_SelectAggr"

        $gb_SelectAggr.Size = New-Object System.Drawing.Size(600, 20)

        $gb_SelectAggr.TabStop = $False

        $gb_SelectAggr.Text = "Select Aggregate To Create The DR Volume On"

        #$cb_Aggr
        $cb_Aggr.AutoSize = $True

        $cb_Aggr.Location = New-Object System.Drawing.Point(6, 20)

        $cb_Aggr.Name = "cb_Aggr"

        $cb_Aggr.DropDownStyle = "DropDownList"

        $cb_Aggr.Size = New-Object System.Drawing.Size(260, 20)

        $cb_Aggr.TabIndex = 1

        ForEach ($ag in $agrList1 | Sort Name) {$cb_Aggr.Items.Add($ag.Name)}

        #gb_AggrList
        $gb_AggrList.Controls.Add($tb_Aggrs)

        $gb_AggrList.Dock = [System.Windows.Forms.DockStyle]::Fill

        $gb_AggrList.Location = New-Object System.Drawing.Point(3, 40)

        $gb_AggrList.Name = "tb_AggrList"

        $gb_AggrList.Size = New-Object System.Drawing.Size(600, 300)

        $gb_AggrList.TabStop = $False

        $gb_AggrList.Text = "List Of Available Aggregates"

        #tb_Aggrs
        $tb_Aggrs.AutoSize = $True

        $tb_Aggrs.Location = New-Object System.Drawing.Point(6, 20)

        $tb_Aggrs.Dock = [System.Windows.Forms.DockStyle]::Fill

        $tb_Aggrs.Name = "tb_Aggrs"

        $tb_Aggrs.Font = New-Object System.Drawing.Font("Lucida Console",9.5)

        $tb_Aggrs.Size = New-Object System.Drawing.Size(600, 300)

        $tb_Aggrs.TabStop = $false

        $tb_Aggrs.ReadOnly = $true

        $tb_Aggrs.AppendText("`nAggregate Name`tAvailable Size (GB)`tTotal Size (GB)`tBlock Type`n")

        $tb_Aggrs.AppendText("--------------`t-------------------`t---------------`t----------`n")

        ForEach ($agr in $agrList) {

            If($agr.BlockType -ne "64_bit") {$agr.BlockType = "32_bit"}

            $len = $agr.Name.Length

            If ($len -lt 7) {$tb_Aggrs.AppendText($agr.Name+"`t`t`t"+[Math]::Truncate($agr.SizeAvailable / 1GB)+"`t`t`t`t"+[Math]::Truncate($agr.SizeTotal / 1GB)+"`t`t`t"+$agr.BlockType+"`n")}

            ElseIf ($len -gt 11) {$tb_Aggrs.AppendText($agr.Name+"`t"+[Math]::Truncate($agr.SizeAvailable / 1GB)+"`t`t`t`t"+[Math]::Truncate($agr.SizeTotal / 1GB)+"`t`t`t"+$agr.BlockType+"`n")}

            Else {$tb_Aggrs.AppendText($agr.Name+"`t`t"+[Math]::Truncate($agr.SizeAvailable / 1GB)+"`t`t`t`t"+[Math]::Truncate($agr.SizeTotal / 1GB)+"`t`t`t"+$agr.BlockType+"`n")}

        }

        #OKButton
        $form.Controls.Add($OKButton)

        $OKButton.Location = New-Object System.Drawing.Point(250,425)

        $OKButton.Size = New-Object System.Drawing.Size(75,23)

        $OKButton.Text = "OK"

        $OKButton.TabIndex = 2

        $OKButton.Add_Click({$global:MyDRAggr=($cb_Aggr.SelectedItem.ToLower()).ToString();$global:x="1";$form.Close()})

        #CancelButton
        $CancelButton.Location = New-Object System.Drawing.Point(325,425)

        $CancelButton.Size = New-Object System.Drawing.Size(75,23)

        $CancelButton.Text = "Cancel"

        $CancelButton.TabIndex = 3

        $CancelButton.Add_Click({$global:x="2";$form.Close()})

        $form.Controls.Add($CancelButton)

        #Form
        $form.AutoScaleDimensions = New-Object System.Drawing.SizeF(6, 13)

        $form.AutoScaleMode = [System.Windows.Forms.AutoScaleMode]::Font

        $form.AutoSize = $True

        $form.ClientSize = New-Object System.Drawing.Size(600, 450)

        $form.Controls.Add($tlp_MainTable)

        $form.Name = "Form"

        $form.StartPosition = "CenterScreen"

        $form.Text = "Aggregate Selection"

        #Final Layout
        $form.KeyPreview = $True

        $form.Add_KeyDown({if ($_.KeyCode -eq "Enter")

            {$global:MyDRAggr=$cb_Aggr.SelectedItem.ToString();$global:x="1";$form.Close()}})

        $form.Add_KeyDown({if ($_.KeyCode -eq "Escape")

            {$global:x="2";$form.Close()}})

        $tlp_MainTable.ResumeLayout($False)

        $tlp_MainTable.PerformLayout()

        $gb_SelectAggr.ResumeLayout($False)

        $gb_SelectAggr.PerformLayout()

        $gb_AggrList.ResumeLayout($False)

        $gb_AggrList.PerformLayout()

        $form.ResumeLayout($False)

        [void]$form.ShowDialog()

    }

    Function DRVol_Details ($vName,[int]$drVsize,$DRblock){

        # Get DR volume details
        $drVname = "sm_"+$vName

        $drVsize *= "1.05"

        $form = New-Object System.Windows.Forms.Form

        $form.Text = "DR Volume Details"

        $form.Size = New-Object System.Drawing.Size(320,290)

        $form.StartPosition = "CenterScreen"

        $L_VName = New-Object System.Windows.Forms.Label

        $L_VName.Location = New-Object System.Drawing.Size(10,10)

        $L_VName.Size = New-Object System.Drawing.Size(300,20)

        $L_VName.Text = "What name do you want to give to the DR volume?"

        $form.Controls.Add($L_VName)

        $TB_VName = New-Object System.Windows.Forms.TextBox

        $TB_VName.Location = New-Object System.Drawing.Size(10,30)

        $TB_VName.Size = New-Object System.Drawing.Size(285,20)

        $TB_VName.Text = $drVname

        $form.Controls.Add($TB_VName)

        $L_VSize = New-Object System.Windows.Forms.Label

        $L_VSize.Location = New-Object System.Drawing.Size(10,57)

        $L_VSize.Size = New-Object System.Drawing.Size(300,20)

        $L_VSize.Text = "How large (in GB) do you want the volume to be?"

        $form.Controls.Add($L_VSize)

        $TB_VSize = New-Object System.Windows.Forms.TextBox

        $TB_VSize.Location = New-Object System.Drawing.Size(10,77)

        $TB_VSize.Size = New-Object System.Drawing.Size(285,20)

        $TB_VSize.Text = $drVsize

        $form.Controls.Add($TB_VSize)

        $L_SnapSched = New-Object System.Windows.Forms.Label

        $L_SnapSched.Location = New-Object System.Drawing.Size(10,100)

        $L_SnapSched.Size = New-Object System.Drawing.Size(300,20)

        $L_SnapSched.Text = "How many SnapShots do you want to keep?"

        $form.Controls.Add($L_SnapSched)

        $L_SnapW = New-Object System.Windows.Forms.Label

        $L_SnapW.Location = New-Object System.Drawing.Size(10,122)

        $L_SnapW.Size = New-Object System.Drawing.Size(46,20)

        $L_SnapW.Text = "Weekly:"

        $form.Controls.Add($L_SnapW)

        $TB_SnapW = New-Object System.Windows.Forms.TextBox

        $TB_SnapW.Location = New-Object System.Drawing.Size(56,120)

        $TB_SnapW.Size = New-Object System.Drawing.Size(25,20)

        $TB_SnapW.Text = "0"

        $form.Controls.Add($TB_SnapW)

        $L_SnapN = New-Object System.Windows.Forms.Label

        $L_SnapN.Location = New-Object System.Drawing.Size(120,122)

        $L_SnapN.Size = New-Object System.Drawing.Size(45,20)

        $L_SnapN.Text = "Nightly:"

        $form.Controls.Add($L_SnapN)

        $TB_SnapN = New-Object System.Windows.Forms.TextBox

        $TB_SnapN.Location = New-Object System.Drawing.Size(165,120)

        $TB_SnapN.Size = New-Object System.Drawing.Size(25,20)

        $TB_SnapN.Text = "0"

        $form.Controls.Add($TB_SnapN)

        $L_SnapH = New-Object System.Windows.Forms.Label

        $L_SnapH.Location = New-Object System.Drawing.Size(225,122)

        $L_SnapH.Size = New-Object System.Drawing.Size(45,20)

        $L_SnapH.Text = "Hourly:"

        $form.Controls.Add($L_SnapH)

        $TB_SnapH = New-Object System.Windows.Forms.TextBox

        $TB_SnapH.Location = New-Object System.Drawing.Size(270,120)

        $TB_SnapH.Size = New-Object System.Drawing.Size(25,20)

        $TB_SnapH.Text = "30"

        $form.Controls.Add($TB_SnapH)

        $L_Asis = New-Object System.Windows.Forms.Label

        $L_Asis.Location = New-Object System.Drawing.Size(10,145)

        $L_Asis.Size = New-Object System.Drawing.Size(140,20)

        $L_Asis.Text = "Enable Storage Efficiency?"

        $form.Controls.Add($L_Asis)

        $L_YesAsis = New-Object System.Windows.Forms.Label

        $L_YesAsis.Location = New-Object System.Drawing.Size(195,145)

        $L_YesAsis.Size = New-Object System.Drawing.Size(30,20)

        $L_YesAsis.Text = "Yes"

        $form.Controls.Add($L_YesAsis)

        $C_YesAsis = New-Object System.Windows.Forms.CheckBox

        $C_YesAsis.Location = New-Object System.Drawing.Size(225,142)

        $C_YesAsis.Size = New-Object System.Drawing.Size(20,20)

        $C_YesAsis.CheckState ="1"

        $C_YesAsis.UseVisualStyleBackColor = $True

        $C_YesAsis.DataBindings.DefaultDataSourceUpdateMode = 0

        $form.Controls.Add($C_YesAsis)

        $L_NoAsis = New-Object System.Windows.Forms.Label

        $L_NoAsis.Location = New-Object System.Drawing.Size(250,145)

        $L_NoAsis.Size = New-Object System.Drawing.Size(30,20)

        $L_NoAsis.Text = "No"

        $form.Controls.Add($L_NoAsis)

        $C_NoAsis = New-Object System.Windows.Forms.CheckBox

        $C_NoAsis.Location = New-Object System.Drawing.Size(280,142)

        $C_NoAsis.Size = New-Object System.Drawing.Size(20,20)

        $C_NoAsis.UseVisualStyleBackColor = $True

        $C_NoAsis.DataBindings.DefaultDataSourceUpdateMode = 0

        $form.Controls.Add($C_NoAsis)

        #if aggr is 64-bit give option to enable compression
        If ($DRblock -eq "64_bit") {

            $L_Comp = New-Object System.Windows.Forms.Label

            $L_Comp.Location = New-Object System.Drawing.Size(10,165)

            $L_Comp.Size = New-Object System.Drawing.Size(140,20)

            $L_Comp.Text = "Enable Compression?"

            $form.Controls.Add($L_Comp)

            $L_YesComp = New-Object System.Windows.Forms.Label

            $L_YesComp.Location = New-Object System.Drawing.Size(195,165)

            $L_YesComp.Size = New-Object System.Drawing.Size(30,20)

            $L_YesComp.Text = "Yes"

            $form.Controls.Add($L_YesComp)

            $C_YesComp = New-Object System.Windows.Forms.CheckBox

            $C_YesComp.Location = New-Object System.Drawing.Size(225,162)

            $C_YesComp.Size = New-Object System.Drawing.Size(20,20)

            $C_YesComp.CheckState ="1"

            $C_YesComp.UseVisualStyleBackColor = $True

            $C_YesComp.DataBindings.DefaultDataSourceUpdateMode = 0

            $form.Controls.Add($C_YesComp)

            $L_NoComp = New-Object System.Windows.Forms.Label

            $L_NoComp.Location = New-Object System.Drawing.Size(250,165)

            $L_NoComp.Size = New-Object System.Drawing.Size(30,20)

            $L_NoComp.Text = "No"

            $form.Controls.Add($L_NoComp)

            $C_NoComp = New-Object System.Windows.Forms.CheckBox

            $C_NoComp.Location = New-Object System.Drawing.Size(280,162)

            $C_NoComp.Size = New-Object System.Drawing.Size(20,20)

            $C_NoComp.UseVisualStyleBackColor = $True

            $C_NoComp.DataBindings.DefaultDataSourceUpdateMode = 0

            $form.Controls.Add($C_NoComp)

            $L_InL = New-Object System.Windows.Forms.Label

            $L_InL.Location = New-Object System.Drawing.Size(10,185)

            $L_InL.Size = New-Object System.Drawing.Size(170,20)

            $L_InL.Text = "Enable InLine Compression?"

            $form.Controls.Add($L_InL)

            $L_YesInL = New-Object System.Windows.Forms.Label

            $L_YesInL.Location = New-Object System.Drawing.Size(195,185)

            $L_YesInL.Size = New-Object System.Drawing.Size(30,20)

            $L_YesInL.Text = "Yes"

            $form.Controls.Add($L_YesInL)

            $C_YesInL = New-Object System.Windows.Forms.CheckBox

            $C_YesInL.Location = New-Object System.Drawing.Size(225,182)

            $C_YesInL.Size = New-Object System.Drawing.Size(20,20)

            $C_YesInL.CheckState ="1"

            $C_YesInL.UseVisualStyleBackColor = $True

            $C_YesInL.DataBindings.DefaultDataSourceUpdateMode = 0

            $form.Controls.Add($C_YesInL)

            $L_NoInL = New-Object System.Windows.Forms.Label

            $L_NoInL.Location = New-Object System.Drawing.Size(250,185)

            $L_NoInL.Size = New-Object System.Drawing.Size(30,20)

            $L_NoInL.Text = "No"

            $form.Controls.Add($L_NoInL)

            $C_NoInL = New-Object System.Windows.Forms.CheckBox

            $C_NoInL.Location = New-Object System.Drawing.Size(280,182)

            $C_NoInL.Size = New-Object System.Drawing.Size(20,20)

            $C_NoInL.UseVisualStyleBackColor = $True

            $C_NoInL.DataBindings.DefaultDataSourceUpdateMode = 0

            $form.Controls.Add($C_NoInL)

        }

        $OKButton = New-Object System.Windows.Forms.Button

        $OKButton.Location = New-Object System.Drawing.Size(85,220)

        $OKButton.Size = New-Object System.Drawing.Size(75,23)

        $OKButton.Text = "OK"

        $OKButton.Add_Click({

            $globalSmiley Very HappyRvName=$TB_VName.Text;

            $globalSmiley Very HappyRvSize=$TB_VSize.Text;

            $globalSmiley Very HappyRsnapW=$TB_SnapW.Text;

            $globalSmiley Very HappyRsnapN=$TB_SnapN.Text;

            $globalSmiley Very HappyRsnapH=$TB_SnapH.Text;

            $global:x="1";

            If ($C_YesAsis.CheckState -eq "1") {$globalSmiley Very HappyRYesAsis = "1"} Else {$globalSmiley Very HappyRYesAsis = "0"};

            If ($C_YesComp.CheckState -eq "1") {$globalSmiley Very HappyRYesComp = "1"} Else {$globalSmiley Very HappyRYesComp = "0"};

            If ($C_YesInL.CheckState -eq "1") {$globalSmiley Very HappyRYesInL = "1"} Else {$globalSmiley Very HappyRYesInL = "0"};

            $form.Close()})

        $form.Controls.Add($OKButton)

        $CancelButton = New-Object System.Windows.Forms.Button

        $CancelButton.Location = New-Object System.Drawing.Size(160,220)

        $CancelButton.Size = New-Object System.Drawing.Size(75,23)

        $CancelButton.Text = "Cancel"

        $CancelButton.Add_Click({$global:x="2";$form.Close()})

        $form.Controls.Add($CancelButton)

        $form.KeyPreview = $True

        $form.Add_KeyDown({if ($_.KeyCode -eq "Enter"){

            $global:vName=$TB_VName.Text;

            $global:vSize=$TB_VSize.Text;

            $global:snapW=$TB_SnapW.Text;

            $global:snapN=$TB_SnapN.Text;

            $global:snapH=$TB_SnapH.Text;

            $global:x="1";

            If ($C_YesAsis.CheckState -eq "1") {$globalSmiley Very HappyRYesAsis = "1"} Else {$globalSmiley Very HappyRYesAsis = "0"};

            If ($C_YesComp.CheckState -eq "1") {$globalSmiley Very HappyRYesComp = "1"} Else {$globalSmiley Very HappyRYesComp = "0"};

            If ($C_YesInL.CheckState -eq "1") {$globalSmiley Very HappyRYesInL = "1"} Else {$globalSmiley Very HappyRYesInL = "0"};

            $form.Close()}})

        $form.Add_KeyDown({if ($_.KeyCode -eq "Escape")

            {$global:x="2";$form.Close()}})

        $form.Topmost = $True

        $form.Add_Shown({$form.Activate()})

        [void] $form.ShowDialog()

    }

    Function Get_DRSnapHours ($sourceSnapH){

        #Get snapshot schedule for DR volume
        #Set default to 1 hour after mirror
        $form = New-Object System.Windows.Forms.Form

        $form.Text = "DR Snapshot Details"

        $form.Size = New-Object System.Drawing.Size(270,275)

        $form.StartPosition = "CenterScreen"

        $L_Hours = New-Object System.Windows.Forms.Label

        $L_Hours.Location = New-Object System.Drawing.Point(0,20)

        $L_Hours.Size = New-Object System.Drawing.Size(260,20)

        $L_Hours.TextAlign = 2

        $L_Hours.Text = "On what hours should snapshots be taken?"

        $form.Controls.Add($L_Hours)

        $L_am = New-Object System.Windows.Forms.Label

        $L_am.Location = New-Object System.Drawing.Point(53,40)

        $L_am.Size = New-Object System.Drawing.Size(40,20)

        $L_am.Text = "AM"

        $form.Controls.Add($L_am)

        $L_pm = New-Object System.Windows.Forms.Label

        $L_pm.Location = New-Object System.Drawing.Point(178,40)

        $L_pm.Size = New-Object System.Drawing.Size(40,20)

        $L_pm.Text = "PM"

        $form.Controls.Add($L_pm)

        $C_12a = New-Object System.Windows.Forms.CheckBox

        $C_12a.Location = New-Object System.Drawing.Point(20,58)

        $C_12a.Size = New-Object System.Drawing.Size(40,20)

        $C_12a.UseVisualStyleBackColor = $True

        $C_12a.Text = "12"

        $form.Controls.Add($C_12a)

        $C_6a = New-Object System.Windows.Forms.CheckBox

        $C_6a.Location = New-Object System.Drawing.Point(80,58)

        $C_6a.Size = New-Object System.Drawing.Size(40,20)

        $C_6a.UseVisualStyleBackColor = $True

        $C_6a.Text = "6"

        $form.Controls.Add($C_6a)

        $C_12p = New-Object System.Windows.Forms.CheckBox

        $C_12p.Location = New-Object System.Drawing.Point(150,58)

        $C_12p.Size = New-Object System.Drawing.Size(40,20)

        $C_12p.UseVisualStyleBackColor = $True

        $C_12p.Text = "12"

        $form.Controls.Add($C_12p)

        $C_6p = New-Object System.Windows.Forms.CheckBox

        $C_6p.Location = New-Object System.Drawing.Point(200,58)

        $C_6p.Size = New-Object System.Drawing.Size(40,20)

        $C_6p.UseVisualStyleBackColor = $True

        $C_6p.Text = "6"

        $form.Controls.Add($C_6p)

        $C_1a = New-Object System.Windows.Forms.CheckBox

        $C_1a.Location = New-Object System.Drawing.Point(20,78)

        $C_1a.Size = New-Object System.Drawing.Size(40,20)

        $C_1a.UseVisualStyleBackColor = $True

        $C_1a.Text = "1"

        $form.Controls.Add($C_1a)

        $C_7a = New-Object System.Windows.Forms.CheckBox

        $C_7a.Location = New-Object System.Drawing.Point(80,78)

        $C_7a.Size = New-Object System.Drawing.Size(40,20)

        $C_7a.UseVisualStyleBackColor = $True

        $C_7a.Text = "7"

        $form.Controls.Add($C_7a)

        $C_1p = New-Object System.Windows.Forms.CheckBox

        $C_1p.Location = New-Object System.Drawing.Point(150,78)

        $C_1p.Size = New-Object System.Drawing.Size(40,20)

        $C_1p.UseVisualStyleBackColor = $True

        $C_1p.Text = "1"

        $form.Controls.Add($C_1p)

        $C_7p = New-Object System.Windows.Forms.CheckBox

        $C_7p.Location = New-Object System.Drawing.Point(200,78)

        $C_7p.Size = New-Object System.Drawing.Size(40,20)

        $C_7p.UseVisualStyleBackColor = $True

        $C_7p.Text = "7"

        $form.Controls.Add($C_7p)

        $C_2a = New-Object System.Windows.Forms.CheckBox

        $C_2a.Location = New-Object System.Drawing.Point(20,98)

        $C_2a.Size = New-Object System.Drawing.Size(40,20)

        $C_2a.UseVisualStyleBackColor = $True

        $C_2a.Text = "2"

        $form.Controls.Add($C_2a)

        $C_8a = New-Object System.Windows.Forms.CheckBox

        $C_8a.Location = New-Object System.Drawing.Point(80,98)

        $C_8a.Size = New-Object System.Drawing.Size(40,20)

        $C_8a.UseVisualStyleBackColor = $True

        $C_8a.Text = "8"

        $form.Controls.Add($C_8a)

        $C_2p = New-Object System.Windows.Forms.CheckBox

        $C_2p.Location = New-Object System.Drawing.Point(150,98)

        $C_2p.Size = New-Object System.Drawing.Size(40,20)

        $C_2p.UseVisualStyleBackColor = $True

        $C_2p.Text = "2"

        $form.Controls.Add($C_2p)

        $C_8p = New-Object System.Windows.Forms.CheckBox

        $C_8p.Location = New-Object System.Drawing.Point(200,98)

        $C_8p.Size = New-Object System.Drawing.Size(40,20)

        $C_8p.UseVisualStyleBackColor = $True

        $C_8p.Text = "8"

        $form.Controls.Add($C_8p)

        $C_3a = New-Object System.Windows.Forms.CheckBox

        $C_3a.Location = New-Object System.Drawing.Point(20,118)

        $C_3a.Size = New-Object System.Drawing.Size(40,20)

        $C_3a.UseVisualStyleBackColor = $True

        $C_3a.Text = "3"

        $form.Controls.Add($C_3a)

        $C_9a = New-Object System.Windows.Forms.CheckBox

        $C_9a.Location = New-Object System.Drawing.Point(80,118)

        $C_9a.Size = New-Object System.Drawing.Size(40,20)

        $C_9a.UseVisualStyleBackColor = $True

        $C_9a.Text = "9"

        $form.Controls.Add($C_9a)

        $C_3p = New-Object System.Windows.Forms.CheckBox

        $C_3p.Location = New-Object System.Drawing.Point(150,118)

        $C_3p.Size = New-Object System.Drawing.Size(40,20)

        $C_3p.UseVisualStyleBackColor = $True

        $C_3p.Text = "3"

        $form.Controls.Add($C_3p)

        $C_9p = New-Object System.Windows.Forms.CheckBox

        $C_9p.Location = New-Object System.Drawing.Point(200,118)

        $C_9p.Size = New-Object System.Drawing.Size(40,20)

        $C_9p.UseVisualStyleBackColor = $True

        $C_9p.Text = "9"

        $form.Controls.Add($C_9p)

        $C_4a = New-Object System.Windows.Forms.CheckBox

        $C_4a.Location = New-Object System.Drawing.Point(20,138)

        $C_4a.Size = New-Object System.Drawing.Size(40,20)

        $C_4a.UseVisualStyleBackColor = $True

        $C_4a.Text = "4"

        $form.Controls.Add($C_4a)

        $C_10a = New-Object System.Windows.Forms.CheckBox

        $C_10a.Location = New-Object System.Drawing.Point(80,138)

        $C_10a.Size = New-Object System.Drawing.Size(40,20)

        $C_10a.UseVisualStyleBackColor = $True

        $C_10a.Text = "10"

        $form.Controls.Add($C_10a)

        $C_4p = New-Object System.Windows.Forms.CheckBox

        $C_4p.Location = New-Object System.Drawing.Point(150,138)

        $C_4p.Size = New-Object System.Drawing.Size(40,20)

        $C_4p.UseVisualStyleBackColor = $True

        $C_4p.Text = "4"

        $form.Controls.Add($C_4p)

        $C_10p = New-Object System.Windows.Forms.CheckBox

        $C_10p.Location = New-Object System.Drawing.Point(200,138)

        $C_10p.Size = New-Object System.Drawing.Size(40,20)

        $C_10p.UseVisualStyleBackColor = $True

        $C_10p.Text = "10"

        $form.Controls.Add($C_10p)

        $C_5a = New-Object System.Windows.Forms.CheckBox

        $C_5a.Location = New-Object System.Drawing.Point(20,158)

        $C_5a.Size = New-Object System.Drawing.Size(40,20)

        $C_5a.UseVisualStyleBackColor = $True

        $C_5a.Text = "5"

        $form.Controls.Add($C_5a)

        $C_11a = New-Object System.Windows.Forms.CheckBox

        $C_11a.Location = New-Object System.Drawing.Point(80,158)

        $C_11a.Size = New-Object System.Drawing.Size(40,20)

        $C_11a.UseVisualStyleBackColor = $True

        $C_11a.Text = "11"

        $form.Controls.Add($C_11a)

        $C_5p = New-Object System.Windows.Forms.CheckBox

        $C_5p.Location = New-Object System.Drawing.Point(150,158)

        $C_5p.Size = New-Object System.Drawing.Size(40,20)

        $C_5p.UseVisualStyleBackColor = $True

        $C_5p.Text = "5"

        $form.Controls.Add($C_5p)

        $C_11p = New-Object System.Windows.Forms.CheckBox

        $C_11p.Location = New-Object System.Drawing.Point(200,158)

        $C_11p.Size = New-Object System.Drawing.Size(40,20)

        $C_11p.UseVisualStyleBackColor = $True

        $C_11p.Text = "11"

        $form.Controls.Add($C_11p)

        If (($sourceSnapH).Length -gt "0") {

            If ($sourceSnapH -eq "22") {$C_12a.CheckState = "1"}

            If ($sourceSnapH -eq "23") {$C_1a.CheckState = "1"}

            If ($sourceSnapH -eq "0") {$C_2a.CheckState = "1"}

            If ($sourceSnapH -eq "1") {$C_3a.CheckState = "1"}

            If ($sourceSnapH -eq "2") {$C_4a.CheckState = "1"}

            If ($sourceSnapH -eq "3") {$C_5a.CheckState = "1"}

            If ($sourceSnapH -eq "4") {$C_6a.CheckState = "1"}

            If ($sourceSnapH -eq "5") {$C_7a.CheckState = "1"}

            If ($sourceSnapH -eq "6") {$C_8a.CheckState = "1"}

            If ($sourceSnapH -eq "7") {$C_9a.CheckState = "1"}

            If ($sourceSnapH -eq "8") {$C_10a.CheckState = "1"}

            If ($sourceSnapH -eq "9") {$C_11a.CheckState = "1"}

            If ($sourceSnapH -eq "10") {$C_12p.CheckState = "1"}

            If ($sourceSnapH -eq "11") {$C_1p.CheckState = "1"}

            If ($sourceSnapH -eq "12") {$C_2p.CheckState = "1"}

            If ($sourceSnapH -eq "13") {$C_3p.CheckState = "1"}

            If ($sourceSnapH -eq "14") {$C_4p.CheckState = "1"}

            If ($sourceSnapH -eq "15") {$C_5p.CheckState = "1"}

            If ($sourceSnapH -eq "16") {$C_6p.CheckState = "1"}

            If ($sourceSnapH -eq "17") {$C_7p.CheckState = "1"}

            If ($sourceSnapH -eq "18") {$C_8p.CheckState = "1"}

            If ($sourceSnapH -eq "19") {$C_9p.CheckState = "1"}

            If ($sourceSnapH -eq "20") {$C_10p.CheckState = "1"}

            If ($sourceSnapH -eq "21") {$C_11p.CheckState = "1"}

        }

        $OKButton = New-Object System.Windows.Forms.Button

        $OKButton.Location = New-Object System.Drawing.Point(55,200)

        $OKButton.Size = New-Object System.Drawing.Size(75,23)

        $OKButton.Text = "OK"

        $OKButton.Add_Click({

            If ($C_12a.CheckState -eq "1") {$DRh12a = "0"} Else {$DRh12a = ""};

            If ($C_1a.CheckState -eq "1") {$DRh1a = "1"} Else {$DRh1a = ""};

            If ($C_2a.CheckState -eq "1") {$DRh2a = "2"} Else {$DRh2a = ""};

            If ($C_3a.CheckState -eq "1") {$DRh3a = "3"} Else {$DRh3a = ""};

            If ($C_4a.CheckState -eq "1") {$DRh4a = "4"} Else {$DRh4a = ""};

            If ($C_5a.CheckState -eq "1") {$DRh5a = "5"} Else {$DRh5a = ""};

            If ($C_6a.CheckState -eq "1") {$DRh6a = "6"} Else {$DRh6a = ""};

            If ($C_7a.CheckState -eq "1") {$DRh7a = "7"} Else {$DRh7a = ""};

            If ($C_8a.CheckState -eq "1") {$DRh8a = "8"} Else {$DRh8a = ""};

            If ($C_9a.CheckState -eq "1") {$DRh9a = "9"} Else {$DRh9a = ""};

            If ($C_10a.CheckState -eq "1") {$DRh10a = "10"} Else {$DRh10a = ""};

            If ($C_11a.CheckState -eq "1") {$DRh11a = "11"} Else {$DRh11a = ""};

            If ($C_12p.CheckState -eq "1") {$DRh12p = "12"} Else {$DRh12p = ""};

            If ($C_1p.CheckState -eq "1") {$DRh1p = "13"} Else {$DRh1p = ""};

            If ($C_2p.CheckState -eq "1") {$DRh2p = "14"} Else {$DRh2p = ""};

            If ($C_3p.CheckState -eq "1") {$DRh3p = "15"} Else {$DRh3p = ""};

            If ($C_4p.CheckState -eq "1") {$DRh4p = "16"} Else {$DRh4p = ""};

            If ($C_5p.CheckState -eq "1") {$DRh5p = "17"} Else {$DRh5p = ""};

            If ($C_6p.CheckState -eq "1") {$DRh6p = "18"} Else {$DRh6p = ""};

            If ($C_7p.CheckState -eq "1") {$DRh7p = "19"} Else {$DRh7p = ""};

            If ($C_8p.CheckState -eq "1") {$DRh8p = "20"} Else {$DRh8p = ""};

            If ($C_9p.CheckState -eq "1") {$DRh9p = "21"} Else {$DRh9p = ""};

            If ($C_10p.CheckState -eq "1") {$DRh10p = "22"} Else {$DRh10p = ""};

            If ($C_11p.CheckState -eq "1") {$DRh11p = "23"} Else {$DRh11p = ""};

            $global:x="1";$form.Close()})

        $form.Controls.Add($OKButton)

        $CancelButton = New-Object System.Windows.Forms.Button

        $CancelButton.Location = New-Object System.Drawing.Point(130,200)

        $CancelButton.Size = New-Object System.Drawing.Size(75,23)

        $CancelButton.Text = "Cancel"

        $CancelButton.Add_Click({$global:x="2";$form.Close()})

        $form.Controls.Add($CancelButton)

        $form.KeyPreview = $True

        $form.Add_KeyDown({if ($_.KeyCode -eq "Enter") {

            If ($C_12a.CheckState -eq "1") {$DRh12a = "0"} Else {$DRh12a = ""};

            If ($C_1a.CheckState -eq "1") {$DRh1a = "1"} Else {$DRh1a = ""};

            If ($C_2a.CheckState -eq "1") {$DRh2a = "2"} Else {$DRh2a = ""};

            If ($C_3a.CheckState -eq "1") {$DRh3a = "3"} Else {$DRh3a = ""};

            If ($C_4a.CheckState -eq "1") {$DRh4a = "4"} Else {$DRh4a = ""};

            If ($C_5a.CheckState -eq "1") {$DRh5a = "5"} Else {$DRh5a = ""};

            If ($C_6a.CheckState -eq "1") {$DRh6a = "6"} Else {$DRh6a = ""};

            If ($C_7a.CheckState -eq "1") {$DRh7a = "7"} Else {$DRh7a = ""};

            If ($C_8a.CheckState -eq "1") {$DRh8a = "8"} Else {$DRh8a = ""};

            If ($C_9a.CheckState -eq "1") {$DRh9a = "9"} Else {$DRh9a = ""};

            If ($C_10a.CheckState -eq "1") {$DRh10a = "10"} Else {$DRh10a = ""};

            If ($C_11a.CheckState -eq "1") {$DRh11a = "11"} Else {$DRh11a = ""};

            If ($C_12p.CheckState -eq "1") {$DRh12p = "12"} Else {$DRh12p = ""};

            If ($C_1p.CheckState -eq "1") {$DRh1p = "13"} Else {$DRh1p = ""};

            If ($C_2p.CheckState -eq "1") {$DRh2p = "14"} Else {$DRh2p = ""};

            If ($C_3p.CheckState -eq "1") {$DRh3p = "15"} Else {$DRh3p = ""};

            If ($C_4p.CheckState -eq "1") {$DRh4p = "16"} Else {$DRh4p = ""};

            If ($C_5p.CheckState -eq "1") {$DRh5p = "17"} Else {$DRh5p = ""};

            If ($C_6p.CheckState -eq "1") {$DRh6p = "18"} Else {$DRh6p = ""};

            If ($C_7p.CheckState -eq "1") {$DRh7p = "19"} Else {$DRh7p = ""};

            If ($C_8p.CheckState -eq "1") {$DRh8p = "20"} Else {$DRh8p = ""};

            If ($C_9p.CheckState -eq "1") {$DRh9p = "21"} Else {$DRh9p = ""};

            If ($C_10p.CheckState -eq "1") {$DRh10p = "22"} Else {$DRh10p = ""};

            If ($C_11p.CheckState -eq "1") {$DRh11p = "23"} Else {$DRh11p = ""};

            $global:x="1";$form.Close()}})

        $form.Add_KeyDown({if ($_.KeyCode -eq "Escape")

            {$global:x="2";$form.Close()}})

        $form.Topmost = $True

        $form.Add_Shown({$form.Activate()})

        [void] $form.ShowDialog()

        If ($DRh12a -ne "") {$DRh12a += ","}

        If ($DRh1a -ne "") {$DRh1a += ","}

        If ($DRh2a -ne "") {$DRh2a += ","}

        If ($DRh3a -ne "") {$DRh3a += ","}

        If ($DRh4a -ne "") {$DRh4a += ","}

        If ($DRh5a -ne "") {$DRh5a += ","}

        If ($DRh6a -ne "") {$DRh6a += ","}

        If ($DRh7a -ne "") {$DRh7a += ","}

        If ($DRh8a -ne "") {$DRh8a += ","}

        If ($DRh9a -ne "") {$DRh9a += ","}

        If ($DRh10a -ne "") {$DRh10a += ","}

        If ($DRh11a -ne "") {$DRh11a += ","}

        If ($DRh12p -ne "") {$DRh12p += ","}

        If ($DRh1p -ne "") {$DRh1p += ","}

        If ($DRh2p -ne "") {$DRh2p += ","}

        If ($DRh3p -ne "") {$DRh3p += ","}

        If ($DRh4p -ne "") {$DRh4p += ","}

        If ($DRh5p -ne "") {$DRh5p += ","}

        If ($DRh6p -ne "") {$DRh6p += ","}

        If ($DRh7p -ne "") {$DRh7p += ","}

        If ($DRh8p -ne "") {$DRh8p += ","}

        If ($DRh9p -ne "") {$DRh9p += ","}

        If ($DRh10p -ne "") {$DRh10p += ","}

        $DRsnapHours1 = $DRh12a+$DRh1a+$DRh2a+$DRh3a+$DRh4a+$DRh5a+$DRh6a+$DRh7a+$DRh8a+$DRh9a+$DRh10a+$DRh11a+$DRh12p+$DRh1p+$DRh2p+$DRh3p+$DRh4p+$DRh5p+$DRh6p+$DRh7p+$DRh8p+$DRh9p+$DRh10p+$DRh11p

        If ($DRsnapHours1.substring((($DRsnapHours1.length) -1), 1) -eq ",") {$globalSmiley Very HappyRsnapHours = $DRsnapHours1.substring(0,(($DRsnapHours1.length) -1))} Else {$globalSmiley Very HappyRsnapHours=$DRsnapHours1}

    }

    Function NoSourceSnap () {

        # Alert user if no source snapshots
        $form = New-Object System.Windows.Forms.Form

        $form.Text = "No Source Snapshots"

        $form.Size = New-Object System.Drawing.Size(300,120)

        $form.StartPosition = "CenterScreen"

        $Label = New-Object System.Windows.Forms.Label

        $Label.Location = New-Object System.Drawing.Size(0,10)

        $Label.Size = New-Object System.Drawing.Size(285,40)

        $Label.TextAlign = 2

        $Label.Text = "Snapshots were not configured on source volume.`nThey will not be set on the DR volume!"

        $form.Controls.Add($Label)

        $OKButton = New-Object System.Windows.Forms.Button

        $OKButton.Location = New-Object System.Drawing.Size(112,50)

        $OKButton.Size = New-Object System.Drawing.Size(75,25)

        $OKButton.Text = "OK"

        $OKButton.Add_Click({$global:x="1";$form.Close()})

        $form.Controls.Add($OKButton)

        $form.Topmost = $True

        $form.Add_Shown({$form.Activate()})

        [void] $form.ShowDialog()   

    }

    Function Get_DRAsis ($sourceASISH) {

        # Get ASIS schedule for DR volume
        # Default to same time as source, if source ASIS was enabled
        $form = New-Object System.Windows.Forms.Form

        $form.Text = "DR ASIS Details"

        $form.Size = New-Object System.Drawing.Size(270,275)

        $form.StartPosition = "CenterScreen"

        $L_Hours = New-Object System.Windows.Forms.Label

        $L_Hours.Location = New-Object System.Drawing.Point(0,10)

        $L_Hours.Size = New-Object System.Drawing.Size(260,30)

        $L_Hours.TextAlign = 2

        $L_Hours.Text = "On what hour should Storage Efficiency run?`n(this should be after hours)"

        $form.Controls.Add($L_Hours)

        $L_am = New-Object System.Windows.Forms.Label

        $L_am.Location = New-Object System.Drawing.Point(53,40)

        $L_am.Size = New-Object System.Drawing.Size(40,20)

        $L_am.Text = "AM"

        $form.Controls.Add($L_am)

        $L_pm = New-Object System.Windows.Forms.Label

        $L_pm.Location = New-Object System.Drawing.Point(178,40)

        $L_pm.Size = New-Object System.Drawing.Size(40,20)

        $L_pm.Text = "PM"

        $form.Controls.Add($L_pm)

        $C_12a = New-Object System.Windows.Forms.CheckBox

        $C_12a.Location = New-Object System.Drawing.Point(20,58)

        $C_12a.Size = New-Object System.Drawing.Size(40,20)

        $C_12a.UseVisualStyleBackColor = $True

        $C_12a.Text = "12"

        $form.Controls.Add($C_12a)

        $C_6a = New-Object System.Windows.Forms.CheckBox

        $C_6a.Location = New-Object System.Drawing.Point(80,58)

        $C_6a.Size = New-Object System.Drawing.Size(40,20)

        $C_6a.UseVisualStyleBackColor = $True

        $C_6a.Text = "6"

        $form.Controls.Add($C_6a)

        $C_12p = New-Object System.Windows.Forms.CheckBox

        $C_12p.Location = New-Object System.Drawing.Point(150,58)

        $C_12p.Size = New-Object System.Drawing.Size(40,20)

        $C_12p.UseVisualStyleBackColor = $True

        $C_12p.Text = "12"

        $form.Controls.Add($C_12p)

        $C_6p = New-Object System.Windows.Forms.CheckBox

        $C_6p.Location = New-Object System.Drawing.Point(200,58)

        $C_6p.Size = New-Object System.Drawing.Size(40,20)

        $C_6p.UseVisualStyleBackColor = $True

        $C_6p.Text = "6"

        $form.Controls.Add($C_6p)

        $C_1a = New-Object System.Windows.Forms.CheckBox

        $C_1a.Location = New-Object System.Drawing.Point(20,78)

        $C_1a.Size = New-Object System.Drawing.Size(40,20)

        $C_1a.UseVisualStyleBackColor = $True

        $C_1a.Text = "1"

        $form.Controls.Add($C_1a)

        $C_7a = New-Object System.Windows.Forms.CheckBox

        $C_7a.Location = New-Object System.Drawing.Point(80,78)

        $C_7a.Size = New-Object System.Drawing.Size(40,20)

        $C_7a.UseVisualStyleBackColor = $True

        $C_7a.Text = "7"

        $form.Controls.Add($C_7a)

        $C_1p = New-Object System.Windows.Forms.CheckBox

        $C_1p.Location = New-Object System.Drawing.Point(150,78)

        $C_1p.Size = New-Object System.Drawing.Size(40,20)

        $C_1p.UseVisualStyleBackColor = $True

        $C_1p.Text = "1"

        $form.Controls.Add($C_1p)

        $C_7p = New-Object System.Windows.Forms.CheckBox

        $C_7p.Location = New-Object System.Drawing.Point(200,78)

        $C_7p.Size = New-Object System.Drawing.Size(40,20)

        $C_7p.UseVisualStyleBackColor = $True

        $C_7p.Text = "7"

        $form.Controls.Add($C_7p)

        $C_2a = New-Object System.Windows.Forms.CheckBox

        $C_2a.Location = New-Object System.Drawing.Point(20,98)

        $C_2a.Size = New-Object System.Drawing.Size(40,20)

        $C_2a.UseVisualStyleBackColor = $True

        $C_2a.Text = "2"

        $form.Controls.Add($C_2a)

        $C_8a = New-Object System.Windows.Forms.CheckBox

        $C_8a.Location = New-Object System.Drawing.Point(80,98)

        $C_8a.Size = New-Object System.Drawing.Size(40,20)

        $C_8a.UseVisualStyleBackColor = $True

        $C_8a.Text = "8"

        $form.Controls.Add($C_8a)

        $C_2p = New-Object System.Windows.Forms.CheckBox

        $C_2p.Location = New-Object System.Drawing.Point(150,98)

        $C_2p.Size = New-Object System.Drawing.Size(40,20)

        $C_2p.UseVisualStyleBackColor = $True

        $C_2p.Text = "2"

        $form.Controls.Add($C_2p)

        $C_8p = New-Object System.Windows.Forms.CheckBox

        $C_8p.Location = New-Object System.Drawing.Point(200,98)

        $C_8p.Size = New-Object System.Drawing.Size(40,20)

        $C_8p.UseVisualStyleBackColor = $True

        $C_8p.Text = "8"

        $form.Controls.Add($C_8p)

        $C_3a = New-Object System.Windows.Forms.CheckBox

        $C_3a.Location = New-Object System.Drawing.Point(20,118)

        $C_3a.Size = New-Object System.Drawing.Size(40,20)

        $C_3a.UseVisualStyleBackColor = $True

        $C_3a.Text = "3"

        $form.Controls.Add($C_3a)

        $C_9a = New-Object System.Windows.Forms.CheckBox

        $C_9a.Location = New-Object System.Drawing.Point(80,118)

        $C_9a.Size = New-Object System.Drawing.Size(40,20)

        $C_9a.UseVisualStyleBackColor = $True

        $C_9a.Text = "9"

        $form.Controls.Add($C_9a)

        $C_3p = New-Object System.Windows.Forms.CheckBox

        $C_3p.Location = New-Object System.Drawing.Point(150,118)

        $C_3p.Size = New-Object System.Drawing.Size(40,20)

        $C_3p.UseVisualStyleBackColor = $True

        $C_3p.Text = "3"

        $form.Controls.Add($C_3p)

        $C_9p = New-Object System.Windows.Forms.CheckBox

        $C_9p.Location = New-Object System.Drawing.Point(200,118)

        $C_9p.Size = New-Object System.Drawing.Size(40,20)

        $C_9p.UseVisualStyleBackColor = $True

        $C_9p.Text = "9"

        $form.Controls.Add($C_9p)

        $C_4a = New-Object System.Windows.Forms.CheckBox

        $C_4a.Location = New-Object System.Drawing.Point(20,138)

        $C_4a.Size = New-Object System.Drawing.Size(40,20)

        $C_4a.UseVisualStyleBackColor = $True

        $C_4a.Text = "4"

        $form.Controls.Add($C_4a)

        $C_10a = New-Object System.Windows.Forms.CheckBox

        $C_10a.Location = New-Object System.Drawing.Point(80,138)

        $C_10a.Size = New-Object System.Drawing.Size(40,20)

        $C_10a.UseVisualStyleBackColor = $True

        $C_10a.Text = "10"

        $form.Controls.Add($C_10a)

        $C_4p = New-Object System.Windows.Forms.CheckBox

        $C_4p.Location = New-Object System.Drawing.Point(150,138)

        $C_4p.Size = New-Object System.Drawing.Size(40,20)

        $C_4p.UseVisualStyleBackColor = $True

        $C_4p.Text = "4"

        $form.Controls.Add($C_4p)

        $C_10p = New-Object System.Windows.Forms.CheckBox

        $C_10p.Location = New-Object System.Drawing.Point(200,138)

        $C_10p.Size = New-Object System.Drawing.Size(40,20)

        $C_10p.UseVisualStyleBackColor = $True

        $C_10p.Text = "10"

        $form.Controls.Add($C_10p)

        $C_5a = New-Object System.Windows.Forms.CheckBox

        $C_5a.Location = New-Object System.Drawing.Point(20,158)

        $C_5a.Size = New-Object System.Drawing.Size(40,20)

        $C_5a.UseVisualStyleBackColor = $True

        $C_5a.Text = "5"

        $form.Controls.Add($C_5a)

        $C_11a = New-Object System.Windows.Forms.CheckBox

        $C_11a.Location = New-Object System.Drawing.Point(80,158)

        $C_11a.Size = New-Object System.Drawing.Size(40,20)

        $C_11a.UseVisualStyleBackColor = $True

        $C_11a.Text = "11"

        $form.Controls.Add($C_11a)

        $C_5p = New-Object System.Windows.Forms.CheckBox

        $C_5p.Location = New-Object System.Drawing.Point(150,158)

        $C_5p.Size = New-Object System.Drawing.Size(40,20)

        $C_5p.UseVisualStyleBackColor = $True

        $C_5p.Text = "5"

        $form.Controls.Add($C_5p)

        $C_11p = New-Object System.Windows.Forms.CheckBox

        $C_11p.Location = New-Object System.Drawing.Point(200,158)

        $C_11p.Size = New-Object System.Drawing.Size(40,20)

        $C_11p.UseVisualStyleBackColor = $True

        $C_11p.Text = "11"

        $form.Controls.Add($C_11p)

        If (($sourceASISH).Length -gt "0") {

            If ($sourceASISH -eq "0") {$C_12a.CheckState = "1"}

            If ($sourceASISH -eq "1") {$C_1a.CheckState = "1"}

            If ($sourceASISH -eq "2") {$C_2a.CheckState = "1"}

            If ($sourceASISH -eq "3") {$C_3a.CheckState = "1"}

            If ($sourceASISH -eq "4") {$C_4a.CheckState = "1"}

            If ($sourceASISH -eq "5") {$C_5a.CheckState = "1"}

            If ($sourceASISH -eq "6") {$C_6a.CheckState = "1"}

            If ($sourceASISH -eq "7") {$C_7a.CheckState = "1"}

            If ($sourceASISH -eq "8") {$C_8a.CheckState = "1"}

            If ($sourceASISH -eq "9") {$C_9a.CheckState = "1"}

            If ($sourceASISH -eq "10") {$C_10a.CheckState = "1"}

            If ($sourceASISH -eq "11") {$C_11a.CheckState = "1"}

            If ($sourceASISH -eq "12") {$C_12p.CheckState = "1"}

            If ($sourceASISH -eq "13") {$C_1p.CheckState = "1"}

            If ($sourceASISH -eq "14") {$C_2p.CheckState = "1"}

            If ($sourceASISH -eq "15") {$C_3p.CheckState = "1"}

            If ($sourceASISH -eq "16") {$C_4p.CheckState = "1"}

            If ($sourceASISH -eq "17") {$C_5p.CheckState = "1"}

            If ($sourceASISH -eq "18") {$C_6p.CheckState = "1"}

            If ($sourceASISH -eq "19") {$C_7p.CheckState = "1"}

            If ($sourceASISH -eq "20") {$C_8p.CheckState = "1"}

            If ($sourceASISH -eq "21") {$C_9p.CheckState = "1"}

            If ($sourceASISH -eq "22") {$C_10p.CheckState = "1"}

            If ($sourceASISH -eq "23") {$C_11p.CheckState = "1"}

        }

        $OKButton = New-Object System.Windows.Forms.Button

        $OKButton.Location = New-Object System.Drawing.Point(55,200)

        $OKButton.Size = New-Object System.Drawing.Size(75,23)

        $OKButton.Text = "OK"

        $OKButton.Add_Click({

            If ($C_12a.CheckState -eq "1") {$DRh12a1 = "0"} Else {$DRh12a1 = ""};

            If ($C_1a.CheckState -eq "1") {$DRh1a1 = "1"} Else {$DRh1a1 = ""};

            If ($C_2a.CheckState -eq "1") {$DRh2a1 = "2"} Else {$DRh2a1 = ""};

            If ($C_3a.CheckState -eq "1") {$DRh3a1 = "3"} Else {$DRh3a1 = ""};

            If ($C_4a.CheckState -eq "1") {$DRh4a1 = "4"} Else {$DRh4a1 = ""};

            If ($C_5a.CheckState -eq "1") {$DRh5a1 = "5"} Else {$DRh5a1 = ""};

            If ($C_6a.CheckState -eq "1") {$DRh6a1 = "6"} Else {$DRh6a1 = ""};

            If ($C_7a.CheckState -eq "1") {$DRh7a1 = "7"} Else {$DRh7a1 = ""};

            If ($C_8a.CheckState -eq "1") {$DRh8a1 = "8"} Else {$DRh8a1 = ""};

            If ($C_9a.CheckState -eq "1") {$DRh9a1 = "9"} Else {$DRh9a1 = ""};

            If ($C_10a.CheckState -eq "1") {$DRh10a1 = "10"} Else {$DRh10a1 = ""};

            If ($C_11a.CheckState -eq "1") {$DRh11a1 = "11"} Else {$DRh11a1 = ""};

            If ($C_12p.CheckState -eq "1") {$DRh12p1 = "12"} Else {$DRh12p1 = ""};

            If ($C_1p.CheckState -eq "1") {$DRh1p1 = "13"} Else {$DRh1p1 = ""};

            If ($C_2p.CheckState -eq "1") {$DRh2p1 = "14"} Else {$DRh2p1 = ""};

            If ($C_3p.CheckState -eq "1") {$DRh3p1 = "15"} Else {$DRh3p1 = ""};

            If ($C_4p.CheckState -eq "1") {$DRh4p1 = "16"} Else {$DRh4p1 = ""};

            If ($C_5p.CheckState -eq "1") {$DRh5p1 = "17"} Else {$DRh5p1 = ""};

            If ($C_6p.CheckState -eq "1") {$DRh6p1 = "18"} Else {$DRh6p1 = ""};

            If ($C_7p.CheckState -eq "1") {$DRh7p1 = "19"} Else {$DRh7p1 = ""};

            If ($C_8p.CheckState -eq "1") {$DRh8p1 = "20"} Else {$DRh8p1 = ""};

            If ($C_9p.CheckState -eq "1") {$DRh9p1 = "21"} Else {$DRh9p1 = ""};

            If ($C_10p.CheckState -eq "1") {$DRh10p1 = "22"} Else {$DRh10p1 = ""};

            If ($C_11p.CheckState -eq "1") {$DRh11p1 = "23"} Else {$DRh11p1 = ""};

            $global:x="1";$form.Close()})

        $form.Controls.Add($OKButton)

        $CancelButton = New-Object System.Windows.Forms.Button

        $CancelButton.Location = New-Object System.Drawing.Point(130,200)

        $CancelButton.Size = New-Object System.Drawing.Size(75,23)

        $CancelButton.Text = "Cancel"

        $CancelButton.Add_Click({$global:x="2";$form.Close()})

        $form.Controls.Add($CancelButton)

        $form.KeyPreview = $True

        $form.Add_KeyDown({if ($_.KeyCode -eq "Enter") {

            If ($C_12a.CheckState -eq "1") {$DRh12a1 = "0"} Else {$DRh12a1 = ""};

            If ($C_1a.CheckState -eq "1") {$DRh1a1 = "1"} Else {$DRh1a1 = ""};

            If ($C_2a.CheckState -eq "1") {$DRh2a1 = "2"} Else {$DRh2a1 = ""};

            If ($C_3a.CheckState -eq "1") {$DRh3a1 = "3"} Else {$DRh3a1 = ""};

            If ($C_4a.CheckState -eq "1") {$DRh4a1 = "4"} Else {$DRh4a1 = ""};

            If ($C_5a.CheckState -eq "1") {$DRh5a1 = "5"} Else {$DRh5a1 = ""};

            If ($C_6a.CheckState -eq "1") {$DRh6a1 = "6"} Else {$DRh6a1 = ""};

            If ($C_7a.CheckState -eq "1") {$DRh7a1 = "7"} Else {$DRh7a1 = ""};

            If ($C_8a.CheckState -eq "1") {$DRh8a1 = "8"} Else {$DRh8a1 = ""};

            If ($C_9a.CheckState -eq "1") {$DRh9a1 = "9"} Else {$DRh9a1 = ""};

            If ($C_10a.CheckState -eq "1") {$DRh10a1 = "10"} Else {$DRh10a1 = ""};

            If ($C_11a.CheckState -eq "1") {$DRh11a1 = "11"} Else {$DRh11a1 = ""};

            If ($C_12p.CheckState -eq "1") {$DRh12p1 = "12"} Else {$DRh12p1 = ""};

            If ($C_1p.CheckState -eq "1") {$DRh1p1 = "13"} Else {$DRh1p1 = ""};

            If ($C_2p.CheckState -eq "1") {$DRh2p1 = "14"} Else {$DRh2p1 = ""};

            If ($C_3p.CheckState -eq "1") {$DRh3p1 = "15"} Else {$DRh3p1 = ""};

            If ($C_4p.CheckState -eq "1") {$DRh4p1 = "16"} Else {$DRh4p1 = ""};

            If ($C_5p.CheckState -eq "1") {$DRh5p1 = "17"} Else {$DRh5p1 = ""};

            If ($C_6p.CheckState -eq "1") {$DRh6p1 = "18"} Else {$DRh6p1 = ""};

            If ($C_7p.CheckState -eq "1") {$DRh7p1 = "19"} Else {$DRh7p1 = ""};

            If ($C_8p.CheckState -eq "1") {$DRh8p1 = "20"} Else {$DRh8p1 = ""};

            If ($C_9p.CheckState -eq "1") {$DRh9p1 = "21"} Else {$DRh9p1 = ""};

            If ($C_10p.CheckState -eq "1") {$DRh10p1 = "22"} Else {$DRh10p1 = ""};

            If ($C_11p.CheckState -eq "1") {$DRh11p1 = "23"} Else {$DRh11p1 = ""};

            $global:x="1";$form.Close()}})

        $form.Add_KeyDown({if ($_.KeyCode -eq "Escape")

            {$global:x="2";$form.Close()}})

        $form.Topmost = $True

        $form.Add_Shown({$form.Activate()})

        [void] $form.ShowDialog()

        If ($DRh12a1 -ne "") {$DRh12a1 += ","}

        If ($DRh1a1 -ne "") {$DRh1a1 += ","}

        If ($DRh2a1 -ne "") {$DRh2a1 += ","}

        If ($DRh3a1 -ne "") {$DRh3a1 += ","}

        If ($DRh4a1 -ne "") {$DRh4a1 += ","}

        If ($DRh5a1 -ne "") {$DRh5a1 += ","}

        If ($DRh6a1 -ne "") {$DRh6a1 += ","}

        If ($DRh7a1 -ne "") {$DRh7a1 += ","}

        If ($DRh8a1 -ne "") {$DRh8a1 += ","}

        If ($DRh9a1 -ne "") {$DRh9a1 += ","}

        If ($DRh10a1 -ne "") {$DRh10a1 += ","}

        If ($DRh11a1 -ne "") {$DRh11a1 += ","}

        If ($DRh12p1 -ne "") {$DRh12p1 += ","}

        If ($DRh1p1 -ne "") {$DRh1p1 += ","}

        If ($DRh2p1 -ne "") {$DRh2p1 += ","}

        If ($DRh3p1 -ne "") {$DRh3p1 += ","}

        If ($DRh4p1 -ne "") {$DRh4p1 += ","}

        If ($DRh5p1 -ne "") {$DRh5p1 += ","}

        If ($DRh6p1 -ne "") {$DRh6p1 += ","}

        If ($DRh7p1 -ne "") {$DRh7p1 += ","}

        If ($DRh8p1 -ne "") {$DRh8p1 += ","}

        If ($DRh9p1 -ne "") {$DRh9p1 += ","}

        If ($DRh10p1 -ne "") {$DRh10p1 += ","}

        If ($DRh11p1 -ne "") {$DRh11p1 += ","}

        $DRasisHours1 = $DRh12a1+$DRh1a1+$DRh2a1+$DRh3a1+$DRh4a1+$DRh5a1+$DRh6a1+$DRh7a1+$DRh8a1+$DRh9a1+$DRh10a1+$DRh11a1+$DRh12p1+$DRh1p1+$DRh2p1+$DRh3p1+$DRh4p1+$DRh5p1+$DRh6p1+$DRh7p1+$DRh8p1+$DRh9p1+$DRh10p1+$DRh11p1

        If ($DRasisHours1.substring((($DRasisHours1.length) -1), 1) -eq ",") {$globalSmiley Very HappyRasisHours = $DRasisHours1.substring(0,(($DRasisHours1.length) -1))} Else {$globalSmiley Very HappyRasisHours=$DRasisHours1}

    }

    Function Get_MirrorHour ($sourceSnapH) {

        # Get QSM schedule
        # Default to 1 hour after source snapshot was taken
        $form = New-Object System.Windows.Forms.Form

        $form.Text = "SnapMirror Details"

        $form.Size = New-Object System.Drawing.Size(270,275)

        $form.StartPosition = "CenterScreen"

        $L_Hours = New-Object System.Windows.Forms.Label

        $L_Hours.Location = New-Object System.Drawing.Size(0,20)

        $L_Hours.Size = New-Object System.Drawing.Size(260,20)

        $L_Hours.TextAlign = 2

        $L_Hours.Text = "On what hour should the SnapMirror run?"

        $form.Controls.Add($L_Hours)

        $L_am = New-Object System.Windows.Forms.Label

        $L_am.Location = New-Object System.Drawing.Point(53,40)

        $L_am.Size = New-Object System.Drawing.Size(40,20)

        $L_am.Text = "AM"

        $form.Controls.Add($L_am)

        $L_pm = New-Object System.Windows.Forms.Label

        $L_pm.Location = New-Object System.Drawing.Point(178,40)

        $L_pm.Size = New-Object System.Drawing.Size(40,20)

        $L_pm.Text = "PM"

        $form.Controls.Add($L_pm)

        $C_12a = New-Object System.Windows.Forms.CheckBox

        $C_12a.Location = New-Object System.Drawing.Point(20,58)

        $C_12a.Size = New-Object System.Drawing.Size(40,20)

        $C_12a.UseVisualStyleBackColor = $True

        $C_12a.Text = "12"

        $form.Controls.Add($C_12a)

        $C_6a = New-Object System.Windows.Forms.CheckBox

        $C_6a.Location = New-Object System.Drawing.Point(80,58)

        $C_6a.Size = New-Object System.Drawing.Size(40,20)

        $C_6a.UseVisualStyleBackColor = $True

        $C_6a.Text = "6"

        $form.Controls.Add($C_6a)

        $C_12p = New-Object System.Windows.Forms.CheckBox

        $C_12p.Location = New-Object System.Drawing.Point(150,58)

        $C_12p.Size = New-Object System.Drawing.Size(40,20)

        $C_12p.UseVisualStyleBackColor = $True

        $C_12p.Text = "12"

        $form.Controls.Add($C_12p)

        $C_6p = New-Object System.Windows.Forms.CheckBox

        $C_6p.Location = New-Object System.Drawing.Point(200,58)

        $C_6p.Size = New-Object System.Drawing.Size(40,20)

        $C_6p.UseVisualStyleBackColor = $True

        $C_6p.Text = "6"

        $form.Controls.Add($C_6p)

        $C_1a = New-Object System.Windows.Forms.CheckBox

        $C_1a.Location = New-Object System.Drawing.Point(20,78)

        $C_1a.Size = New-Object System.Drawing.Size(40,20)

        $C_1a.UseVisualStyleBackColor = $True

        $C_1a.Text = "1"

        $form.Controls.Add($C_1a)

        $C_7a = New-Object System.Windows.Forms.CheckBox

        $C_7a.Location = New-Object System.Drawing.Point(80,78)

        $C_7a.Size = New-Object System.Drawing.Size(40,20)

        $C_7a.UseVisualStyleBackColor = $True

        $C_7a.Text = "7"

        $form.Controls.Add($C_7a)

        $C_1p = New-Object System.Windows.Forms.CheckBox

        $C_1p.Location = New-Object System.Drawing.Point(150,78)

        $C_1p.Size = New-Object System.Drawing.Size(40,20)

        $C_1p.UseVisualStyleBackColor = $True

        $C_1p.Text = "1"

        $form.Controls.Add($C_1p)

        $C_7p = New-Object System.Windows.Forms.CheckBox

        $C_7p.Location = New-Object System.Drawing.Point(200,78)

        $C_7p.Size = New-Object System.Drawing.Size(40,20)

        $C_7p.UseVisualStyleBackColor = $True

        $C_7p.Text = "7"

        $form.Controls.Add($C_7p)

        $C_2a = New-Object System.Windows.Forms.CheckBox

        $C_2a.Location = New-Object System.Drawing.Point(20,98)

        $C_2a.Size = New-Object System.Drawing.Size(40,20)

        $C_2a.UseVisualStyleBackColor = $True

        $C_2a.Text = "2"

        $form.Controls.Add($C_2a)

        $C_8a = New-Object System.Windows.Forms.CheckBox

        $C_8a.Location = New-Object System.Drawing.Point(80,98)

        $C_8a.Size = New-Object System.Drawing.Size(40,20)

        $C_8a.UseVisualStyleBackColor = $True

        $C_8a.Text = "8"

        $form.Controls.Add($C_8a)

        $C_2p = New-Object System.Windows.Forms.CheckBox

        $C_2p.Location = New-Object System.Drawing.Point(150,98)

        $C_2p.Size = New-Object System.Drawing.Size(40,20)

        $C_2p.UseVisualStyleBackColor = $True

        $C_2p.Text = "2"

        $form.Controls.Add($C_2p)

        $C_8p = New-Object System.Windows.Forms.CheckBox

        $C_8p.Location = New-Object System.Drawing.Point(200,98)

        $C_8p.Size = New-Object System.Drawing.Size(40,20)

        $C_8p.UseVisualStyleBackColor = $True

        $C_8p.Text = "8"

        $form.Controls.Add($C_8p)

        $C_3a = New-Object System.Windows.Forms.CheckBox

        $C_3a.Location = New-Object System.Drawing.Point(20,118)

        $C_3a.Size = New-Object System.Drawing.Size(40,20)

        $C_3a.UseVisualStyleBackColor = $True

        $C_3a.Text = "3"

        $form.Controls.Add($C_3a)

        $C_9a = New-Object System.Windows.Forms.CheckBox

        $C_9a.Location = New-Object System.Drawing.Point(80,118)

        $C_9a.Size = New-Object System.Drawing.Size(40,20)

        $C_9a.UseVisualStyleBackColor = $True

        $C_9a.Text = "9"

        $form.Controls.Add($C_9a)

        $C_3p = New-Object System.Windows.Forms.CheckBox

        $C_3p.Location = New-Object System.Drawing.Point(150,118)

        $C_3p.Size = New-Object System.Drawing.Size(40,20)

        $C_3p.UseVisualStyleBackColor = $True

        $C_3p.Text = "3"

        $form.Controls.Add($C_3p)

        $C_9p = New-Object System.Windows.Forms.CheckBox

        $C_9p.Location = New-Object System.Drawing.Point(200,118)

        $C_9p.Size = New-Object System.Drawing.Size(40,20)

        $C_9p.UseVisualStyleBackColor = $True

        $C_9p.Text = "9"

        $form.Controls.Add($C_9p)

        $C_4a = New-Object System.Windows.Forms.CheckBox

        $C_4a.Location = New-Object System.Drawing.Point(20,138)

        $C_4a.Size = New-Object System.Drawing.Size(40,20)

        $C_4a.UseVisualStyleBackColor = $True

        $C_4a.Text = "4"

        $form.Controls.Add($C_4a)

        $C_10a = New-Object System.Windows.Forms.CheckBox

        $C_10a.Location = New-Object System.Drawing.Point(80,138)

        $C_10a.Size = New-Object System.Drawing.Size(40,20)

        $C_10a.UseVisualStyleBackColor = $True

        $C_10a.Text = "10"

        $form.Controls.Add($C_10a)

        $C_4p = New-Object System.Windows.Forms.CheckBox

        $C_4p.Location = New-Object System.Drawing.Point(150,138)

        $C_4p.Size = New-Object System.Drawing.Size(40,20)

        $C_4p.UseVisualStyleBackColor = $True

        $C_4p.Text = "4"

        $form.Controls.Add($C_4p)

        $C_10p = New-Object System.Windows.Forms.CheckBox

        $C_10p.Location = New-Object System.Drawing.Point(200,138)

        $C_10p.Size = New-Object System.Drawing.Size(40,20)

        $C_10p.UseVisualStyleBackColor = $True

        $C_10p.Text = "10"

        $form.Controls.Add($C_10p)

        $C_5a = New-Object System.Windows.Forms.CheckBox

        $C_5a.Location = New-Object System.Drawing.Point(20,158)

        $C_5a.Size = New-Object System.Drawing.Size(40,20)

        $C_5a.UseVisualStyleBackColor = $True

        $C_5a.Text = "5"

        $form.Controls.Add($C_5a)

        $C_11a = New-Object System.Windows.Forms.CheckBox

        $C_11a.Location = New-Object System.Drawing.Point(80,158)

        $C_11a.Size = New-Object System.Drawing.Size(40,20)

        $C_11a.UseVisualStyleBackColor = $True

        $C_11a.Text = "11"

        $form.Controls.Add($C_11a)

        $C_5p = New-Object System.Windows.Forms.CheckBox

        $C_5p.Location = New-Object System.Drawing.Point(150,158)

        $C_5p.Size = New-Object System.Drawing.Size(40,20)

        $C_5p.UseVisualStyleBackColor = $True

        $C_5p.Text = "5"

        $form.Controls.Add($C_5p)

        $C_11p = New-Object System.Windows.Forms.CheckBox

        $C_11p.Location = New-Object System.Drawing.Point(200,158)

        $C_11p.Size = New-Object System.Drawing.Size(40,20)

        $C_11p.UseVisualStyleBackColor = $True

        $C_11p.Text = "11"

        $form.Controls.Add($C_11p)

        If (($sourceSnapH).Length -gt "0") {

            If ($sourceSnapH -eq "23") {$C_12a.CheckState = "1"}

            If ($sourceSnapH -eq "0") {$C_1a.CheckState = "1"}

            If ($sourceSnapH -eq "1") {$C_2a.CheckState = "1"}

            If ($sourceSnapH -eq "2") {$C_3a.CheckState = "1"}

            If ($sourceSnapH -eq "3") {$C_4a.CheckState = "1"}

            If ($sourceSnapH -eq "4") {$C_5a.CheckState = "1"}

            If ($sourceSnapH -eq "5") {$C_6a.CheckState = "1"}

            If ($sourceSnapH -eq "6") {$C_7a.CheckState = "1"}

            If ($sourceSnapH -eq "7") {$C_8a.CheckState = "1"}

            If ($sourceSnapH -eq "8") {$C_9a.CheckState = "1"}

            If ($sourceSnapH -eq "9") {$C_10a.CheckState = "1"}

            If ($sourceSnapH -eq "10") {$C_11a.CheckState = "1"}

            If ($sourceSnapH -eq "11") {$C_12p.CheckState = "1"}

            If ($sourceSnapH -eq "12") {$C_1p.CheckState = "1"}

            If ($sourceSnapH -eq "13") {$C_2p.CheckState = "1"}

            If ($sourceSnapH -eq "14") {$C_3p.CheckState = "1"}

            If ($sourceSnapH -eq "15") {$C_4p.CheckState = "1"}

            If ($sourceSnapH -eq "16") {$C_5p.CheckState = "1"}

            If ($sourceSnapH -eq "17") {$C_6p.CheckState = "1"}

            If ($sourceSnapH -eq "18") {$C_7p.CheckState = "1"}

            If ($sourceSnapH -eq "19") {$C_8p.CheckState = "1"}

            If ($sourceSnapH -eq "20") {$C_9p.CheckState = "1"}

            If ($sourceSnapH -eq "21") {$C_10p.CheckState = "1"}

            If ($sourceSnapH -eq "22") {$C_11p.CheckState = "1"}

        }

        $OKButton = New-Object System.Windows.Forms.Button

        $OKButton.Location = New-Object System.Drawing.Size(55,200)

        $OKButton.Size = New-Object System.Drawing.Size(75,23)

        $OKButton.Text = "OK"

        $OKButton.Add_Click({

            If ($C_12a.CheckState -eq "1") {$global:MirrorHour = "0"}

            If ($C_1a.CheckState -eq "1") {$global:MirrorHour = "1"}

            If ($C_2a.CheckState -eq "1") {$global:MirrorHour = "2"}

            If ($C_3a.CheckState -eq "1") {$global:MirrorHour = "3"}

            If ($C_4a.CheckState -eq "1") {$global:MirrorHour = "4"}

            If ($C_5a.CheckState -eq "1") {$global:MirrorHour = "5"}

            If ($C_6a.CheckState -eq "1") {$global:MirrorHour = "6"}

            If ($C_7a.CheckState -eq "1") {$global:MirrorHour = "7"}

            If ($C_8a.CheckState -eq "1") {$global:MirrorHour = "8"}

            If ($C_9a.CheckState -eq "1") {$global:MirrorHour = "9"}

            If ($C_10a.CheckState -eq "1") {$global:MirrorHour = "10"}

            If ($C_11a.CheckState -eq "1") {$global:MirrorHour = "11"}

            If ($C_12p.CheckState -eq "1") {$global:MirrorHour = "12"}

            If ($C_1p.CheckState -eq "1") {$global:MirrorHour = "13"}

            If ($C_2p.CheckState -eq "1") {$global:MirrorHour = "14"}

            If ($C_3p.CheckState -eq "1") {$global:MirrorHour = "15"}

            If ($C_4p.CheckState -eq "1") {$global:MirrorHour = "16"}

            If ($C_5p.CheckState -eq "1") {$global:MirrorHour = "17"}

            If ($C_6p.CheckState -eq "1") {$global:MirrorHour = "18"}

            If ($C_7p.CheckState -eq "1") {$global:MirrorHour = "19"}

            If ($C_8p.CheckState -eq "1") {$global:MirrorHour = "20"}

            If ($C_9p.CheckState -eq "1") {$global:MirrorHour = "21"}

            If ($C_10p.CheckState -eq "1") {$global:MirrorHour = "22"}

            If ($C_11p.CheckState -eq "1") {$global:MirrorHour = "23"}

            $global:x="1";$form.Close()})

        $form.Controls.Add($OKButton)

        $CancelButton = New-Object System.Windows.Forms.Button

        $CancelButton.Location = New-Object System.Drawing.Size(130,200)

        $CancelButton.Size = New-Object System.Drawing.Size(75,23)

        $CancelButton.Text = "Cancel"

        $CancelButton.Add_Click({$global:x="2";$form.Close()})

        $form.Controls.Add($CancelButton)

        $form.KeyPreview = $True

        $form.Add_KeyDown({if ($_.KeyCode -eq "Enter") {

            If ($C_12a.CheckState -eq "1") {$global:MirrorHour = "0"}

            If ($C_1a.CheckState -eq "1") {$global:MirrorHour = "1"}

            If ($C_2a.CheckState -eq "1") {$global:MirrorHour = "2"}

            If ($C_3a.CheckState -eq "1") {$global:MirrorHour = "3"}

            If ($C_4a.CheckState -eq "1") {$global:MirrorHour = "4"}

            If ($C_5a.CheckState -eq "1") {$global:MirrorHour = "5"}

            If ($C_6a.CheckState -eq "1") {$global:MirrorHour = "6"}

            If ($C_7a.CheckState -eq "1") {$global:MirrorHour = "7"}

            If ($C_8a.CheckState -eq "1") {$global:MirrorHour = "8"}

            If ($C_9a.CheckState -eq "1") {$global:MirrorHour = "9"}

            If ($C_10a.CheckState -eq "1") {$global:MirrorHour = "10"}

            If ($C_11a.CheckState -eq "1") {$global:MirrorHour = "11"}

            If ($C_12p.CheckState -eq "1") {$global:MirrorHour = "12"}

            If ($C_1p.CheckState -eq "1") {$global:MirrorHour = "13"}

            If ($C_2p.CheckState -eq "1") {$global:MirrorHour = "14"}

            If ($C_3p.CheckState -eq "1") {$global:MirrorHour = "15"}

            If ($C_4p.CheckState -eq "1") {$global:MirrorHour = "16"}

            If ($C_5p.CheckState -eq "1") {$global:MirrorHour = "17"}

            If ($C_6p.CheckState -eq "1") {$global:MirrorHour = "18"}

            If ($C_7p.CheckState -eq "1") {$global:MirrorHour = "19"}

            If ($C_8p.CheckState -eq "1") {$global:MirrorHour = "20"}

            If ($C_9p.CheckState -eq "1") {$global:MirrorHour = "21"}

            If ($C_10p.CheckState -eq "1") {$global:MirrorHour = "22"}

            If ($C_11p.CheckState -eq "1") {$global:MirrorHour = "23"}

            $global:x="1";$form.Close()}})

        $form.Add_KeyDown({if ($_.KeyCode -eq "Escape")

            {$global:x="2";$form.Close()}})

        $form.Topmost = $True

        $form.Add_Shown({$form.Activate()})

        [void] $form.ShowDialog()

    }

    Function Source_Vol_Created () {

        # Notify user that source volume creation completed
        $form = New-Object System.Windows.Forms.Form

        $form.Text = "Source Vol Created"

        $form.Size = New-Object System.Drawing.Size(250,120)

        $form.StartPosition = "CenterScreen"

        $Label = New-Object System.Windows.Forms.Label

        $Label.Location = New-Object System.Drawing.Size(0,20)

        $Label.Size = New-Object System.Drawing.Size(240,20)

        $Label.TextAlign = 2

        $Label.Text = "The source volume has been created."

        $form.Controls.Add($Label)

        $OKButton = New-Object System.Windows.Forms.Button

        $OKButton.Location = New-Object System.Drawing.Size(88,50)

        $OKButton.Size = New-Object System.Drawing.Size(75,25)

        $OKButton.Text = "OK"

        $OKButton.Add_Click({$global:x="1";$form.Close()})

        $form.Controls.Add($OKButton)

        $form.Topmost = $True

        $form.Add_Shown({$form.Activate()})

        [void] $form.ShowDialog()

    }

    Function DR_Vol_Created () {

        # Notify user that DR volume creation completed
        $form = New-Object System.Windows.Forms.Form

        $form.Text = "DR Vol Created"

        $form.Size = New-Object System.Drawing.Size(250,120)

        $form.StartPosition = "CenterScreen"

        $Label = New-Object System.Windows.Forms.Label

        $Label.Location = New-Object System.Drawing.Size(0,20)

        $Label.Size = New-Object System.Drawing.Size(240,20)

        $Label.TextAlign = 2

        $Label.Text = "The DR volume has been created."

        $form.Controls.Add($Label)

        $OKButton = New-Object System.Windows.Forms.Button

        $OKButton.Location = New-Object System.Drawing.Size(88,50)

        $OKButton.Size = New-Object System.Drawing.Size(75,25)

        $OKButton.Text = "OK"

        $OKButton.Add_Click({$global:x="1";$form.Close()})

        $form.Controls.Add($OKButton)

        $form.Topmost = $True

        $form.Add_Shown({$form.Activate()})

        [void] $form.ShowDialog()

    }

    Function Vol_Aborted () {

        # Notify user that script was aborted
        $form = New-Object System.Windows.Forms.Form

        $form.Text = "Script Aborted"

        $form.Size = New-Object System.Drawing.Size(240,120)

        $form.StartPosition = "CenterScreen"

        $Label = New-Object System.Windows.Forms.Label

        $Label.Location = New-Object System.Drawing.Size(0,20)

        $Label.Size = New-Object System.Drawing.Size(230,20)

        $Label.TextAlign = 2

        $Label.Text = "The script was aborted!"

        $form.Controls.Add($Label)

        $OKButton = New-Object System.Windows.Forms.Button

        $OKButton.Location = New-Object System.Drawing.Size(82,50)

        $OKButton.Size = New-Object System.Drawing.Size(75,25)

        $OKButton.Text = "OK"

        $OKButton.Add_Click({$form.Close()})

        $form.Controls.Add($OKButton)

        $form.Topmost = $True

        $form.Add_Shown({$form.Activate()})

        [void] $form.ShowDialog()

    }

    ## SCRIPT ##

    #################
    ##SOURCE VOLUME##
    #################

    # Run the Select_Filer Function to select a Filer to add the volume to
    Select_Filer $Filers | Out-Null

    # Connect to selected Filer and get Aggregate variables
    If ($x -eq "0") {

        $filer1 = Connect-NaController $MyFiler

        $aggrs = Get-NaAggr

        $aggr1 = Get-NaAggr | Select-Object Name, SizeAvailable, SizeTotal, BlockType | Sort SizeAvailable -Descending

    }

    # Run the Select_Aggr Function to select the aggregate to create the volume on
    If ($x -eq "0") {Select_Aggr $aggr1 $aggrs | Out-Null}

    # Run the Vol_Details Function to get the volume name and size
    If ($x -eq "0") {Vol_Details | Out-Null}

    # If selected, Run ExportNFS Functions to get NFS Export VLANs
    If ($x -eq "0") {If ($YesExp -eq "1") {ExportNFS | Out-Null}}

    # Append collected volume size with "g"
    If ($x -eq "0") {

        [int]$vSize1 = $vSize

        [int]$drVsize = $vSize

        $vSize1 += 200

        $vSize += "g"

        [string]$vSize2 = $vSize1

        $vSize2 += "g"

    }

    # Set path for Qtree addition
    If ($x -eq "0") {

        $path = "/vol/"+$vName+"/"+$vName

        $volPath = "/vol/"+$vName

    }

    # Set CIFS Share name
    If ($x -eq "0") {$cifs = $vName+"$"}

    # Create the volume on the selected aggregate
    If ($x -eq "0") {New-NaVol -Name $vName -Aggregate $MyAggr -Size $vSize -Confirm:$false | Out-Null}

    # Create the Qtree in the new volume
    If ($x -eq "0") {New-NaQtree -Path $path -Confirm:$false | Out-Null}

    # Set SnapShot Reserve of new volume
    If ($x -eq "0") {Set-NaSnapshotReserve -Name $vName $snapRes | Out-Null}

    # Set SnapShot Schedules for new volume
    If ($x -eq "0") {

        If ($snapH -ne "0") {

            Get_SnapHours | Out-Null

            Set-NaSnapshotSchedule -Name $vName -Weeks $snapW -Days $snapN -Hours $snapH -WhichHours $snapHours | Out-Null

            }

        Else {Set-NaSnapshotSchedule -Name $vName -Weeks $snapW -Days $snapN -Hours $snapH | Out-Null}

    }

    # Set NFS Exports and delete default export
    If ($x -eq "0") {

        If ($YesExp -eq "1") {

            If ($Irv -eq "1") {Add-NaNfsExport -Persistent:$true -Path $path -ReadWrite @('192.128.10.0/24','192.128.28.0/24') -Root @('192.128.10.0/24','192.128.28.0/24') | Out-Null}

            If ($HQ -eq "1") {Add-NaNfsExport -Persistent:$true -Path $path -ReadWrite @('192.128.28.0/24','192.130.162.0/24') -Root @('192.128.28.0/24','192.130.162.0/24') | Out-Null}

            If ($V -eq "1") {Add-NaNfsExport -Persistent:$true -Path $path -ReadWrite @('192.128.10.0/24','192.128.28.0/24') -Root @('192.128.10.0/24','192.128.28.0/24') | Out-Null}

        }

        Remove-NaNfsExport -Paths $volPath | Out-Null

    }

    # Turn off Access Time Update on new volume
    If ($x -eq "0") {Set-NaVolOption $vName no_atime_update on | Out-Null}

    # Set Fractional Reserve for new volume to 0
    If ($x -eq "0") {Set-NaVolOption $vName fractional_reserve 0 | Out-Null}

    # Set unicode options for new volume
    If ($x -eq "0") {

        Set-NaVolOption $vName create_ucode on | Out-Null

        Set-NaVolOption $vName convert_ucode on | Out-Null

    }

    # Set ASIS for new volume
    If ($x -eq "0") {

        If ($yesAsis -eq "1") {

            Get_Asis | Out-Null

            [string]$asisTime = "sun-sat@"

            $asisTime += $asisHours

            Enable-NaSis $vName | Out-Null

            Set-NaSis -Path $volPath -Schedule $asisTime | Out-Null

        }

    }

    # Set AutoGrow for new volume
    If ($x -eq "0") {Set-NaVolAutosize $vName -Enabled -MaximumSize $vSize2 -IncrementSize "20g" | Out-Null}

    # Add hidden CIFS share for new volume
    If ($x -eq "0") {Add-NaCifsShare $cifs $path | Out-Null}

    # If selected, add NFS exports to ESX hosts
    If ($x -eq "0") {

        $NFShost = Get-NaNetInterface | Where {$_.PrimaryAddresses -like "192.128.2*"} | Select PrimaryAddresses | ForEach {$_.PrimaryAddresses}

        If ($NFShost) {

            If ($ExpVC -eq "1") {

                If ($Irv -eq "1") {

                    $MyDC = "DC1"

                    ExportESX $MyDC $vName $path $NFShost | Out-Null

                }

                If ($HQ -eq "1") {

                    $MyDC = "DC2"

                    ExportESX $MyDC $vName $path $NFShost | Out-Null

                }

                If ($V -eq "1") {

                    $MyDC = "View"

                    ExportESX $MyDC $vName $path $NFShost | Out-Null

                }

            }

        }

        Else {NoNFS $MyFiler}

    }

    # Display message if volume was created or if script was aborted
    If ($x -eq "0") {Source_Vol_Created}

    #############
    ##DR VOLUME##
    #############
   

    # Run the Select_DRFiler Function to select a Filer to add the backup volume to
    If ($x -eq "1") {Select_DRFiler $DR_filers | Out-Null}

    # Connect to selected DRFiler and get Aggregate variables
    If ($x -eq "1") {

        $drfiler1 = Connect-NaController $MyDRFiler

        $dr_aggrs = Get-NaAggr

        $dr_aggr1 = Get-NaAggr | Select-Object Name, SizeAvailable, SizeTotal, BlockType | Sort SizeAvailable -Descending

    }

    # Run the Select_DRAggr Function to select the aggregate to create the DR volume on
    If ($x -eq "1") {

        Select_DRAggr $dr_aggr1 $dr_aggrs | Out-Null

        $DRblock = Get-NaAggr $MyDRAggr | Select BlockType | ForEach {$_.BlockType}

    }

    # Run the Vol_Details Function to get the volume name and size
    If ($x -eq "1") {DRVol_Details $vName $drVsize $DRblock | Out-Null}

    # Append collected volume size with "g"
    If ($x -eq "1") {

        [int]$DRvSize1 = $drVsize

        $DRvSize1 += 200

        [string]$DRvSize3 = $drVsize

        $DRvSize3 += "g"

        [string]$DRvSize2 = $DRvSize1

        $DRvSize2 += "g"

    }

    # Set path
    If ($x -eq "1") {

        $DRqPath = "/vol/"+$DRvName+"/"+$vName

        $DRvolPath = "/vol/"+$DRvName

    }

    # Set CIFS Share name
    If ($x -eq "1") {$DRcifs = $DRvName+"$"}

    # Create the volume on the selected aggregate
    If ($x -eq "1") {New-NaVol -Name $DRvName -Aggregate $MyDRAggr -Size $DRvSize3 -Confirm:$false | Out-Null}

    # Set SnapShot Reserve of new volume
    If ($x -eq "1") {

        $DRsnapRes = "0"

        Set-NaSnapshotReserve -Name $DRvName $DRsnapRes | Out-Null

    }

    # Set SnapShot Schedules for new volume
    If ($x -eq "1") {

        If ($snapW -or $snapN -or $snapH) {

            If ($DRsnapH -ne "0") {

                Get_DRSnapHours $sourceSnapH | Out-Null

                Set-NaSnapshotSchedule -Name $DRvName -Weeks $DRsnapW -Days $DRsnapN -Hours $DRsnapH -WhichHours $DRsnapHours | Out-Null

                }

            Else {Set-NaSnapshotSchedule -Name $DrvName -Weeks $DRsnapW -Days $DRsnapN -Hours $DRsnapH | Out-Null}

        }

        Else {NoSourceSnap}

    }

    # Turn off Access Time Update on new volume
    If ($x -eq "1") {Set-NaVolOption $DRvName no_atime_update on | Out-Null}

    # Set Fractional Reserve for new volume to 0
    If ($x -eq "1") {Set-NaVolOption $DRvName fractional_reserve 0 | Out-Null}

    # Set unicode options for new volume
    If ($x -eq "1") {

        Set-NaVolOption $DRvName create_ucode on | Out-Null

        Set-NaVolOption $DRvName convert_ucode on | Out-Null

    }

    # Set DR ASIS Options
    If ($x -eq "1") {

        If ($DRyesAsis -eq "1") {

            Get_DRAsis $sourceASISH | Out-Null

            [string]$DRasisTime = "sun-sat@"

            $DRasisTime += $DRasisHours

            Enable-NaSis $DRvName | Out-Null

            Set-NaSis -Path $DRvolPath -Schedule $DRasisTime | Out-Null

            If ($DRYesComp -eq "1") {Set-NaSis -Path $DRvolPath -Compression:$true | Out-Null}

            If ($DRYesInL -eq "1") {Set-NaSis -Path $DRvolPath -InlineCompression:$true | Out-Null}

        }

    }

    # Create Mirror
    If ($x -eq "1") {

        Get_MirrorHour $sourceSnapH | Out-Null

        Set-NaSnapmirrorSchedule -Source $filer1":"$path -Destination $drfiler1":"$DRqPath  -Minutes "0" -Hours $MirrorHour -DaysOfWeek "*" -DaysOfMonth "*" -Confirm:$false | Out-Null

        Invoke-NaSnapmirrorInitialize $drfiler1":"$DRqPath $filer1":"$path -Confirm:$false | Out-Null

    }

    # Display message if volume was created or if script was aborted
    If ($x -eq "1") {DR_Vol_Created}

    If ($x -eq "2") {Vol_Aborted}

}

Warning!

This NetApp Community is public and open website that is indexed by search engines such as Google. Participation in the NetApp Community is voluntary. All content posted on the NetApp Community is publicly viewable and available. This includes the rich text editor which is not encrypted for https.

In accordance to our Code of Conduct and Community Terms of Use DO NOT post or attach the following:

  • Software files (compressed or uncompressed)
  • Files that require an End User License Agreement (EULA)
  • Confidential information
  • Personal data you do not want publicly available
  • Another’s personally identifiable information
  • Copyrighted materials without the permission of the copyright owner

Files and content that do not abide by the Community Terms of Use or Code of Conduct will be removed. Continued non-compliance may result in NetApp Community account restrictions or termination.