dell/OpenManage-Enterprise

Get-ReportList.ps1 Error - Unable to find type [System.Net.Http.HttpRequestException]

Closed this issue · 3 comments

Get-ReportList.ps1's update throws an error... and usine PowerShell ISE PSVersion 5.1.18362.1171 when it does such...

PS C:\bin\I_am_wonderful> ./Get-ReportList.ps1 -IpAddress "100.79.7.15" -Credentials $cred
C:\bin\I_am_wonderful\Get-ReportList.ps1 : Exception occured at line 150 - Unable to find type [System.Net.Http.HttpRequestException].
At line:1 char:1

  • ./Get-ReportList.ps1 -IpAddress "100.79.7.15" -Credentials $cred
  •   + CategoryInfo          : NotSpecified: (:) [Write-Error], WriteErrorException
      + FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,Get-ReportList.ps1
    
    
    

PS C:\bin\I_am_wonderful> Get-Host | Select-Object Version

Version

5.1.18362.1171

@ChrisSteinbeisser since I'm the only one doing maintenance in my free time we're trying to future proof so everything is targeting PS7 for longevity. The problem is some people have upgraded and some people have not and the two versions are not mutually compatible.

That said, if you'd be willing I'd definitely welcome help retooling the library code to handle both versions if that's something you want. I know 5.1 comes default on servers so it's something probably worth investigating.

Edit: The other reason 7 was selected is that PS core is portable whereas ISE is not

I figured it was something to do with compatibility. I'll just get in line with PS7 moving forward/communicate using PS7 to others when using these examples as starter scripts as well. Thanks!

I went and checked - I get the same error on 5.1 that you did. I've added a warning on the README and also opened a ticket on which people can comment if PS5.1 is a hard requirement for them so we have a better idea of how big an issue this is. If we get a lot of responses indicating this is a problem I'll work out a solution for at least making it so the library code is cross compatible.

I also added a requirement to all the scripts so they will fail with the below message when run on a version below 7:

The script 'Get-ReportList.ps1' cannot be run because it contained a "#requires" statement for Windows PowerShell 7.0. The 
version of Windows PowerShell that is required by the script does not match the currently running version of Windows PowerShell 
5.1.19041.610.
    + CategoryInfo          : ResourceUnavailable: (Get-ReportList.ps1:String) [], ParentContainsErrorRecordException
    + FullyQualifiedErrorId : ScriptRequiresUnmatchedPSVersion