How to Create Logical Drive on HPE DL580 G10 by PowerShell

I have published some posts about HPE Scripting Tools for PowerShell to automating physical server preparation and deployment services. The tools helping administrators to deploying services on HPE servers faster than normal ways, also there is no additional costs, just buy a PowerShell book!

The scripting tools provides PowerShell cmdlets for configuring BIOS, iLO, OA and Smart Array. The tools are available for download as free tools on HPE website.

Scripting Tools for Windows PowerShell

The smart array cmdlets are compatible with HPE Generation 10 and not all smart array adapters. Read the user guide document to find list of compatible smart array adapters.

The tools will help to configure smart array adapters on multiple servers very faster than normal ways or other automation tools. Of course, the tools is not comparable with HPE OneView.

Sample Script to Create Logical Drive with 2 Drive

The below sample will create two logical drives from 4 drives on multiple servers:

$Servers= "iLO IP1","iLO IP2"
$Credential=Get-Credential
ForEach ($Server in $Servers)
{
	$SAConnection= Connect-HPESA -IP $Server -Credential $Credential -DisableCertificateAuthentication
	$iLOConnection= Connect-HPEiLO -IP $Server -Credential $Credential -DisableCertificateAuthentication
	Start-Sleep -s 60
	$HostPower= Get-HPEiLoServerPower -Connection $iLOConnection
	If ($HostPower.Power -eq "Off")
	{
		Set-HPEiLoServerPower -Connection $iLOConnection -Power on
	}
	Else
	{
		Reset-HPEiLO -Connection $iLOConnection -Device Server -Confirm:$false
	}
	Start-Sleep -s 60
	$ControllerConfiguration= Get-HPESAConfigurationStatus -Connection $SAConnection
	$SlotNumber= $ControllerConfiguration.ConfigurationStatus.ControllerLocation
	$LogicalDrive= Get-HPESALogicalDrive -Connection $SAConnection
	$RemoveLogicalDrives= $LogicalDrive.LogicalDrive.VolumeUniqueIdentifier
	ForEach ($RemoveLogicalDrive in $RemoveLogicalDrives)
	{
		Remove-HPESALogicalDrive -Connection $SAConnection -ControllerLocation $SlotNumber -VolumeUniqueIdentifier $RemoveLogicalDrive
	}
	Start-Sleep -s 60
	$HostPower= Get-HPEiLoServerPower -Connection $iLOConnection
	If ($HostPower.Power -eq "Off")
	{
		Set-HPEiLoServerPower -Connection $iLOConnection -Power on
	}
	Else
	{
		Reset-HPEiLO -Connection $iLOConnection -Device Server -Confirm:$false
	}
	Start-Sleep -s 300
	$PhysicalDrives= Get-HPESAPhysicalDrive -Connection $SAConnection -ControllerLocation $SlotNumber
	$PhysicalDrivesSorted= $PhysicalDrives.PhysicalDrive.Location | Sort-Object
	$Drive0= $PhysicalDrivesSorted[0]
	$Drive1= $PhysicalDrivesSorted[1]
	$Drive2= $PhysicalDrivesSorted[2]
	$Drive3= $PhysicalDrivesSorted[3]
	New-HPESALogicalDrive -Connection $SAConnection -ControllerLocation $SlotNumber -LogicalDriveName LogicalDrive1 -Raid Raid1 -DataDrive @(,@("$Drive0","$Drive1")) -CapacityGiB -1
	New-HPESALogicalDrive -Connection $SAConnection -ControllerLocation $SlotNumber -LogicalDriveName LogicalDrive2 -Raid Raid1 -DataDrive @(,@("$Drive2","$Drive3")) -CapacityGiB -1
	$HostPower= Get-HPEiLoServerPower -Connection $iLOConnection
	If ($HostPower.Power -eq "Off")
	{
		Set-HPEiLoServerPower -Connection $iLOConnection -Power on
	}
	Else
	{
		Reset-HPEiLO -Connection $iLOConnection -Device Server -Confirm:$false
	}
	Disconnect-HPEiLO -Connection $iLOConnection
	Disconnect-HPESA -Connection $SAConnection
}

Same administrator account will be required on the servers and you can change “iLO IP” with your iLO IP addresses. Logical drives will be made as RAID 1. The script has been tested on HPE DL580 G10.

You need to install HPE iLO and HPE Smart Array cmdlets in order to run the above script.

For find more samples, you can check the below links:

GitHub HPE Servers PowerShell Samples

PowerShell Gallery

Further Reading

Configure NTP on iLO via HPE Scripting Tools for Windows PowerShell

HP Scripting Tools for Windows PowerShell

Davoud Teimouri

Davoud Teimouri is as a professional blogger, vExpert 2015/2016/2017/2018/2019, VCA, MCITP. This blog is started with simple posts and now, it has large following readers.

1 Response

  1. 31/07/2019

    […] How to Create Logical Drive on HPE DL580 G10 by PowerShell […]

Leave a Reply

Your email address will not be published. Required fields are marked *

Subscribe to our newsletter and join other subscribers

Holler Box