• Skip to primary navigation
  • Skip to content

jdgreen.io

The personal blog of James Green

  • Home
  • Technology
    • Announcements
    • Industry
    • Reviews/Guides
    • Tech Field Day
    • Interviews
  • Health
    • Food
    • Biohacking
    • Fitness
  • Faith
  • Book Notes
    • Business Books
    • Faith Books
    • Health Books
    • Technology Books
  • About
  • Show Search
Hide Search

powercli

PowerCLI – Configure Syslog for All Hosts

James Green · Aug 10, 2015 ·

Here’s a quick bit of PowerCLI to configure syslog server on all hosts, place each hosts logs in a unique directory, and then enable the firewall exception to allow it to be used. This will do every host in the vCenter you’re connected to. I highly recommend that anyone managing a vSphere environment set up a syslog destination for ESXi. There’s nothing more frustrating than attempting root-cause analysis on a failure when logs aren’t persistent and in a central location.

Cheers!

[code language=”ps”] #Get all ESXi hosts
$hosts = Get-VMHost

#Update Syslog configuration
$hosts | Set-VMHostAdvancedConfiguration Syslog.global.logHost -Value 0.0.0.0
$hosts | Set-VMHostAdvancedConfiguration Syslog.global.logDirUnique -Value True

#Enable firewall exception
$hosts | Get-VMHostFirewallException | where {$_.Name.StartsWith(‘syslog’)} |
Set-VMHostFirewallException -Enabled $true
[/code]

The VirtAdmin SSH Tool for vSphere Clusters

James Green · Mar 20, 2014 ·

A while back, I added this post with some PowerCLI one-liners to turn on and off SSH across a whole cluster. I got irritated with always having to browse out here and copy the script, so I created a reusable tool with a GUI to do this little task!

The VirtAdmin SSH Tool for vSphere Clusters

The tool uses Powershell to draw Windows forms. I generated the GUI using Sapien Technologies’ PrimalForms CE. The tool did most of the leg work for me. Once the form was generated, I just added the logic and made the buttons do things! Let me explain a few details…

[Read more…] about The VirtAdmin SSH Tool for vSphere Clusters

PowerCLI – Rolling Reboot vSphere Cluster

James Green · Mar 17, 2014 ·

From time to time, I need to reboot all hosts in a cluster. If it’s not for an Update Manager operation, I need a way to run through the whole cluster (not manually). I need to place one host in maintenance mode, reboot it, exit maintenance mode, and move to the next one. PowerCLI to the rescue, as usual! Feel free to modify or share! And of course, use at your own risk 🙂

PowerCLI script

[code language=”powershell”] # Check to make sure both arguments exist
if ($args.count -ne 2) {
Write-Host "Usage: reboot-vmcluster.ps1 <vCenter> <HostList.txt>"
exit
}

# Set vCenter and Cluster name from Arg
$vCenterServer = $args[0] $VIHosts = $args[1]

# Connect to vCenter
Connect-VIServer -Server $vCenterServer | Out-Null

# Get VMware Server Object based on name passed as arg
$ESXiServers = Get-Content $VIHosts | %{Get-VMHost $_}

# Reboot ESXi Server Function
Function RebootESXiServer ($CurrentServer) {
# Get VI-Server name
$ServerName = $CurrentServer.Name

# Put server in maintenance mode
Write-Host "** Rebooting $ServerName **"
Write-Host "Entering Maintenance Mode"
Set-VMhost $CurrentServer -State maintenance -Evacuate | Out-Null

# Reboot host
Write-Host "Rebooting"
Restart-VMHost $CurrentServer -confirm:$false | Out-Null

# Wait for Server to show as down
do {
sleep 15
$ServerState = (get-vmhost $ServerName).ConnectionState
}
while ($ServerState -ne "NotResponding")
Write-Host "$ServerName is Down"

# Wait for server to reboot
do {
sleep 60
$ServerState = (get-vmhost $ServerName).ConnectionState
Write-Host "Waiting for Reboot …"
}
while ($ServerState -ne "Maintenance")
Write-Host "$ServerName is back up"

# Exit maintenance mode
Write-Host "Exiting Maintenance mode"
Set-VMhost $CurrentServer -State Connected | Out-Null
Write-Host "** Reboot Complete **"
Write-Host ""
}

## MAIN
foreach ($ESXiServer in $ESXiServers) {
RebootESXiServer ($ESXiServer)
}

# Disconnect from vCenter
Disconnect-VIServer -Server $vCenterServer -Confirm:$False
[/code]

Check VIB installation with PowerCLI

James Green · Feb 14, 2014 ·

This is super ugly, but I wanted as few lines as possible. Given a certain VIB name, this should give you a table of which hosts it is and isn’t loaded on. $True would indicate that it is installed. Maybe @alanrenouf can show me the PROPER way to do this 🙂

[code language=”powershell”] $VIBinstalled = @{}

Get-VMHost | Sort Name | %{
$VIBinstalled.Add($_,((Get-EsxCli -VMHost $_).software.vib.list() |
Where-Object {$_.Name -like ""}) -ne $null)}

$VIBinstalled
[/code]

Here’s a screenshot:

Screen Shot 2014-02-14 at 3.43.30 PM

[Read more…] about Check VIB installation with PowerCLI

Disable SSH Warning Across vCenter

James Green · Jan 21, 2014 ·

Run this PowerCLI one-liner to disable that pesky “SSH is enabled” warning on your ESXi hosts. Yes, it’s a security risk, but in my lab (for instance) I don’t want to look at it. Enjoy looking at a clean, happy cluster!

[code language=”powershell”] Get-VMHost | Get-AdvancedSetting UserVars.SuppressShellWarning |
Set-AdvancedSetting -Value 1
[/code]
  • Page 1
  • Page 2
  • Next Page »

Copyright © 2021 · Monochrome Pro on Genesis Framework · WordPress · Log in