Solved

Need help with PowerCLI for loop

Posted on 2013-01-23
1
472 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
Comment Utility
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

This article will show, step by step, how to integrate R code into a R Sweave document
This article will help you understand what HashTables are and how to use them in PowerShell.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…

772 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

10 Experts available now in Live!

Get 1:1 Help Now