Last active
December 26, 2020 09:37
-
-
Save DavoudTeimouri/a2b761f83d21cd5acbd2c847f274fc03 to your computer and use it in GitHub Desktop.
Create Logical Drive on HPE ProLiant G10
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $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 | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment