Hello,
I have written a powershell script to get the amount of free space avaliable in the datastores butthis is too high level
I need the information to be broken down as per the view of "Datastores" with the Virtual Centre
eg - my DataCentre folder look like
Teir 1
Datastores x -x-x-x-x-x-x
Teir 2
Datastores x-x-x-x-x-x-x-x
Teir 3
Datastores x-x-x-x-x-x-x-x
Can someone help please
Absolutely. The problem has to do with the way pipelining works and the references that you're trying to use in the output. There are a few ways to handle this, and I think this may do what you want.
Get-Datacenter | Foreach-Object { $dc=$_; $dc | Get-Datastore | Select-Object @{name="DC Name"; expression={$dc.name}},Name,FreeSpaceMB,CapacityMB}
It might help if you give us an example of what you want.
Based on the subject, you can do something like Get-Datacenter | Get-Datastore | {your code here} to walk through the datastores per datacenter and do whatever you need, but I don't think what you want to do it quite that easy
This is what I am doing so far :
this is just to show you what my top level view looks like ###
get-datacenter -name *
Name Id
-
--
DEV Datacenter-datacenter-1039
TIER 3 Datacenter-datacenter-155
TIER 4 Datacenter-datacenter-158
###########
This is what I thought would work ###
C:\> get-datacenter -name * |get-datastore
Name FreeSpaceMB CapacityMB
-
-
-
F_00165_T3_PAGE_002 28980 35584
F_00174_T3_PAGE_006 22858 30464
F_00114_T3_OS_001 146487 204544
F_00170_T3_OS_005 177228 204544
But as both of the view use "Name" I cannot format the table to show for example
TIER3 F_00165_T3_PAGE_002 28980 35584
TIER4 F_00175_T3_OS_001 146487 204544
Hope this explains a bit more
Have uploaded more info
Absolutely. The problem has to do with the way pipelining works and the references that you're trying to use in the output. There are a few ways to handle this, and I think this may do what you want.
Get-Datacenter | Foreach-Object { $dc=$_; $dc | Get-Datastore | Select-Object @{name="DC Name"; expression={$dc.name}},Name,FreeSpaceMB,CapacityMB}
Absolutely. The problem has to do with the way pipelining works and the references that you're trying to use in the output. There are a few ways to handle this, and I think this may do what you want.
Get-Datacenter | Foreach-Object { $dc=$_; $dc | Get-Datastore | Select-Object @{name="DC Name"; expression={$dc.name}},Name,FreeSpaceMB,CapacityMB}
Absolutely. The problem has to do with the way pipelining works and the references that you're trying to use in the output. There are a few ways to handle this, and I think this may do what you want.
Get-Datacenter | Foreach-Object { $dc=$_; $dc | Get-Datastore | Select-Object @{name="DC Name"; expression={$dc.name}},Name,FreeSpaceMB,CapacityMB}
That worked a treat
Here you go..
Get-Datacenter | % { $dc = $_ $dc | Get-Datastore | FT +-AutoSize+ @{Label="DataCenter";Expression= {$dc.Name}}, Name, FreeSpaceMB }
#Click Helpfull or Correct button if that helped