VMware Status Dashboard

When I run my PowerCLI scripts from the local server where SquaredUp is installed they work fine. However, when I try to run the scripts in SquaredUp they just time out after 59 seconds. The environment is setup to use a VMware profile that was copied from the the community site and the variables were changed to match my local configuration.

Same here. Same results. Not clear what’s wrong.

@PierreB
@Daniel

Could either of you provide more details? Maybe some screen captures on how you set it up (just to baseline things).

Once I have more information, I’ll see if I can troubleshoot in my lab.

Cheers

Thanks for offering to help. Honestly not much else to provide. I followed the instructions from the dashboard’s page, supplying two different sets of credentials to try with. The tiles just keep saying script timeout, then they seem to keep trying, then time out again and again. If I run the scripts from the tiles themselves in a powershell window on the DS server, they also work fine.

some log entries:
2023-04-19 14:16:36.321 >> 077 >> [WRN] PoSH execute 721ded31-a18a-480a-811b-962c7234ea09: SquaredUp.PowerShell.Host.exe: Execution timed out after 116.11 seconds
2023-04-19 14:16:36.325 >> 077 >> [WRN] PowerShell host threw exception System.Exception: SquaredUp.PowerShell.Exceptions.PowerShellTimeoutException: PowerShell script timed out after 116.11 seconds
at SquaredUp.PowerShell.Host.PowerShell.d__2.MoveNext()

What account are you using for the PowerShell tile?

Are you using the NetworkService account, and did you give it the Allow Log On Locally permission?

If you are using a different account, did you give it the Allow Log on Locally, Adjust memory quotas for a process, and Replace a process-level token?

For reference, and for others watching this thread, this is all documented here:

#Profile Script
###############################################################################

Load up our Custom Profile

###############################################################################
$User = “domain\username”
$Pass = “password”

#The URL to our vCenter Server
$vCenter = “vcenter server name”

###############################################################################

Before a connection to vCenter is initiated, check some specific settings

We mostly care about ignoring invalid certificate warnings and depreciated warnings

Wrap the settings change in a Try-Catch block to prevent any unhandled exception messages

This prevents error messages when multiple tiles attempt (and fail) to write to the PowerCLI_Settings.xml file at the same time

###############################################################################
$lConfig = Get-PowerCLIConfiguration -Scope User
If ($lConfig.InvalidCertificateAction -ne’Ignore’) {
try {
Set-PowerCLIConfiguration -InvalidCertificateAction Ignore -Confirm:$false -ErrorAction SilentlyContinue
}
Catch {
#$Error[0]
}
}

If ($lConfig.DisplayDeprecationWarnings -ne’False’) {
try {
Set-PowerCLIConfiguration -DisplayDeprecationWarnings $false -Confirm:$false -ErrorAction SilentlyContinue | Out-Null
}
Catch {
#Error[0]
}
}

###############################################################################

Conenct to vCenter

###############################################################################
$serverlist = $global:DefaultVIServer
while ($serverlist.IsConnected -ne"True") {
try {
Connect-VIServer -Server $vCenter -User $User -Password $Pass -ErrorAction SilentlyContinue
}
catch {
}
$serverlist = $global:DefaultVIServer
}

###############################################################################

Page Timeframe code

###############################################################################
$finish = [DateTime]::Now
switch ($timeFrame) {
“last1Hour” { $start = $finish.Addhours(-1); $MaxSamples = 150; }
“last12Hours” { $start = $finish.Addhours(-12); $MaxSamples = 300; }
“last24Hours” { $start = $finish.Addhours(-24); $MaxSamples = 400; }
“last7Days” { $start = $finish.AddDays(-7); $MaxSamples = 500; }
“last30Days” { $start = $finish.AddDays(-30); $MaxSamples = 600; }
“last3Months” { $start = $finish.AddMonths(-3); $MaxSamples = 700; }
“last6Months” { $start = $finish.AddMonths(-6); $MaxSamples = 800; }
“last12Months” { $start = $finish.AddMonths(-12); $MaxSamples = 900; }
}

###############################################################################

Some variables to resuse

###############################################################################
$vm = “vm name”
$vmHost = Get-VMHost -Name “vm host name”

#end profile script

