Server Management - Remote Server Management
1752447 Members
6470 Online
108788 Solutions
New Discussion

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

 
SOLVED
Go to solution
rookie1082
Frequent 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 1
GZahidi
Advisor
Solution

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) 

 


I am a HPE Employee