dell / OpenManage-Enterprise

Script collateral leveraging the OME/OME-M REST APIs
Apache License 2.0
95 stars 49 forks source link

Invoke-ReportExecution.ps1 throws System.UInt64 conversion type error returning multiple $ReportData.id's #190

Closed ChrisSteinbeisser closed 3 years ago

ChrisSteinbeisser commented 3 years ago

Invoke-ReportExecution.ps1 with a -ReportD works fine but -ReportName throws a type conversion error.

PS C:\bin\I_am_wonderful\OME> .\Invoke-ReportExecution.ps1 -IpAddress "100.79.7.15" -ReportName "Warranty" -OutputFilePath test.csv

cmdlet Invoke-ReportExecution.ps1 at command pipeline position 1 Supply values for the following parameters: User: oseadmin Password for user oseadmin: *** Looking up the report with name Warranty Write-Error: Exception occured at line 406 - Cannot convert the "System.Object[]" value of type "System.Object[]" to type "System.UInt64".

SO... I threw in a line to print out $ReportData.Id right before Line 406 and noticed that looking up the name "Warranty" returns three reports: "Warranty"[11677], "warranty"[25595], and "Warranty Report"[19002] for my instance of OpenManage Enterprise. I know you can't name reports the same BUT it looks like exact matching including case might be needed here.

[running with my little print $ReportData.Id hack plus looking up ID's to name via Get-ReportList.ps1) PS C:\bin\I_am_wonderful\OME> .\Invoke-ReportExecution.ps1 -IpAddress "100.79.7.15" -Credential $cred -ReportName 'Warranty' -OutputFilePath test.csv

test.csv already exists. Do you want to continue? (Y/N): Y Looking up the report with name Warranty 11677 19002 25595 Write-Error: Exception occured at line 407 - Cannot convert the "System.Object[]" value of type "System.Object[]" to type "System.UInt64". PS C:\bin\I_amwonderful\OME> (.\Get-ReportList.ps1 -IpAddress "100.79.7.15" -Credential $cred | where-object {$.id -eq "11677"}).name

Warranty PS C:\bin\I_amwonderful\OME> (.\Get-ReportList.ps1 -IpAddress "100.79.7.15" -Credential $cred | where-object {$.id -eq "25595"}).name

warranty PS C:\bin\I_amwonderful\OME> (.\Get-ReportList.ps1 -IpAddress "100.79.7.15" -Credential $cred | where-object {$.id -eq "19002"}).name

Warranty Report

ERRATA
PS C:\bin\I_am_wonderful\OME> $PSVersionTable Name Value


PSVersion 7.1.1 PSEdition Core GitCommitId 7.1.1 OS Microsoft Windows 10.0.18363 Platform Win32NT PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…} PSRemotingProtocolVersion 2.3 SerializationVersion 1.1.0.1 WSManStackVersion 3.0

grantcurell commented 3 years ago

Evidently odata's equal operator isn't actually equal which is odd. In strings it apparently means "contains". I'm going to look into if this is supposed to happen

image

I'll patch it

grantcurell commented 3 years ago

@ChrisSteinbeisser - fixed. Let me know if you still have problems.