1 Reply Latest reply: Apr 8, 2015 8:09 AM by Kelley Underwood RSS

    Scripting Drive and Volume Collection Creation with plink using variables

    Kelley Underwood Newbie
    Visibility: Open to anyone

      I'm working on a script combining PowerShell and remote SSH commands with plink that I someday hope will allow me to use a csv as input and then create an assortment of database and log volumes and matching volume colletions and then mount the volumes for an Exchange server. I am at the very beginning and trying to get the concepts working without the csv using variables. When I get this stage finished I'll move on. The problem I'm having is getting our Nimble system to create a volume using my variables. If I manually enter the correct info at the command prompt the volume is created fine. When I use Write-Host in my script to display the command before execution, it matches exactly with what works when manually entered but always results in an error: "ERROR: Failed to create volume. No such object." I have tracked it down to a problem creating a variable that included quotes. Below is some of my script. Clearly, I am not a coder. Can anyone help me understand was I need to modify to get the perfpolicy variables set?


      #Use plink to script the creation of Nimble Exchange volumes"


      #get array to add volumes and collections






      #Volume/Collection Name Variables






      $xd="`"Exchange 2010 data store`""

      $xl="`"Exchange log`""


      Write-Host $xd

      Write-Host $xl


      #Create a volume collection with appropriate properties and assign the new volumes to the collection using plink and SSH

      $plinkarrayoptions="$array -l $user -pw $pw"


      #Switching to Variables

      $remotecmd1="vol --create $srv-$volbase-DB$dbn --size $size --perfpolicy $xd --initiatorgrp $srv --multi_initiator no"

      Write-Host $remotecmd2

      $remotecmd2="vol --create $srv-$volbase-Log$dbn --size 102400 --perfpolicy $xl --initiatorgrp $srv --multi_initiator no"

      Write-Host $remotecmd3


      #Create Commands

      $command1=$plink+" "+$plinkarrayoptions+" "+$remotecmd1

      $command2=$plink+" "+$plinkarrayoptions+" "+$remotecmd2


      #Execute the Commands

      $msg=Invoke-Expression -command $command1

      $msg=Invoke-Expression -command $command2



      When I run this I get the following:

      "Exchange 2010 data store"

      "Exchange log"

      vol --create X1301-HCCA-DB2 --size 204800 --perfpolicy "Exchange 2010 data store" --initiatorgrp X1301 --multi_initiator no

      vol --create X1301-HCCA-Log2 --size 102400 --perfpolicy "Exchange log" --initiatorgrp X1301 --multi_initiator no

      ERROR: Failed to create volume. No such object.

      ERROR: Failed to create volume. No such object.


      If I copy and paste the vol --create lines into an SSH CLI the volumes are created. When the lines are passed to the array with plink I get the errors. It appears to me that the -perfpolicy value must be enclosed in double quotes and getting those to show as expected meant escaping a quote on each side of the variable. I've tried the volume creation using the Nimble PowerShell Module from Justin Rich and it works but not with the variables. Can anyone help me understand what needs to be changed to make this work?