Quantcast
Channel: VMware Communities: Message List
Viewing all articles
Browse latest Browse all 219257

Re: Exporting RVtools report in CSV from Power Cli automation script

$
0
0

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


Viewing all articles
Browse latest Browse all 219257

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>