Automation

 View Only
  • 1.  script to fetch datastore details -- vsphere replication

    Posted Aug 15, 2017 06:32 PM

    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



  • 2.  RE: script to fetch datastore details -- vsphere replication

    Posted Aug 15, 2017 08:24 PM

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



  • 3.  RE: script to fetch datastore details -- vsphere replication

    Posted Aug 16, 2017 11:16 AM

    It is vSphere replication appliance.



  • 4.  RE: script to fetch datastore details -- vsphere replication

    Posted Aug 16, 2017 11:56 AM

    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



  • 5.  RE: script to fetch datastore details -- vsphere replication

    Posted Aug 16, 2017 12:08 PM

    Thanks LucD



  • 6.  RE: script to fetch datastore details -- vsphere replication

    Posted Aug 25, 2017 06:55 PM

    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.



  • 7.  RE: script to fetch datastore details -- vsphere replication

    Posted Aug 25, 2017 09:43 PM

    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



  • 8.  RE: script to fetch datastore details -- vsphere replication

    Posted Aug 29, 2017 10:58 AM

    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



  • 9.  RE: script to fetch datastore details -- vsphere replication
    Best Answer

    Posted Aug 29, 2017 04:03 PM

    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



  • 10.  RE: script to fetch datastore details -- vsphere replication

    Posted Sep 01, 2017 12:44 PM

    Thank you LucD for your help.