Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Anonymous
Not applicable

Power BI Dashboard incrementing after running the script. How to Fix

 

 

Hi All,

 

Whenever i run the below scrip the data in BI dashboard keeps incrementing. Example - ESX Host - 5 then it increments to 10 Host and VM's - 61 to 122. How to fix this in power BI.

 

Any pointers will be much appreciated.

 

Nilay78_0-1601302390919.png

 

 

eport = foreach ($vCenter in $vCenters) {

Connect-VIServer $vCenter -Protocol https

}

$date = Get-Date

foreach($cluster in Get-Cluster){
$esx = $cluster | Get-VMHost


$cluster | Select @{N="DCname";E={(Get-Datacenter -Cluster $cluster).Name}},
@{N="Clustername";E={$cluster.Name}},
@{N="Total Physical Memory (GB)";E={($esx | Measure-Object -Property MemoryTotalGB -Sum).Sum}},
@{N="Configured Memory GB";E={($esx | Measure-Object -Property MemoryUsageGB -Sum).Sum}},
@{N="Available Memory (GB)";E={($esx | Measure-Object -InputObject {$_.MemoryTotalGB - $_.MemoryUsageGB} -Sum).Sum}},
@{N="Num of CPUs)";E={($esx | Measure-Object -Property NumCpu -Sum).Sum}},
@{N="Total CPU (Mhz)";E={($esx | Measure-Object -Property CpuTotalMhz -Sum).Sum}},
@{N="Configured CPU (Mhz)";E={($esx | Measure-Object -Property CpuUsageMhz -Sum).Sum}},
@{N="Number of VMs";E={($esx | Get-VM).count}},
@{N="Number of ESXi Hosts";E={$esx.count}}


$endpoint = "https://api.powerbi.com/beta/a1f1e214-7ded-45b6-81a1-9e8ae3459641/datasets/808338b1-a3bf-4572-8496-b..."
$payload = @{
"Date" = $Date
"Available Memory (GB)" =($esx | Measure-Object -InputObject {$_.MemoryTotalGB - $_.MemoryUsageGB} -Sum).Sum
"Configured Memory GB" =($esx | Measure-Object -Property MemoryUsageGB -Sum).Sum
"Total Physical Memory (GB)" =($esx | Measure-Object -Property MemoryTotalGB -Sum).Sum
"Clustername" =$cluster.Name
"Num of CPUs" =($esx | Measure-Object -Property NumCpu -Sum).Sum
"Total CPU (Mhz)" =($esx | Measure-Object -Property CpuTotalMhz -Sum).Sum
"Configured CPU (Mhz)" =($esx | Measure-Object -Property CpuUsageMhz -Sum).Sum
"Datacenter" =(Get-Datacenter -Cluster $cluster).Name
"Number of VMs" =($esx | Get-VM).count
"Number of ESXi Hosts" =$esx.count
}
Invoke-RestMethod -Method Post -Uri "$endpoint" -Body (ConvertTo-Json @($payload))

}

 

Thanks

N

1 REPLY 1
PhilipTreacy
Super User
Super User

Hi @Anonymous 

Is that a PowerShell script? Sorry I'm not familiar with it.  But if your script is doubling the values in your data, is it reading the current values and then adding them back to itself?

Phil



Did I answer your question? Then please mark my post as the solution.
If I helped you, click on the Thumbs Up to give Kudos.


Blog :: YouTube Channel :: Connect on Linkedin


Proud to be a Super User!


Helpful resources

Announcements
July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.