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.
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.
ok well now Iâm jealous haha
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â