alanrenouf / vCheck-vSphere

vCheck Daily Report for vSphere
MIT License
733 stars 325 forks source link

How to schedule vCheck for multiple vCenters in single job? #752

Open Srikanth1455 opened 1 year ago

Srikanth1455 commented 1 year ago
  1. How to run vCheck on multiple vCenters
  2. How to merge all vCenters output in single HTML file?
junk430 commented 2 months ago

Might not be everything you are looking for but we've got 4-5 locations and someone wrote this script to search sub dir's for vCheck.ps1 and run it. So put a vCheck_USA, vCheck_France directory under the script.

$strSMTP = "eemail.home.now"
$strFrom = "yourcomputer@home.now" $arTo = @("me@home.now") $strSubject = "vCheck Reports" $strMessage = "See attached vCheck Reports"

$ScriptPath = (Split-Path ((Get-Variable MyInvocation).Value).MyCommand.Path)

$ScriptInstances = Get-ChildItem -Path $ScriptPath -Filter vcheck.ps1 -Recurse Remove-Item -Path "$ScriptPath\Output*" -Recurse Foreach ($instance in $ScriptInstances) { $command = $instance.FullName + " –OutputPath $ScriptPath\Output" Invoke-Expression -Command $command }

$outputHTM = Get-ChildItem -Path "$ScriptPath\OutPut" -Filter *.htm -Recurse $arAttachments = @() Foreach ($htm in $outputHTM) { $arTemp = $htm.BaseName.Split(".") $newFileName = $arTemp[0] + ".htm" Rename-Item $htm.FullName $newfileName $newfileName = $htm.DirectoryName + "\" + $newFileName $arAttachments += $newFileName }

send-mailmessage -SmtpServer $strSMTP -From $strFrom -To $arTo -Subject $strSubject -Body $strMessage -Attachments $arAttachments

Clean up

Remove-Item -Path "$ScriptPath\Output*" -Recurse