Skip to content

Instantly share code, notes, and snippets.

Function Backup-VMHost {
[CmdletBinding()]
Param(
[Parameter(Mandatory=$True)]
[string[]]$VMHost,
[Parameter(Mandatory=$True)]
[string]$FilePath
)
#Variable declaration
$vCenterIPorFQDN="192.168.243.172"
$vCenterUsername="Administrator@vsphere.local"
$vCenterPassword="vmware"
$destination = "C:\Users\Paolo\Desktop" #Location where to download support bundles
Write-Host "Connecting to vCenter" -foregroundcolor "magenta"
Connect-VIServer -Server $vCenterIPorFQDN -User $vCenterUsername -Password $vCenterPassword
$hosts = Get-VMHost #Retrieve all hosts from vCenter
#Variable declaration
$hosts=@("192.168.243.144","10.0.1.62") #ESXi hosts to download support bundles from
$username="root" #ESXi host username
$password="vmware" #ESXi host password
$destination = "C:\Users\Paolo\Desktop" #Location where to download support bundles
[System.Net.ServicePointManager]::ServerCertificateValidationCallback = {$true} #Ignore SSL certificate validation
foreach ($element in $hosts){
#Variable declaration
$vCenterIPorFQDN="192.168.243.172"
$vCenterUsername="Administrator@vsphere.local"
$vCenterPassword="vmware"
$OutputFile="C:\Inetpub\wwwroot\mywebsite\feed.xml" #Where you want to place generated report
Remove-Item $OutputFile #Delete files from previous runs
Write-Host "Connecting to vCenter" -foregroundcolor "magenta"