PowerCLI

 View Only
Expand all | Collapse all

Exporting RVtools report in CSV from Power Cli automation script

  • 1.  Exporting RVtools report in CSV from Power Cli automation script

    Posted Sep 25, 2015 08:18 PM

    Hi all,

    Can we Export the RV tools Report through Power Cli script.

    I could get the details from RV tools per VC , but i want to get details of RVtools report of multiple VCs in sheet

    from Power Cli script.

    E.g.

    RVTools.exe -passthroughAuth -s VM01.ze.zk.com -c ExportAll2xls -d %EXPORTDESTINATION% -f VM01_%RUNDATETIME%.xls

    START /WAIT RVToolsSendMail.bat smtpek.us.zk.com 25 VMwareMEmailNotifications@ZK.com VMSV49_RVTooolsExport@ZK.com %LOG_FILE_ARCHIVE% >> %LOG_FILE_2% 2>&1

    Thanks in advance.

    vmk2014



  • 2.  RE: Exporting RVtools report in CSV from Power Cli automation script

    Posted Sep 25, 2015 08:22 PM

    All i want a scheduled task that would launch it regularly, exports the results with the date in the export file-name. The command line parameters are well documented and described in the documentation.



  • 3.  RE: Exporting RVtools report in CSV from Power Cli automation script

    Posted Sep 28, 2015 12:00 PM

    There is a sample script to use RVTools over multiple vCenters in https://github.com/Sneddo/Powershell/blob/master/VMware/RVToolsExport.ps1

    To run a PS script as a scheduled task see Calling PowerShell scripts from Task Scheduler



  • 4.  RE: Exporting RVtools report in CSV from Power Cli automation script

    Posted Sep 28, 2015 03:53 PM

    LucD,

      First of all, i would like to say thanks to you. Could you,please help me to correct the below errors,though i am getting the output but not sure whether its complete report or not.

    PowerCLI C:\temp> .\RVTools_Export.ps1

    Get-ChildItem : Cannot find path 'C:\vmserv1' because it does not exist.

    At C:\temp\RVTools_Export.ps1:37 char:13

    +    $Items = Get-ChildItem "$path\$server"

    +             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

        + CategoryInfo          : ObjectNotFound: (C:\vmserv1:String) [Get-C

       hildItem], ItemNotFoundException

        + FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.GetCh

       ildItemCommand

    thanks

    vm2014



  • 5.  RE: Exporting RVtools report in CSV from Power Cli automation script

    Posted Sep 28, 2015 05:55 PM

    Can you include the script you are using ?



  • 6.  RE: Exporting RVtools report in CSV from Power Cli automation script

    Posted Sep 28, 2015 06:45 PM

    LucD,

      Please find the script below which i am running.

    (

       $Servers = @("SWRSVC100"),

       $BasePath = "C:\Scripts\Powershell\RVToolsExport\Archive",

       $OldFileDays = 30

    )

    $Date = (Get-Date -f "yyyyMMdd")

    foreach ($Server in $Servers)

    {

       # Create Directory

       New-Item -Path "$BasePath\$Server\$Date" -ItemType Directory -ErrorAction SilentlyContinue | Out-Null

       # Run Export

       . "C:\Program Files (x86)\RobWare\RVTools\RVTools.exe" -passthroughAuth -s "$Server.us.kz.com" -c ExportAll2csv -d "$BasePath\$Server\$Date"

       # Cleanup old files

       $Items = Get-ChildItem "$path\$server"

       foreach ($item in $items)

       {

          $itemDate = ("{0}/{1}/{2}" -f $item.name.Substring(6,2),$item.name.Substring(4,2),$item.name.Substring(0,4))

         

          if ((((Get-date).AddDays(-$OldFileDays))-(Get-Date($itemDate))).Days -gt 0)

          {

             $item | Remove-Item -Recurse

          }

       }

    }

    thanks

    vm2014



  • 7.  RE: Exporting RVtools report in CSV from Power Cli automation script

    Posted Sep 28, 2015 06:52 PM

    I think that line should be

       $Items = Get-ChildItem "$BasePath\$server"



  • 8.  RE: Exporting RVtools report in CSV from Power Cli automation script

    Posted Sep 28, 2015 07:24 PM

    Thanks LucD. Its fixed the issue, but now its throws different error

    PowerCLI C:\temp> .\RVTools_Export.ps1

    Get-Date : Cannot bind parameter 'Date'. Cannot convert value "28/09/2015" to

    type "System.DateTime". Error: "String was not recognized as a valid DateTime."

    At C:\temp\RVTools_Export.ps1:42 char:57

    +       if ((((Get-date).AddDays(-$OldFileDays))-(Get-Date($itemDate))).Days

    -gt 0 ...

    +                                                         ~~~~~~~~~~~

        + CategoryInfo          : InvalidArgument: (:) [Get-Date], ParameterBindin

       gException

        + FullyQualifiedErrorId : CannotConvertArgumentNoMessage,Microsoft.PowerSh

       ell.Commands.GetDateCommand

    thanks

    vm2014



  • 9.  RE: Exporting RVtools report in CSV from Power Cli automation script

    Posted Sep 29, 2015 05:01 AM

    This is most probably related to the locale you have in use on your station.

    Could be that your station expects in the format MM-dd-yyyy

    You can check which format is accepted by for example doing

    Get-Culture | select -ExpandProperty DateTimeFormat



  • 10.  RE: Exporting RVtools report in CSV from Power Cli automation script

    Posted Sep 29, 2015 03:58 PM

    LucD,

      Thanks. The timing will be in Central time, but its weird that even after fixing this error, a new error throws every time. But out put is getting generated.

    PowerCLI C:\temp> .\RVTools_Export.ps1

    Get-ChildItem : Cannot find path 'C:\VSXXYwrv100' because it does not exist.

    At C:\temp\RVTools_Export.ps1:37 char:13

    +    $Items = Get-ChildItem "$path\$server"

    +             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

        + CategoryInfo          : ObjectNotFound: (C:\usphicwsrv020:String) [Get-C

       hildItem], ItemNotFoundException

        + FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.GetCh

       ildItemCommand

    I changed  to  $Items = Get-ChildItem "$BasePath\$server" (as suggested above)

    Get-Date : Cannot bind parameter 'Date'. Cannot convert value "15/20/0929" to

    type "System.DateTime". Error: "String was not recognized as a valid DateTime."

    At C:\temp\RVTools_Export.ps1:42 char:57

    +       if ((((Get-date).AddDays(-$OldFileDays))-(Get-Date($itemDate))).Days

    -gt 0 ...

    +                                                         ~~~~~~~~~~~

        + CategoryInfo          : InvalidArgument: (:) [Get-Date], ParameterBindin

       gException

        + FullyQualifiedErrorId : CannotConvertArgumentNoMessage,Microsoft.PowerSh

       ell.Commands.GetDateCommand

    Get-Date : Cannot bind parameter 'Date'. Cannot convert value "28/09/2015" to

    type "System.DateTime". Error: "String was not recognized as a valid DateTime."

    At C:\temp\RVTools_Export.ps1:42 char:57

    +       if ((((Get-date).AddDays(-$OldFileDays))-(Get-Date($itemDate))).Days

    -gt 0 ...

    +                                                         ~~~~~~~~~~~

        + CategoryInfo          : InvalidArgument: (:) [Get-Date], ParameterBindin

       gException

        + FullyQualifiedErrorId : CannotConvertArgumentNoMessage,Microsoft.PowerSh

       ell.Commands.GetDateCommand

    thanks

    vm2014



  • 11.  RE: Exporting RVtools report in CSV from Power Cli automation script

    Posted Sep 30, 2015 08:39 PM

    Did you got the chance to see why its throwing the below error while running the script, but it generates the output in csv.

    Thanks in advance !!

    vm2014



  • 12.  RE: Exporting RVtools report in CSV from Power Cli automation script

    Posted Oct 01, 2015 05:06 AM

    There is nothing new to say, the $path variable is not initialised, that should be $basepath.

    The error line doesn't correspond with the line in the error message, perhaps attach the current version of the script you are running.

    Your locale doesn't accept that specific date format.

    What does Get-Culture show ?



  • 13.  RE: Exporting RVtools report in CSV from Power Cli automation script

    Posted Oct 02, 2015 04:13 PM

    LucD,

        Please find the output for Get-Culture. Also, i have attached the current version of the script, which i am running.

    PowerCLI C:\temp> Get-Culture

    LCID             Name             DisplayName

    ----             ----             -----------

    1033             en-US            English (United States)

    thanks

    vm2014



  • 14.  RE: Exporting RVtools report in CSV from Power Cli automation script

    Posted Sep 20, 2016 04:58 PM

    I fixed this issue for myself by editing line 39 to the following.  Note that the only change is "{0}/{1}/{2}" to "{1}/{0}/{2}"

    $itemDate = ("{1}/{0}/{2}" -f $item.name.Substring(6,2),$item.name.Substring(4,2),$item.name.Substring(0,4))

    Hope this helps.



  • 15.  RE: Exporting RVtools report in CSV from Power Cli automation script

    Posted Mar 23, 2017 02:19 AM

    How does user authentication work when using this method? I ran it and it brought up an error about username and password and also the GUI login box.



  • 16.  RE: Exporting RVtools report in CSV from Power Cli automation script

    Posted Mar 23, 2017 07:55 AM

    The different options (userid/password or passthroughauthentication) are described in the RVTools documentation in the Commandline section



  • 17.  RE: Exporting RVtools report in CSV from Power Cli automation script

    Posted Apr 02, 2022 11:59 AM

    i did configured the script & were working till 2-3 years but suddenly stoped working.

    command executed but no xls generates. can you please suggest ?



  • 18.  RE: Exporting RVtools report in CSV from Power Cli automation script

    Posted Dec 14, 2018 11:02 AM

    Given link is broken. Any idea where else I can get the script to export rvtools report from multiple VCs remotely ?



  • 19.  RE: Exporting RVtools report in CSV from Power Cli automation script

    Posted Dec 14, 2018 11:08 AM

    Find the script here.

    Find the RVTools documentation here.



  • 20.  RE: Exporting RVtools report in CSV from Power Cli automation script

    Posted Jan 10, 2019 02:55 PM

    Thank you, it worked.



  • 21.  RE: Exporting RVtools report in CSV from Power Cli automation script

    Posted Feb 25, 2019 03:50 PM

    Hi,

    I have a scenario that I need only the following tabs from rvtools,

    vdisk

    vinfo

    vPartition

    from 3 vcenter servers

    I passed the vCenter servers to $servers variable and created a script like this

    $Date = (Get-Date -f "yyyyMMdd")

    #$Date = (Get-Date -Format )

    foreach ($Server in $Servers)

    {

      # Create Directory

       New-Item -Path "$BasePath\$Server\$Date" -ItemType Directory -ErrorAction SilentlyContinue | Out-Null

       # Run Export

      . "C:\Program Files (x86)\RobWare\RVTools\RVTools.exe" -passthroughAuth -s $Server -c Exportvdisk2csv -d $BasePath\$date -f $Server+vdisk+$date.csv

      . "C:\Program Files (x86)\RobWare\RVTools\RVTools.exe" -passthroughAuth -s $Server -c ExportvInfo2csv -d $BasePath\$date -f $Server+vInfo+$date.csv

       . "C:\Program Files (x86)\RobWare\RVTools\RVTools.exe" -passthroughAuth -s $Server -c ExportvPartition2csv -d $BasePath\$date -f $Server+vPartition+$date.csv

    }

    If I run this, I can see each line of the export  creates a new rvtools process thread  and when it comes to multiple vCenter servers, it eats up more resources and sometimes the rvtools goes to unresponsive state ? Is it possible to customize the script that in single rvtools instance to vCenter , I need to capture only the data from  three tabs .

    Also at the end , using this script 9 files will be created (3 files (each VC)x 3 vCenter servers), I have to consolidate the 3 vdisk file in to one vdisk file , like wise vinfo and vpartition file should also be consolidated.

    Can you please help me ?



  • 22.  RE: Exporting RVtools report in CSV from Power Cli automation script

    Posted Feb 25, 2019 04:20 PM

    In the same document I pointed to earlier, there is a RVToolsMergeExcelFiles.ps1 script that is provided to merge multiple XLSX files.

    If you want to combine multiple tabs in 1 call, you will have to contact Rob I'm afraid.



  • 23.  RE: Exporting RVtools report in CSV from Power Cli automation script

    Posted Feb 25, 2019 04:53 PM

    Thanks