2,187
edits
m (→Daily ESX Up/Down Check: Added PowerShell_Credentials_Files template) |
(→ESX BIOS, NIC and HBA Driver Versions: Added PowerShell_Credentials_Files template, remove refs to Log (standard.ps1) and VC_List) |
||
Line 162: | Line 162: | ||
$start = Get-Date | $start = Get-Date | ||
$OutputFile = "ESXs.csv" | $OutputFile = "ESXs.csv" | ||
$UserFile = "User.fil" | $UserFile = "User.fil" | ||
$PassFile = "Pass.fil" # Encrypted file to store password in | $PassFile = "Pass.fil" # Encrypted file to store password in | ||
$Results = @() | $Results = @() | ||
# | $VCs = @() | ||
$VCs += "vCentreA" # Hostname of Virtual Center | |||
$VCs += "vCentreB" # Hostname of Virtual Center (repeat if you have more VC's, delete if you've only one) | |||
Start-Transcript -Path ESX-Inventory.log | Start-Transcript -Path ESX-Inventory.log | ||
Write-Host "Started script run at $start" | |||
# Function-U-like =================================================================================== | # Function-U-like =================================================================================== | ||
Line 183: | Line 183: | ||
# =================================================================================================== | # =================================================================================================== | ||
# Load password credential from encrypted file | # Load password credential from encrypted file | ||
Line 201: | Line 193: | ||
# Connect to VC | # Connect to VC | ||
try { | try { | ||
Log("Connecting to " + $ | Log("Connecting to " + $vc) | ||
$VCconn = Connect-VIServer -Server $ | $VCconn = Connect-VIServer -Server $vc -Credential $cred -errorAction "Stop" | ||
} catch [VMware.VimAutomation.ViCore.Types.V1.ErrorHandling.InvalidLogin] { | } catch [VMware.VimAutomation.ViCore.Types.V1.ErrorHandling.InvalidLogin] { | ||
Log("Unable to connect to vCentre, invalid logon error !!") | Log("Unable to connect to vCentre, invalid logon error !!") | ||
Line 213: | Line 205: | ||
# Get ESX objects | # Get ESX objects | ||
Log("Getting list of ESXs to check on " + ($ | Log("Getting list of ESXs to check on " + ($vc) + "...") | ||
$ESXs = Get-VMHost -Server $ | $ESXs = Get-VMHost -Server $vc | Sort -property Name | ||
Log("Got list of " + ($ESXs.Count) + " ESXs to check") | Log("Got list of " + ($ESXs.Count) + " ESXs to check") | ||
Line 226: | Line 218: | ||
# Get the basics | # Get the basics | ||
$row.VC = $ | $row.VC = $vc | ||
$row.Cluster = $ESX.Parent | $row.Cluster = $ESX.Parent | ||
$row.Name = $ESX.Name.Split(".")[0] | $row.Name = $ESX.Name.Split(".")[0] | ||
Line 285: | Line 277: | ||
</source> | </source> | ||
{{PowerShell_Credentials_Files}} | |||
== Daily ESX Up/Down Check == | == Daily ESX Up/Down Check == |