{"id":2449,"date":"2011-07-03T11:49:53","date_gmt":"2011-07-03T09:49:53","guid":{"rendered":"http:\/\/contoso.se\/blog\/?p=2449"},"modified":"2011-07-04T21:01:33","modified_gmt":"2011-07-04T19:01:33","slug":"how-to-build-a-custom-activity-with-qik-and-powershell","status":"publish","type":"post","link":"http:\/\/contoso.se\/blog\/?p=2449","title":{"rendered":"How-to build custom activities with QIK and PowerShell"},"content":{"rendered":"<p>In this blog post I will show you how to build\u00c2\u00a0two custom activities based on PowerShell commands. I will be using the Orchestrator beta and Quick Integration Kit 3. The\u00c2\u00a0Quick Integration\u00c2\u00a0Kit (QIK) enables you to extend\u00c2\u00a0your library of activities, with new custom integration packs and activities. QIK features a Command Line Interface (CLI) Wizard that allows you to describe how to run Command Line Interfaces (such as Windows Commands, SSH or PowerShell) and capture their output as Published Data. The QIK CLI Wizard provides a mechanism for very rapidly producing activities without the need for programming, given the readily available libraries of PowerShell from Microsoft and other community sources.\u00c2\u00a0In this blog post we will build two activities, one for counting files in a folder and one for list all files with a specific extension (for example mp3 files) in a folder. We will use\u00c2\u00a0QIK CLI that will help us build an integration pack (IP) around in this scenario two PowerShell commands. Let\u00c2\u00b4s start with the one counting files<\/p>\n<ol>\n<li>Start Opalis\u00c2\u00a0QIK CLI. After default installation of QIK there will be a shortcut on your desktop<\/li>\n<li>Welcome to the Opalis QIK CLI, click Next<\/li>\n<li>Assembly QIK CLI, input a name for example ContosoFileAssembly<\/li>\n<li>Assembly QIK CLI, browse and input where the file will be created, for example C:\\TEMP\\FILEIP\\ContosoFileIPAssembly.dll<\/li>\n<li>Assembly QIK CLI, click Next<\/li>\n<li>Commands, click Add&#8230;<\/li>\n<li>Add\/Edit Command, General, input\n<ol>\n<li>Name: Count Files in Folder<\/li>\n<li>Mode: Run Windows PowerShell<br \/>\n<a href=\"http:\/\/contoso.se\/blog\/wp-content\/uploads\/2011\/06\/20110630_FILE_QIK01.jpg\"><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter size-medium wp-image-2461\" title=\"20110630_FILE_QIK01\" src=\"http:\/\/contoso.se\/blog\/wp-content\/uploads\/2011\/06\/20110630_FILE_QIK01-300x144.jpg\" alt=\"\" width=\"300\" height=\"144\" srcset=\"http:\/\/contoso.se\/blog\/wp-content\/uploads\/2011\/06\/20110630_FILE_QIK01-300x144.jpg 300w, http:\/\/contoso.se\/blog\/wp-content\/uploads\/2011\/06\/20110630_FILE_QIK01.jpg 475w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><\/li>\n<\/ol>\n<\/li>\n<li>Add\/Edit Command, Arguments,\n<ol>\n<li>Click Add under Parameters<\/li>\n<li>Add\/Edit Parameter, input\n<ol>\n<li>Name: Folder<\/li>\n<li>Usage mode: Command Argument<\/li>\n<li>Display Style: Folder<\/li>\n<li>Echo as published data: Check<\/li>\n<li>Click OK<br \/>\n<a href=\"http:\/\/contoso.se\/blog\/wp-content\/uploads\/2011\/06\/20110630_FILE_QIK02.jpg\"><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter size-medium wp-image-2462\" title=\"20110630_FILE_QIK02\" src=\"http:\/\/contoso.se\/blog\/wp-content\/uploads\/2011\/06\/20110630_FILE_QIK02-300x203.jpg\" alt=\"\" width=\"300\" height=\"203\" srcset=\"http:\/\/contoso.se\/blog\/wp-content\/uploads\/2011\/06\/20110630_FILE_QIK02-300x203.jpg 300w, http:\/\/contoso.se\/blog\/wp-content\/uploads\/2011\/06\/20110630_FILE_QIK02.jpg 459w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><\/li>\n<\/ol>\n<\/li>\n<li> Add\/Edit Command, Arguments, input  &#8220;get-childitem $(Folder) | measure-object -property length&#8221; as command line. Click OK<br \/>\n<a href=\"http:\/\/contoso.se\/blog\/wp-content\/uploads\/2011\/06\/20110630_FILE_QIK03.jpg\"><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter size-medium wp-image-2463\" title=\"20110630_FILE_QIK03\" src=\"http:\/\/contoso.se\/blog\/wp-content\/uploads\/2011\/06\/20110630_FILE_QIK03-300x231.jpg\" alt=\"\" width=\"300\" height=\"231\" srcset=\"http:\/\/contoso.se\/blog\/wp-content\/uploads\/2011\/06\/20110630_FILE_QIK03-300x231.jpg 300w, http:\/\/contoso.se\/blog\/wp-content\/uploads\/2011\/06\/20110630_FILE_QIK03.jpg 463w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><\/li>\n<\/ol>\n<\/li>\n<li>Add\/Edit Command, Published Data, click Add\n<ol>\n<li>Add\/Edit Published Data, input\n<ol>\n<li>Name: _Count (We use _ in front of all object-specific published data, then it is easier to see it in the list of published data when working in the console. Thanks to Robert Hearn for that tip)<\/li>\n<li>Property: Count<\/li>\n<li>Description: Number of files in folder<\/li>\n<li>Click OK<br \/>\n<a href=\"http:\/\/contoso.se\/blog\/wp-content\/uploads\/2011\/06\/20110630_FILE_QIK04.jpg\"><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter size-medium wp-image-2466\" title=\"20110630_FILE_QIK04\" src=\"http:\/\/contoso.se\/blog\/wp-content\/uploads\/2011\/06\/20110630_FILE_QIK04-300x165.jpg\" alt=\"\" width=\"300\" height=\"165\" srcset=\"http:\/\/contoso.se\/blog\/wp-content\/uploads\/2011\/06\/20110630_FILE_QIK04-300x165.jpg 300w, http:\/\/contoso.se\/blog\/wp-content\/uploads\/2011\/06\/20110630_FILE_QIK04.jpg 371w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><\/li>\n<\/ol>\n<\/li>\n<\/ol>\n<\/li>\n<li>Add\/Edit Command, Published Data, click OK<\/li>\n<li>Commands, click Next<\/li>\n<li>Click Finish<\/li>\n<\/ol>\n<p>We now have a dll file, a .NET assembly. We can now use the invoke .NET activity in the QIK IP to test the DLL before we build the IP. Start the System Center Orchestrator Runbook Designer and build a simple runbook to use the Invoke .NET activity and a Send Platform Event activity. To get the\u00c2\u00a0Invoke .NET activity you need to import the QIK IP. It is located at C:\\Program Files (x86)\\Opalis Software\\Quick Integration Kit 3\\Integration Packs after default QIK installation. Don&#8217;t forget to input a folder under Properties of the Invoke .NET activity. Configure the Send Platform Event activity to publish the count data from the Invoke .NET activity. Run the policy and verify that you get a result in the Send Platform Event activity.<\/p>\n<p><a href=\"http:\/\/contoso.se\/blog\/wp-content\/uploads\/2011\/06\/20110630_FILE_QIK05.jpg\"><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter size-medium wp-image-2468\" title=\"20110630_FILE_QIK05\" src=\"http:\/\/contoso.se\/blog\/wp-content\/uploads\/2011\/06\/20110630_FILE_QIK05-300x169.jpg\" alt=\"\" width=\"300\" height=\"169\" srcset=\"http:\/\/contoso.se\/blog\/wp-content\/uploads\/2011\/06\/20110630_FILE_QIK05-300x169.jpg 300w, http:\/\/contoso.se\/blog\/wp-content\/uploads\/2011\/06\/20110630_FILE_QIK05.jpg 623w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p><a href=\"http:\/\/contoso.se\/blog\/wp-content\/uploads\/2011\/06\/20110630_FILE_QIK06.jpg\"><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter size-medium wp-image-2469\" title=\"20110630_FILE_QIK06\" src=\"http:\/\/contoso.se\/blog\/wp-content\/uploads\/2011\/06\/20110630_FILE_QIK06-300x137.jpg\" alt=\"\" width=\"300\" height=\"137\" srcset=\"http:\/\/contoso.se\/blog\/wp-content\/uploads\/2011\/06\/20110630_FILE_QIK06-300x137.jpg 300w, http:\/\/contoso.se\/blog\/wp-content\/uploads\/2011\/06\/20110630_FILE_QIK06.jpg 620w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p><a href=\"http:\/\/contoso.se\/blog\/wp-content\/uploads\/2011\/06\/20110630_FILE_QIK07.jpg\"><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter size-medium wp-image-2470\" title=\"20110630_FILE_QIK07\" src=\"http:\/\/contoso.se\/blog\/wp-content\/uploads\/2011\/06\/20110630_FILE_QIK07-300x189.jpg\" alt=\"\" width=\"300\" height=\"189\" srcset=\"http:\/\/contoso.se\/blog\/wp-content\/uploads\/2011\/06\/20110630_FILE_QIK07-300x189.jpg 300w, http:\/\/contoso.se\/blog\/wp-content\/uploads\/2011\/06\/20110630_FILE_QIK07.jpg 384w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>Time to add the second activity, that should list all files with a specific extension in a folder.<\/p>\n<ol>\n<li>Start QIK CLI again, on the Welcome screen, click &#8220;Load from QIK CLI Assembly&#8221; and select your dll file (C:\\TEMP\\FILEIP\\ContosoFileIPAssembly.dll)<\/li>\n<li>Assembly Details,\u00c2\u00a0click Assembly Information and raise version to 1.0.0.1. Click OK<\/li>\n<li>Assembly Details, click Next<\/li>\n<li>Commands, click Add&#8230;\n<ol>\n<li>Input the following settings\n<ol>\n<li>General, Name: List specific files in folder<\/li>\n<li>General, Mode: Run Windows PowerShell<\/li>\n<li>Arguments, Parameters, add\n<ol>\n<li>Name: Folder<\/li>\n<li>Usage mode: Command Argument<\/li>\n<li>Display Style: Folder<\/li>\n<li>Echo as published data: Check<\/li>\n<\/ol>\n<\/li>\n<li>Arguments, Parameters, add\n<ol>\n<li>Name: File Extension<\/li>\n<li>Usage mode: Command Argument<\/li>\n<li>Display Style: Text<\/li>\n<li>Echo as published data: Check<\/li>\n<\/ol>\n<\/li>\n<li>Arguments, Command Line, input &#8220;(Get-childitem $(Folder) | where {$_.Extension -eq &#8216;$Extension)&#8217;})<br \/>\n<a href=\"http:\/\/contoso.se\/blog\/wp-content\/uploads\/2011\/06\/20110630_FILE_QIK10.jpg\"><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter size-medium wp-image-2472\" title=\"20110630_FILE_QIK10\" src=\"http:\/\/contoso.se\/blog\/wp-content\/uploads\/2011\/06\/20110630_FILE_QIK10-300x173.jpg\" alt=\"\" width=\"300\" height=\"173\" srcset=\"http:\/\/contoso.se\/blog\/wp-content\/uploads\/2011\/06\/20110630_FILE_QIK10-300x173.jpg 300w, http:\/\/contoso.se\/blog\/wp-content\/uploads\/2011\/06\/20110630_FILE_QIK10.jpg 461w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><\/li>\n<li>Published Data, add\n<ol>\n<li>Name: _Fullname<\/li>\n<li>Property: fullname<\/li>\n<li>Description: File path<\/li>\n<\/ol>\n<\/li>\n<li>Published Data, add\n<ol>\n<li>Name: _Name<\/li>\n<li>Property: name<\/li>\n<li>Description: Name of the file<\/li>\n<\/ol>\n<\/li>\n<li>Published Data, add\n<ol>\n<li>Name: _Length<\/li>\n<li>Property: Length<\/li>\n<li>Description: File size<\/li>\n<\/ol>\n<\/li>\n<li>Published Data, click OK<br \/>\n<a href=\"http:\/\/contoso.se\/blog\/wp-content\/uploads\/2011\/06\/20110630_FILE_QIK09.jpg\"><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter size-medium wp-image-2471\" title=\"20110630_FILE_QIK09\" src=\"http:\/\/contoso.se\/blog\/wp-content\/uploads\/2011\/06\/20110630_FILE_QIK09-300x100.jpg\" alt=\"\" width=\"300\" height=\"100\" srcset=\"http:\/\/contoso.se\/blog\/wp-content\/uploads\/2011\/06\/20110630_FILE_QIK09-300x100.jpg 300w, http:\/\/contoso.se\/blog\/wp-content\/uploads\/2011\/06\/20110630_FILE_QIK09.jpg 446w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><\/li>\n<\/ol>\n<\/li>\n<li>Commands, click Next<\/li>\n<li>When the wizard complete successfully you can can test the new command in the console with the .NET Invoke activity. Else, to build the integration pack, click Build Integration Pack. It is the same wizard that you can start direct from the shortcut &#8220;QIK Wizard&#8221;<\/li>\n<\/ol>\n<\/li>\n<li>Opalis Quick Integration Kit Wizard, product details, input\n<ol>\n<li>Category Name: Contoso File Management<\/li>\n<li>Manufacturer: Contoso<\/li>\n<\/ol>\n<\/li>\n<li>Opalis Quick Integration Kit Wizard, product details, click Next<\/li>\n<li>Opalis Quick Integration Kit Wizard, objects, click Next<\/li>\n<li>Opalis Quick Integration Kit Wizard, dependencies, click Next<\/li>\n<li>Opalis Quick Integration Kit Wizard, Opalis Integration Pack File, input where to create the IP, for example C:\\TEMP\\FILEIP\\ContosoFile.oip . Click Next<\/li>\n<li>Opalis Quick Integration Kit Wizard, The QIK Wizard Succeeded, click Finish<\/li>\n<\/ol>\n<p>Now, use the Deployment manager to register IP with Orchestrator Management server and deploy IP to runbook servers and runbook designers. You can then use your new integration pack and activities in runbooks \ud83d\ude42<\/p>\n<p><a href=\"http:\/\/contoso.se\/blog\/wp-content\/uploads\/2011\/06\/20110630_FILE_QIK11.jpg\"><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter size-medium wp-image-2473\" title=\"20110630_FILE_QIK11\" src=\"http:\/\/contoso.se\/blog\/wp-content\/uploads\/2011\/06\/20110630_FILE_QIK11-300x124.jpg\" alt=\"\" width=\"300\" height=\"124\" srcset=\"http:\/\/contoso.se\/blog\/wp-content\/uploads\/2011\/06\/20110630_FILE_QIK11-300x124.jpg 300w, http:\/\/contoso.se\/blog\/wp-content\/uploads\/2011\/06\/20110630_FILE_QIK11.jpg 953w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>Please note that this is provided \u00e2\u20ac\u0153as is\u00e2\u20ac\u009d with no warranties at all. If you want to take a look at my demo files\u00c2\u00a0send me a e-mail, I will upload them after some extra activites has been added.\u00c2\u00a0Download QIK <a href=\"http:\/\/blogs.technet.com\/b\/scorch\/\">here<\/a>.<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In this blog post I will show you how to build\u00c2\u00a0two custom activities based on PowerShell commands. I will be using the Orchestrator beta and Quick Integration Kit 3. The\u00c2\u00a0Quick Integration\u00c2\u00a0Kit (QIK) enables you to extend\u00c2\u00a0your library of activities, with new custom integration packs and activities. QIK features a Command Line Interface (CLI) Wizard that &hellip; <a href=\"http:\/\/contoso.se\/blog\/?p=2449\">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":[58,60],"tags":[],"_links":{"self":[{"href":"http:\/\/contoso.se\/blog\/index.php?rest_route=\/wp\/v2\/posts\/2449"}],"collection":[{"href":"http:\/\/contoso.se\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/contoso.se\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/contoso.se\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/contoso.se\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2449"}],"version-history":[{"count":23,"href":"http:\/\/contoso.se\/blog\/index.php?rest_route=\/wp\/v2\/posts\/2449\/revisions"}],"predecessor-version":[{"id":2483,"href":"http:\/\/contoso.se\/blog\/index.php?rest_route=\/wp\/v2\/posts\/2449\/revisions\/2483"}],"wp:attachment":[{"href":"http:\/\/contoso.se\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2449"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/contoso.se\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2449"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/contoso.se\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2449"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}