Snow-Shell / servicenow-powershell

PowerShell module to automate ServiceNow service and asset management. This module can be used standalone, with Azure Automation, or Docker.
Apache License 2.0
361 stars 171 forks source link

Fix #131 (Add-ServiceNowAttachment not working on PowerShell 7) #132

Closed natescherer closed 3 years ago

natescherer commented 3 years ago

This is a fix for Add-ServiceNowAttachment not working on PowerShell 7.

As there does not appear to be a .NET Core replacement for System.Web.MimeMapping, I created a static hash of mime types derived from https://github.com/samuelneff/MimeTypeMap/blob/master/MimeTypeMap.cs. I have tested and this works on Windows PowerShell 5.1 and PowerShell 7.1.3.

Please let me know if you have any questions!

gdbarron commented 3 years ago

Hey @natescherer, nice work on this! I'd ask for 2 changes please, 1 small, 1 not so small 😄 Can we move this into a config file? It feels like that's a better place for it not just aesthetically, but for reuse. Perhaps /ServiceNow/config/MimeTypeMap.json? There's an example in the .psm1 for main.json. Also, can you throw a link to the .cs file in there? Thanks much!

natescherer commented 3 years ago

Done!

gdbarron commented 3 years ago

Awesome, thanks, working well. Last change and then we are good. The .json just needs to be converted to utf8.

natescherer commented 3 years ago

Good catch, I did an Out-File to create the JSON from the hash and I forgot to set the encoding. It's fixed now.