{"id":3227,"date":"2012-09-01T08:54:19","date_gmt":"2012-09-01T06:54:19","guid":{"rendered":"http:\/\/contoso.se\/blog\/?p=3227"},"modified":"2012-09-01T08:54:19","modified_gmt":"2012-09-01T06:54:19","slug":"get-fileattachments-download-attached-files-from-service-manager","status":"publish","type":"post","link":"https:\/\/contoso.se\/blog\/?p=3227","title":{"rendered":"Get-FileAttachments &#8211; Download attached files from Service Manager"},"content":{"rendered":"<p>In the Integration Pack for Service Manager 2012 there is a\u00c2\u00a0activity\u00c2\u00a0to upload attachment, you can also look at attachments with the Get Object activity. But what you are looking is just the object, not the context of the file. For example you can see that incident IR123 has a related file (System.FileAttachment), you can see some properties of the file, like name and size, but you cant read it. This has been a challenge in a number of scenario. A couple of days ago I asked <a href=\"http:\/\/blogs.litware.se\">Patrik<\/a> if we\u00c2\u00a0couldn&#8217;t\u00c2\u00a0do something about it and today he uploaded the first public version of a Powershell script. This Powershell script, Get-FileAttachments, will dump all file attachments to a folder. It works with both work items like incidents and configuration items like Windows computers.<\/p>\n<p>One scenario that I read about in the forum a couple of days ago is the fact that attachments are not moved to the data warehouse in Service Manager. Instead you need to archive them before the work item or config item is moved to the data warehouse. There is no built in feature for this. But with a simple runbook in Orchestrator and the get-fileattachments script it is solved \ud83d\ude42<\/p>\n<p><a href=\"http:\/\/contoso.se\/blog\/wp-content\/uploads\/2012\/08\/20120831_01.jpg\"><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter size-medium wp-image-3229\" title=\"20120831_01\" src=\"http:\/\/contoso.se\/blog\/wp-content\/uploads\/2012\/08\/20120831_01-300x157.jpg\" alt=\"\" width=\"300\" height=\"157\" srcset=\"https:\/\/contoso.se\/blog\/wp-content\/uploads\/2012\/08\/20120831_01-300x157.jpg 300w, https:\/\/contoso.se\/blog\/wp-content\/uploads\/2012\/08\/20120831_01-1024x538.jpg 1024w, https:\/\/contoso.se\/blog\/wp-content\/uploads\/2012\/08\/20120831_01.jpg 1051w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>This example monitor Service Manager for incidents that is updated with a new status that is equal to closed. The runbook then checks if there are any related file attachments, if there are, the script is triggered. The script that I run as a command in this example gets the SC Object GUID from the Monitor Closed Incidents activity as input. C:\\SCSM_Archive is my archive folder where all\u00c2\u00a0attachments\u00c2\u00a0are stored. The scripts creates a folder named as the incident and stores all files in the folder.<\/p>\n<p><a href=\"http:\/\/contoso.se\/blog\/wp-content\/uploads\/2012\/08\/20120831_02.jpg\"><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter size-medium wp-image-3230\" title=\"20120831_02\" src=\"http:\/\/contoso.se\/blog\/wp-content\/uploads\/2012\/08\/20120831_02-300x184.jpg\" alt=\"\" width=\"300\" height=\"184\" srcset=\"https:\/\/contoso.se\/blog\/wp-content\/uploads\/2012\/08\/20120831_02-300x184.jpg 300w, https:\/\/contoso.se\/blog\/wp-content\/uploads\/2012\/08\/20120831_02.jpg 551w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>Some time ago I wrote a blog post about <a title=\"Convert a incident to a service request, with a bit of Orchestrator magic\" href=\"http:\/\/contoso.se\/blog\/?p=2943\">converting incidents to service request<\/a>s. That is a scenario where you also would like to include this get-fileattachments script, to make sure all attached files are moved to the other work item too.\u00c2\u00a0You can build activity and a integration pack on the script too, see <a title=\"Building a SLEEP activity for Orchestrator\" href=\"http:\/\/contoso.se\/blog\/?p=2802\">this blog post\u00c2\u00a0<\/a>for a example<\/p>\n<p>You can download the script <a href=\"http:\/\/blogs.litware.se\/?p=1369\">here<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In the Integration Pack for Service Manager 2012 there is a\u00c2\u00a0activity\u00c2\u00a0to upload attachment, you can also look at attachments with the Get Object activity. But what you are looking is just the object, not the context of the file. For example you can see that incident IR123 has a related file (System.FileAttachment), you can see &hellip; <a href=\"https:\/\/contoso.se\/blog\/?p=3227\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0},"categories":[60,25],"tags":[],"_links":{"self":[{"href":"https:\/\/contoso.se\/blog\/index.php?rest_route=\/wp\/v2\/posts\/3227"}],"collection":[{"href":"https:\/\/contoso.se\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/contoso.se\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/contoso.se\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/contoso.se\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=3227"}],"version-history":[{"count":7,"href":"https:\/\/contoso.se\/blog\/index.php?rest_route=\/wp\/v2\/posts\/3227\/revisions"}],"predecessor-version":[{"id":3236,"href":"https:\/\/contoso.se\/blog\/index.php?rest_route=\/wp\/v2\/posts\/3227\/revisions\/3236"}],"wp:attachment":[{"href":"https:\/\/contoso.se\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3227"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/contoso.se\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3227"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/contoso.se\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3227"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}