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
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.
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
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
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
Can you include the script you are using ?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
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
I think that line should be
$Items = Get-ChildItem "$BasePath\$server"
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
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
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
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
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
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
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 ?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
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.
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.
The different options (userid/password or passthroughauthentication) are described in the RVTools documentation in the Commandline section
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Given link is broken. Any idea where else I can get the script to export rvtools report from multiple VCs remotely ?
Find the script here.
Find the RVTools documentation here.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Thank you, it worked.
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 ?