Operating System - Microsoft
cancel
Showing results for 
Search instead for 
Did you mean: 

Auto detect slot number "hpssacli.exe ctrl all show" by PowerShell

SOLVED
Go to solution
Simpat
Frequent Advisor

Auto detect slot number "hpssacli.exe ctrl all show" by PowerShell

Hi HP Folks,

On Linux, I can do simple one liner for auto find slot number :

hpssacli ctrl all show config | sed -n '/.*rray.*in Slot/{s/.*in Slot \([^ ]\{1,\}\).*/\1/;p;}'
1

Does anyone have some scripting tips to write PowerShell to detect Smart Array Controller Slot Number?

Invoke-Expression "C:\Progra~1\HP\hpssacli\bin\hpssacli.exe ctrl all show"
# or 
cmd /c "C:\Progra~1\HP\hpssacli\bin\hpssacli.exe ctrl all show"
# output of Smart Array model and Slot number can be vary, something like this.
Smart Array P440ar in Slot 0 (Embedded)   (sn: abcdefghijklmnop)
Smart Array P420i in Slot 1 (Embedded)    (sn: abcdefghijklmnop)
Smart Array P420i in Slot 2 (Embedded) 

Can someone tell me how you do on Windows PowerShell?

|------------- ( ^__^ )--------------|
I'm Happy when You're Happy
3 REPLIES
Simpat
Frequent Advisor
Solution

Re: Auto detect slot number "hpssacli.exe ctrl all show" by PowerShell

I just that is very simple by using .split() 

$Ctrl = ((iex "C:\Progra~1\HP\hpssacli\bin\hpssacli.exe ctrl all show").split())

It will turn all output into array in my $Ctrl variable:

> echo $Ctrl

Smart
Array
P420i
in
Slot
0
(Embedded)



(sn:
001438027D4B390)

So now I can use index [3] for Smart Array model and index [6] for Controller Slot number:

$CtrlModel = $Ctrl[3]
$CtrlSlot = $Ctrl[6]
echo $CtrlModel
P420i echo $CtrlSlot
0

Hope this can help someone create scripting.

|------------- ( ^__^ )--------------|
I'm Happy when You're Happy
Simpat
Frequent Advisor

Re: Auto detect slot number "hpssacli.exe ctrl all show" by PowerShell

 

 

cmd /c "C:\Progra~1\HP\hpssacli\bin\hpssacli.exe ctrl all show config"

### Here I use to create new volume from raw SSD in bay3,4 as RAID1
cmd /c "C:\Progra~1\HP\hpssacli\bin\hpssacli.exe ctrl slot=$CtrlSlot create type=ld drives=1I:1:3,1I:1:4 raid=1 forced"

### I want to disable SSD SmartPath because I found it found it slower
cmd /c "C:\Progra~1\HP\hpssacli\bin\hpssacli.exe ctrl slot=$CtrlSlot array B show"
cmd /c "C:\Progra~1\HP\hpssacli\bin\hpssacli.exe ctrl slot=$CtrlSlot array B modify ssdsmartpath=disable"

### I need to re-enabled Caching  after disabled SSD Spart Path
cmd /c "C:\Progra~1\HP\hpssacli\bin\hpssacli.exe ctrl slot=$CtrlSlot logicaldrive 2 show"
cmd /c "C:\Progra~1\HP\hpssacli\bin\hpssacli.exe ctrl slot=$CtrlSlot logicaldrive 2 modify caching=enable"

### Delete array B if you want to re-create
cmd /c "C:\Progra~1\HP\hpssacli\bin\hpssacli.exe ctrl slot=$CtrlSlot array B delete forced"

### Rescan Disks on OS Level ###
"Rescan","List Disk","List Vol" | DiskPart
Please wait while DiskPart scans your configuration...

DiskPart has finished scanning your configuration.

DISKPART>
  Disk ###  Status         Size     Free     Dyn  Gpt
  --------  -------------  -------  -------  ---  ---
  Disk 0    Online          838 GB      0 B        *
  Disk 1    Offline        1788 GB  1788 GB

DISKPART>
  Volume ###  Ltr  Label        Fs     Type        Size     Status     Info
  ----------  ---  -----------  -----  ----------  -------  ---------  --------
  Volume 0     C   Windows      NTFS   Partition    203 GB  Healthy    Boot
  Volume 1     D   Data         NTFS   Partition    634 GB  Healthy
  Volume 2                      NTFS   Partition    350 MB  Healthy    Hidden
  Volume 3                      FAT32  Partition    100 MB  Healthy    System

PS C:\> Get-Disk

Number Friendly Name                            OperationalStatus                    Total Size Partition Style
------ -------------                            -----------------                    ---------- ---------------
0      HP LOGICAL VOLUME SCSI Disk Device       Online                                838.33 GB GPT
1      HP LOGICAL VOLUME SCSI Disk Device       Offline                                 1.75 TB RAW
|------------- ( ^__^ )--------------|
I'm Happy when You're Happy
Simpat
Frequent Advisor

Re: Auto detect slot number "hpssacli.exe ctrl all show" by PowerShell


PS C:\> Get-Disk | Where partitionstyle -eq 'raw' | Initialize-Disk -PartitionStyle GPT -PassThru

Number Friendly Name                            OperationalStatus                    Total Size Partition Style
------ -------------                            -----------------                    ---------- ---------------
1      HP LOGICAL VOLUME SCSI Disk Device       Offline                                 1.75 TB RAW


PS C:\> New-Partition -DiskNumber 1 -UseMaximumSize -DriveLetter E | Get-Partition


   Disk Number: 1

PartitionNumber  DriveLetter Offset                                        Size Type
---------------  ----------- ------                                        ---- ----
2                E           135266304                                  1.75 TB Basic


PS C:\> Get-Disk | Where Number -eq '1'

Number Friendly Name                            OperationalStatus                    Total Size Partition Style
------ -------------                            -----------------                    ---------- ---------------
1      HP LOGICAL VOLUME SCSI Disk Device       Online                                  1.75 TB GPT


PS C:\> Format-Volume -DriveLetter E -FileSystem NTFS -NewFileSystemLabel VMData -Confirm:$false

DriveLetter       FileSystemLabel  FileSystem       DriveType        HealthStatus        SizeRemaining             Size
-----------       ---------------  ----------       ---------        ------------        -------------             ----
E                 VMData           NTFS             Fixed            Healthy                   1.75 TB          1.75 TB


PS C:\> Get-Partition


   Disk Number: 0

PartitionNumber  DriveLetter Offset                                        Size Type
---------------  ----------- ------                                        ---- ----
1                            1048576                                     350 MB Recovery
2                            368050176                                   100 MB System
3                            472907776                                   128 MB Reserved
4                C           607125504                                203.07 GB Basic
5                D           218648018944                              634.7 GB Basic


   Disk Number: 1

PartitionNumber  DriveLetter Offset                                        Size Type
---------------  ----------- ------                                        ---- ----
1                            17408                                       128 MB Reserved
2                E           135266304                                  1.75 TB Basic
|------------- ( ^__^ )--------------|
I'm Happy when You're Happy