Solved

Need help with PowerCLI for loop

Posted on 2013-01-23
1
483 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Containers & Docker to Create a Powerful Team

Containers are an incredibly powerful technology that can provide you and/or your engineering team with huge productivity gains. Using containers, you can deploy, back up, replicate, and move apps and their dependencies quickly and easily.

Question has a verified solution.

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

My attempt to use PowerShell and other great resources found online to simplify the deployment of Office 365 ProPlus client components to any workstation that needs it, regardless of existing Office components that may be needing attention.
There are times when we need to generate a report on the inbox rules, where users have set up forwarding externally in their mailbox. In this article, I will be sharing a script I wrote to generate the report in CSV format.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

717 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