###vCenterStatus
$vmHost = Get-VMHost | Select-Object Name, ConnectionState, PowerState, NumCpu, CpuUsageMhz, CpuTotalMhz, MemoryUsageGB, MemoryTotalGB, Version

#Create a new column called State for the SquaredUp Status tile
$vmHost | Add-Member -MemberType NoteProperty “state” -Value “”

#Loop through each object to set state
foreach($host2 in $vmHost){
$host2.state = if ($host2.PowerState -eq ‘PoweredOn’){‘healthy’}
elseif ($host2.PowerState -eq ‘PoweredOff’){‘critical’}
else {‘warning’}
}

$vmHost

##Count of VM’s by Assigned Memory
$vm = Get-VM
$vm | Group-Object MemoryGB

##Count of VMs by Assigned vCPUs
$vm = Get-VM
$vm | Group-Object NumCpu

##VM Power Status
$vmHost = Get-VMHost
$vms = Get-VMHost -Name $vmHost.Name | Get-VM

#Get a count of our power states
$count = $vms | Group-Object -Property “PowerState”

#Hint: A column named state must exist and contain the following values: Healthy, Critical, and/or Warning.

Any other values in the state column will be displayed as Unknown (gray tile).

#Create a new column called State for the SquaredUp Status tile
$count | Add-Member -MemberType NoteProperty “state” -Value “”

#Loop through each object to set state
foreach($item in $count){
$item.state = if ($item.name -eq ‘PoweredOn’){‘healthy’}
elseif ($item.name -eq ‘PoweredOff’){‘critical’}
else {‘warning’}
}

#Display Status tiles AND sort by name!
$count | Sort-object name -desc

#Hosts by Version & Build
$vmHost = Get-VMHost
$vmhost | Group-Object -Property Version,Build

#VM Power Status
$vmHost = Get-VMHost
$vms = Get-VMHost -Name $vmHost.Name | Get-VM

#Create a new column called State for the SquaredUp Status tile
$vms | Add-Member -MemberType NoteProperty “state” -Value “”

#Loop through each object to set state
foreach($vm in $vms){
$vm.state = if ($vm.PowerState -eq ‘PoweredOn’){‘healthy’}
elseif ($vm.PowerState -eq ‘PoweredOff’){‘critical’}
else {‘warning’}
}
$vms | Select-Object name,state

My app pool uses NetworkService which is added to local secpol to log on locally. Also tried using my user credentials. No joy either way.

1 Like

1 Like

@Daniel

It looks like you got the dashboard working, nice!

1 Like

ok well now I’m jealous haha

1 Like

@Daniel how did you get it to work?

1 Like

@PierreB

First, let’s verify that NetworkService has the proper permissions.

Create a new dashboard with one PowerShell (Scalar) tile.

For the Run As, choose Default.
For the Profile, choose Default (which you should verify as empty).

For the script, enter this:
whoami /all

You will get some security information for the NetworkService account when it executes. It should look like this:

If that is correct, but things still don’t work, let’s try creating a “test” dashboard.

Create a new dashboard with one PowerShell (status - block) tile.

For the Run As, choose Default.
For the Profile, choose Default (which you should verify as empty).

For the script, enter this:

$User = "<Enter your VMware Username>"
$Pass = "<Enter your VMware Password>"
$vCenter = "<vcenter.domain.local>"
Connect-VIServer -Server $vCenter -User $User -Password $Pass 

$vmHost = Get-VMHost | Select-Object Name, ConnectionState, PowerState, NumCpu, CpuUsageMhz, CpuTotalMhz, MemoryUsageGB, MemoryTotalGB, Version
$vmHost | Add-Member -MemberType NoteProperty "state" -Value ""

foreach($host2 in $vmHost){
    $host2.state = if ($host2.PowerState -eq 'PoweredOn'){'healthy'}
                elseif ($host2.PowerState -eq 'PoweredOff'){'critical'}
                else {'warning'}
}
$vmHost

You should see an error message in the response blade if something isn’t set up correctly.

Here is an example:

I just finished setting this up in my personal lab using NetworkService, and it is working as shown.

All of that works but not the community dashboard. I’ll keep trying I guess.

Solved it by removing this section from the provided script:

###############################################################################

Some variables to resuse

###############################################################################
$vm = “Insert the Name of a VM here”
$vmHost = Get-VMHost -Name “FQDN of your vCenter Host”

1 Like