Solved

Need help with PowerCLI for loop

Posted on 2013-01-23
1
474 Views
Last Modified: 2013-01-24
I am trying to get a for loop going that just gives the CanonicalName option from the output below... what do I need to do to just get that field?

foreach ($LUN in $DS) { Write-Output $LUN ; get-cluster "VDI" | Get-VMHost | Get-Datastore $LUN |
Get-ScsiLun }
alasahds002_003EX

CanonicalN ConsoleDeviceName              LunType         CapacityGB MultipathPolicy
ame
---------- -----------------              -------         ---------- ---------------
naa.600... /vmfs/devices/disks/naa.600... disk             1,072.000 Fixed
naa.600... /vmfs/devices/disks/naa.600... disk             1,072.000 Fixed
naa.600... /vmfs/devices/disks/naa.600... disk             1,072.000 Fixed
naa.600... /vmfs/devices/disks/naa.600... disk             1,072.000 Fixed

Open in new window

0
Comment
Question by:Thaidog
1 Comment
 
LVL 40

Accepted Solution

by:
Subsun earned 500 total points
ID: 38811638
You can select CanonicalName  at the end of the pipeline.. For example..
foreach ($LUN in $DS) { Write-Output $LUN ; get-cluster "VDI" | Get-VMHost | Get-Datastore $LUN | Get-ScsiLun | Select CanonicalName }

Open in new window

Is that what you looking for?
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Utilizing an array to gracefully append to a list of EmailAddresses
I thought I'd write this up for anyone who has a request to create an anonymous whistle-blower-type submission form created using SharePoint 2010 (this would probably work the same for 2013). It's not 100% fool-proof but it's as close as you can get…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

914 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now