Forum Discussion
Host utilization report through Power BI
Hi , All
I'm trying to retrieve the Host utilization report with PowerCLI script to find out average CPU and Memory hosts utilization during period of time and push the data to BI tool, but it fails with an error for all the hosts. Looking for help.
Invoke-RestMethod : Invalid URI: The hostname could not be parsed.
At D:\xyz\Host-ut-BI.ps1:60 char:5
+ Invoke-RestMethod -Method Post -Uri "$endpoint" -Body (ConvertTo- ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Invoke-RestMethod], UriFormatException
+ FullyQualifiedErrorId : System.UriFormatException,Microsoft.PowerShell.Commands.InvokeRestMethodCommand
Thanks
N
Import-Module VMware.VimAutomation.Core
Connect-VIServer -Server Domain.com -user "Domain\user"
$now = Get-Date
$start = $now.AddDays(-1)
$finish = $now
$SStat = @{
Entity = Get-VMHost
Stat = 'cpu.usage.average', 'mem.usage.average'
Start = $start
Finish = $finish
Instance = '*'
ErrorAction = 'SilentlyContinue'
}
Get-Stat @sStat |
Group-Object -Property { $_.Entity.Name } |
ForEach-Object -Process {
New-Object -TypeName PSObject -Property ([ordered]@{
Host = $_.Name
Start = $start
Finish = $finish
CpuAvgPerc = [math]::Round(($_.Group | where { $_.MetricId -eq 'cpu.usage.average' } | Measure-Object -Property Value -Average).Average, 1)
MemAvgPerc = [math]::Round(($_.Group | where { $_.MetricId -eq 'mem.usage.average' } | Measure-Object -Property Value -Average).Average, 1)
})
$payload = @{
"Date" = $Date
"Host" = $Host.Name
"CpuAvgPerc" = $CpuAvgPerc
"MemAvgPerc" = $MemAvgPerc
}
Invoke-RestMethod -Method Post -Uri "$endpoint" -Body (ConvertTo-Json @($payload))
}
Disconnect-VIServer * -Confirm:$false
$endpoint = ""
$payload = @{
"Date" = $Date
"Host" = $Host.Name
"CpuAvgPerc" = $CpuAvgPerc
"MemAvgPerc" = $MemAvgPerc
}
Invoke-RestMethod -Method Post -Uri "$endpoint" -Body (ConvertTo-Json @($payload))
2 Replies
- lbendlinSuper User
your endpoint is empty.
- AnonymousNot applicable
Hi,
I kept intentionally. Infact while running the report i have added the endpoint "https://api.powerbi.com/beta/a1f1e214-7ded-45b6-81a1-9e8ae3459641/datasets/18e01bc8-a274-4dc6-9148-b23eea2fc5da/rows?noSignUpCheck=1&key=jxhJklhkok3elRVNZdus50NtUTqtx8qiRy7ovtNG3idjv%2BV5%2BoMCvJEVkKSUWH2w6hVSC7am5ftBECsCgFT3Ig%3D%3D"
but still throws an error.
Thanks
N