Hi,
May i know why datastore in the cluster datastore would not be listed from the cmdlet output?
How to combine these 2 cmdlet (get-datastore and get-datastorecluster) within a script to list all datastore?
Correct, it only lists datastores that belong to a datastorecluster.
If you want to see all datastores, you can do
Get-Datastore |
Select Name,@{N='DSC';E={
if($_.ParentFolderId -match 'StoragePod'){
Get-View -Id $_.ParentFolderId | select -ExpandProperty Name
}
}} | Export-Csv -Path .\report.csv -UseCulture -NoTypeInformation
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
You mean like this?
Get-DatastoreCluster -PipelineVariable dsc |
Get-Datastore |
Select Name,@{N='DSC';E={$dsc.Name}}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
oh, that is how we could combine it both. my bad :smileysilly:
Thanks!
-PipelineVariable parameter seems cannot be found on my powercli, maybe outdated version that i have yeah?
I am using ise to construct more than one liner script.
Get-DatastoreCluster : A parameter cannot be found that matches parameter name 'PipelineVariable'.
At line:2 char:22
+ Get-DatastoreCluster -PipelineVariable dsc |
+ ~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [Get-DatastoreCluster], ParameterBindingException
+ FullyQualifiedErrorId : NamedParameterNotFound,VMware.VimAutomation.ViCore.Cmdlets.Commands.GetDatastoreCluster
I suspect you might be using an older PowerShell version.
Can you check what $PSVersionTable shows?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
yup,i agree with you. for this server where i currently work on, it is older version than other one i usually work on.
Get-DatastoreCluster : A parameter cannot be found that matches parameter name 'PipelineVariable'.
At line:2 char:22
+ Get-DatastoreCluster -PipelineVariable dsc |
+ ~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [Get-DatastoreCluster], ParameterBindingException
+ FullyQualifiedErrorId : NamedParameterNotFound,VMware.VimAutomation.ViCore.Cmdlets.Commands.GetDatastoreCluster
i am going to update this now than later
Try like this
Get-DatastoreCluster |
ForEach-Object -Process {
$dsc = $_
Get-Datastore -RelatedObject $dsc |
Select Name,@{N='DSC';E={$dsc.Name}}
}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Yes, this works!
Only thing it thrown with this query at the end of line after showing all output, do you know why?
Name : KMBA_DS008_T1S
DSC : KMBA_CDS001
cmdlet Export-Csv at command pipeline position 1
Supply values for the following parameters:
InputObject:
Try like this
Get-DatastoreCluster |
ForEach-Object -Process {
$dsc = $_
Get-Datastore -RelatedObject $dsc |
Select Name,@{N='DSC';E={$dsc.Name}}
} | Export-Csv -Path .\report.csv -UseCulture -NoTypeInformation
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
LucD,
ok,thats it! i missed this ' | ' before making output sentence
But, what i found was the script didnt list other datastores that is not part of the datastore cluster.
Correct, it only lists datastores that belong to a datastorecluster.
If you want to see all datastores, you can do
Get-Datastore |
Select Name,@{N='DSC';E={
if($_.ParentFolderId -match 'StoragePod'){
Get-View -Id $_.ParentFolderId | select -ExpandProperty Name
}
}} | Export-Csv -Path .\report.csv -UseCulture -NoTypeInformation
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
mate, this works great!
Thank you for your help