0

I am using following PowerShlell to get the list of available physical disk.

$disks=((Get-PhysicalDisk -CanPool $true)|Select-Object PhysicalLocation) 

The output of above code is as shown below

Integrated : Adapter 3 : Port 0 : Target 0 : LUN 7

Integrated : Adapter 3 : Port 0 : Target 0 : LUN 0

Integrated : Adapter 3 : Port 0 : Target 0 : LUN 5

Integrated : Adapter 3 : Port 0 : Target 0 : LUN 2

Integrated : Adapter 3 : Port 0 : Target 0 : LUN 6

Integrated : Adapter 3 : Port 0 : Target 0 : LUN 4

Integrated : Adapter 3 : Port 0 : Target 0 : LUN 1

Integrated : Adapter 3 : Port 0 : Target 0 : LUN 3

Integrated : Adapter 3 : Port 0 : Target 0 : LUN 8

However, form the collection I want to select a set of LUN e.g LUN from 5 to 8 to create a storage pool using

New-StoragePool

Thanks

1 Answer 1

1

You don't need to put the expressions in parenthesis. You can try something like below. This regex will help you to get the desired result.

Get-PhysicalDisk -CanPool $true | Foreach-Object -Process {
   $_.PhysicalLocation | Select-String -Pattern 'LUN.[5-8]'
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.