File tree 2 files changed +641
-2
lines changed
2 files changed +641
-2
lines changed Original file line number Diff line number Diff line change @@ -114,8 +114,12 @@ Function Add-ServiceNowAttachment {
114
114
ForEach ($Object in $File ) {
115
115
$FileData = Get-ChildItem $Object - ErrorAction Stop
116
116
If (-not $ContentType ) {
117
- Add-Type - AssemblyName ' System.Web'
118
- $ContentType = [System.Web.MimeMapping ]::GetMimeMapping($FileData.FullName )
117
+ # Thanks to https://github.com/samuelneff/MimeTypeMap/blob/master/MimeTypeMap.cs from which
118
+ # MimeTypeMap.json was adapted
119
+ $ContentTypeHash = ConvertFrom-Json (Get-Content " $PSScriptRoot \..\config\MimeTypeMap.json" - Raw)
120
+
121
+ $Extension = [IO.Path ]::GetExtension($FileData.FullName )
122
+ $ContentType = $ContentTypeHash .$Extension
119
123
}
120
124
121
125
# POST: https://instance.service-now.com/api/now/attachment/file?table_name=incident&table_sys_id=d71f7935c0a8016700802b64c67c11c6&file_name=Issue_screenshot
You can’t perform that action at this time.
0 commit comments