HPE Community read-only access December 15, 2018
This is a maintenance upgrade. You will be able to read articles and posts, but not post or reply.
Hours:
Dec 15, 4:00 am to 10:00 am UTC
Dec 14, 10:00 pm CST to Dec 15, 4:00 am CST
Dec 14, 8:00 pm PST to Dec 15, 2:00 am PST
Server Management - Remote Server Management
cancel
Showing results for 
Search instead for 
Did you mean: 

Get-HPESAPhysicalDrive pipe to New-HPESALogicalDrive, syntax of Drive listing?

 
Highlighted
rookie1082
Advisor

Get-HPESAPhysicalDrive pipe to New-HPESALogicalDrive, syntax of Drive listing?

Quick question when trying to dynamically createa a RAID on a given server.  I want to get the list of physical drives, then in turn use that list (whatever it may be) to create a RAID from the list.  The code I have is as follows:

    $getslot = $connectsa | Get-HPESAControllerConfiguration
    $slot = $getslot.ControllerConfiguration.ControllerLocation
    $raidcard = $slot[0]
    $physicalDrive = $connectsa | Get-HPESAPhysicalDrive -ControllerLocation $raidcard

The above gets the drives connected to the HBA card that's in slot0. The output is:

1I:1:1

1I:1:2

1I:1:3

1I:1:4

1I:1:5

I then run:

   $driveslots = $physicalDrive.PhysicalDrive.location -join ',' 

 Which gives me:

"1I:1:1,1I:1:2,1I:1:3,1I:1:4,1I:1:5"

However, when I take my $Driveslots and try to use it in the New-HPESALogicalDrive, it fails:

    $ConnectSA | New-HPESALogicalDrive -ControllerLocation $raidcard -Raid Raid5 -DataDrive $driveslots

But the command fails saying it is not the correct syntax for the -DataDrive property.

I have to manually enter the phsycal drives in the following format:

    $ConnectSA | New-HPESALogicalDrive -ControllerLocation $raidcard -Raid Raid5 -DataDrive @(,@("1I:1:1","1I:1:2","1I:1:3","1I:1:4","1I:1:5"))


How do I have to manipulate the $physicaldrive variable to get something that the New-HPESALogicalDrive command will recognize in the -DataDrive property?  I want to be able to create a RAID no matter what bay/box the drives are in.

 I don't see any examples in the guides or get-help explanations that show you how to get a drive list and turn that into a logical drive with the cmdlets.  

 

1 REPLY
GZahidi
Advisor

Re: Get-HPESAPhysicalDrive pipe to New-HPESALogicalDrive, syntax of Drive listing?

Hi,

The syntax issue what you are facing is due to PowerShell wrong syntax. This is not related to the HPESmartArrayCmdlets module. 

The -DataDrive parameter of the Cmdlet New-HPESALogicalDrive accpets double dimension array, where as   

$physicalDrive.PhysicalDrive.location

return single dimension array  which leads to synatx error 

Use following snippet and pass it to the -DataDrive 

$dataDrive = @(,$physicalDrive.PhysicalDrive.Location)