VMware Cloud Community
SureshKumarMuth
Commander
Commander
Jump to solution

script to fetch datastore details -- vsphere replication

Hi All,

Can anyone help me with a script to get following information

We have multiple virtual machines configured under vsphere replication. We need the datastore information of all the vmdk on both primary and replicated site (vmdk's datastore of the replicated VM at the DR site)

Please help.

LucD

Regards,
Suresh
https://vconnectit.wordpress.com/
Reply
0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

Try like this.

I added a sleep cmdlet after each datastore

$report = foreach($ds in Get-Datastore){

    New-PSDrive -Name DS -Location $ds -PSProvider VimDatastore -Root '\' | Out-Null

    Get-ChildItem -Path DS:

    Remove-PSDrive -Name DS

    sleep 30

}

$report | Export-Csv .\report.csv -NoTypeInformation -UseCulture


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

View solution in original post

Reply
0 Kudos
9 Replies
LucD
Leadership
Leadership
Jump to solution

Are we talking of the VMware vSphere Replication appliance or SRM?


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos
SureshKumarMuth
Commander
Commander
Jump to solution

It is vSphere replication appliance.

Regards,
Suresh
https://vconnectit.wordpress.com/
Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

I'm afraid there isn't really a way of ding that with PowerCLI.

See also Re: API Guide for vSphere Replication Appliance     6.0.0.1 Build 2718739


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

SureshKumarMuth
Commander
Commander
Jump to solution

Thanks LucD

Regards,
Suresh
https://vconnectit.wordpress.com/
Reply
0 Kudos
SureshKumarMuth
Commander
Commander
Jump to solution

LucD

Is there any way to list out the directories under a Datastore.

In order to accomplish the above task, I am planning for this following task. Please suggest

Our secondary site has identical copy of replicated VM in a directory with same name as primary VM. So in case if we list our all the directories from all datastores and export to excel, then we can compare where the replicated data resides.

For that I am looking for a script to list out the folders in datastores.

Regards,
Suresh
https://vconnectit.wordpress.com/
Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

You can do this

$dsName = 'MyDS'

$ds = Get-Datastore -Name $dsName

New-PSDrive -Name DS -Location $ds -PSProvider VimDatastore -Root '\' | Out-Null

Get-ChildItem -Path DS:

Remove-PSDrive -Name DS


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos
SureshKumarMuth
Commander
Commander
Jump to solution

Thanks @LucD, it worked like charm. I tested in my lab.

Little customization needed for reporting purpose

Can you please check if following tasks are possible

1. Now we are giving DS name instead of MyDS, I want this script to fetch all the folders from all datastores from the VC.

2. Output should be in an excel/csv format with columns DS name / foldername / foldersize / lun id (not sure if it populates all in case of more than one extent)

since it is going to give more load on VC, I am bit worried if it cause any issue to vpxd process when we run it on prod machines, can we run this in a batch mode to avoid huge load on VC or adding sleep times in between to make the process cool down. I use to give sleep function in C programming but not sure about powercli.

Thank you very much for your help so far.

Regards,

Suresh

Regards,
Suresh
https://vconnectit.wordpress.com/
Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

Try like this.

I added a sleep cmdlet after each datastore

$report = foreach($ds in Get-Datastore){

    New-PSDrive -Name DS -Location $ds -PSProvider VimDatastore -Root '\' | Out-Null

    Get-ChildItem -Path DS:

    Remove-PSDrive -Name DS

    sleep 30

}

$report | Export-Csv .\report.csv -NoTypeInformation -UseCulture


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos
SureshKumarMuth
Commander
Commander
Jump to solution

Thank you LucD for your help.

Regards,
Suresh
https://vconnectit.wordpress.com/
Reply
0 Kudos