Attach file to call from folder (folder watcher?)
Sorry if this has been asked before, I couldn't find anything on here (and apologies it's not strictly Cireson related, so tell me to go away if I shouldn't post it here!).
Anyway...
We'd like to be able to save a file in to a folder on a server, that is then picked up (by powershell or orchestrator?) and attached to a SR or IR in SCSM/Cireson.
We'd like to be able to call the file IR123456.pdf and the script know that that file should be attached to IR123456.
(Also for multiples we'd like to be able to call the file IR123456_2.pdf or something and it still know, but that isn't critical)
I guess the orchestrator job would need to poll the folder, to search for files, but would there be a way to put a shortcut in there for the team to double click when they need it (saving system resources).
I'm sure @Geoff_Ross has told me there is a way to achieve something like this previously, but I we hadn't pursued it until now.
Best Answers
-
Brett_Moffett Cireson PACE Super IT Monkey ✭✭✭✭✭here is a quick example:
This just monitors the folder listed for the files shown in the Filters.
Then we can run some PowerShell code to make the magic happen of first enumerating the files (Working out what Work Item number it is for) then finding the Work Item and attaching the file to it.
Finally, move the file to another location so it does not trigger any new workflows.
Hope this helps5 -
David_Johnsen Customer Advanced IT Monkey ✭✭✭Hi,
Just an update for reference, if anyone else is lurking.
I've spent the quiet Christmas period working on some runbooks and a bit of powershell to get the Auto Attach process running. Hopefully it won't become redundant in SM 2016!
I'm very new to runbooks and powershell (about 3 months), so apologies that it's probably pretty crude!
There's 2 runbooks, one that monitors the folder and gets the file info and reads the filename for the SR reference.
The second takes this info and attaches the file to the SR.
The powershell in the "Format File Name to SRID" activity is below:$FileName = "{File name from "Get File Status"}"If ($FileName.Substring(7,1) -match "[0-9]") {$SRID = $FileName.Remove(8)} Else {$SRID = $FileName.Remove(7)}This process relies on 1st character after the SR ref in filename not being a number.
The IF statement is to ensure that if a call is older than SR99 999, then it only reads the 1st 7 digits, if newer than this it reads 8 digits.It'll need amending when we pass SR999 999 (millionth call), but hopefully that'll be around 2025!8
Answers
This forum is for anyone in the community to ask questions on anything System Center related, so no one is going to tell you to go away.
You are absolutely right that this is possible to do.
It could be done via Orchestrator or via PowerShell or a combination there of.
If you wish to do this via a RunBook, then you could do it using a monitoring activity that could monitor a folder, or your could do it via a scheduled job that could run every x minutes\hours etc.
In addition, you could create a task within the SCSM console that could call the Runbook from within Orchestrator to do a "Manual Sync" of the folder if you wanted to as well.
It all depends on what you want to achieve with the solution and how complex it needs to be as to the length a detail of the solution.
I'm happy to chat with you in more detail here about it if you like.
Regards,
@Brett_Moffett
We literally just want to be able to save files to a folder which then automatically attaches the files to a (closed) IR/SR.
I'd be welcome to take your recommendation on it!
This just monitors the folder listed for the files shown in the Filters.
Then we can run some PowerShell code to make the magic happen of first enumerating the files (Working out what Work Item number it is for) then finding the Work Item and attaching the file to it.
Finally, move the file to another location so it does not trigger any new workflows.
Hope this helps
Let me know if you would like me to get you in touch with our UK staff.
But I've got a call open regarding that not working when Skype is installed. So I'll see if I get anywhere with a fix for that, and then take it from there.
Thanks.
Just an update for reference, if anyone else is lurking.
I've spent the quiet Christmas period working on some runbooks and a bit of powershell to get the Auto Attach process running. Hopefully it won't become redundant in SM 2016!
I'm very new to runbooks and powershell (about 3 months), so apologies that it's probably pretty crude!
There's 2 runbooks, one that monitors the folder and gets the file info and reads the filename for the SR reference.
The second takes this info and attaches the file to the SR.
The powershell in the "Format File Name to SRID" activity is below:
The IF statement is to ensure that if a call is older than SR99 999, then it only reads the 1st 7 digits, if newer than this it reads 8 digits.
Nice work.