{"action":"created","comment":{"url":"https://api.github.com/repos/K2NE/K2NEServiceBroker/pulls/comments/93650606","pull_request_review_id":14182997,"id":93650606,"diff_hunk":"@@ -0,0 +1,133 @@\n+﻿using System;\n+using System.Collections.Generic;\n+using System.Linq;\n+using System.Text;\n+using System.Collections.ObjectModel;\n+using System.IO;\n+\n+namespace K2Field.K2NE.ServiceBroker.Helpers.PowerShell\n+{\n+    public static class PowerShellHelper\n+    {\n+        public static string RunScript(string powerShellScript, List<PowerShellVariablesDC> variablesList)\n+        {\n+            try\n+            {\n+                using (System.Management.Automation.PowerShell powerShellInstance = System.Management.Automation.PowerShell.Create())\n+                {\n+                    //set input variables\n+                    foreach (PowerShellVariablesDC variable in variablesList)\n+                    {\n+                        powerShellInstance.Runspace.SessionStateProxy.SetVariable(variable.Name, variable.Value);\n+                    }                    \n+\n+                    powerShellInstance.AddScript(powerShellScript);\n+                    \n+                    // begin invoke execution on the pipeline\n+                    Collection<System.Management.Automation.PSObject> returnValue = powerShellInstance.Invoke();\n+\n+                    //get input variables\n+                    foreach (PowerShellVariablesDC variable in variablesList)\n+                    {\n+                        variable.Value = powerShellInstance.Runspace.SessionStateProxy.GetVariable(variable.Name);\n+                    }\n+\n+                    return GetScriptOutput(returnValue);\n+                }\n+            }\n+            catch (Exception ex)\n+            {\n+                throw ex;\n+            }\n+        }\n+\n+        private static string GetScriptOutput(Collection<System.Management.Automation.PSObject> psObjectValues)\n+        {\n+            StringBuilder stringBuilder = new StringBuilder();\n+            foreach (System.Management.Automation.PSObject obj in psObjectValues)\n+            {\n+                stringBuilder.AppendLine(obj.ToString());\n+            }\n+            return stringBuilder.ToString();\n+        }\n+\n+        #region Directory interaction\n+        \n+        public static string LoadScriptByPath(string filePath)\n+        {\n+            try\n+            {\n+                // Create an instance of StreamReader to read from our file. \n+                // The using statement also closes the StreamReader. \n+                using (StreamReader sr = new StreamReader(filePath))\n+                {\n+\n+                    // use a string builder to get all our lines from the file \n+                    StringBuilder fileContents = new StringBuilder();\n+\n+                    // string to hold the current line \n+                    string curLine;\n+\n+                    // loop through our file and read each line into our \n+                    // stringbuilder as we go along \n+                    while ((curLine = sr.ReadLine()) != null)\n+                    {\n+                        // read each line and MAKE SURE YOU ADD BACK THE \n+                        // LINEFEED THAT IT THE ReadLine() METHOD STRIPS OFF \n+                        fileContents.Append(curLine + \"\\n\");\n+                    }\n+\n+                    // call RunScript and pass in our file contents \n+                    // converted to a string \n+                    return fileContents.ToString();\n+                }\n+            }\n+            catch (Exception e)\n+            {\n+                // Let the user know what went wrong. \n+                string errorText = \"The file could not be read:\";\n+                errorText += e.Message + \"\\n\";\n+                throw new Exception(errorText);\n+            }\n+        }\n+\n+        public static Dictionary<string, string> GetFilePathsFromDirectories(string folderNames)\n+        {\n+            Dictionary<string, string> scriptFiles = new Dictionary<string, string>();\n+\n+            foreach (string folderName in folderNames.Split(';'))\n+            {\n+                if (folderName.Contains(':'))\n+                    continue;\n+\n+                string fullFolderPath = GetServiceBrokerDirectory() + folderName.Trim('.').Trim('\\\\');\n+\n+                if (Directory.Exists(fullFolderPath))\n+                {\n+                    string[] scriptFilePaths = Directory.GetFiles(fullFolderPath)\n+                                .Where(s => Path.GetExtension(s).Equals(\".ps1\")).ToArray();\n+\n+                    foreach (string scriptFilePath in scriptFilePaths)\n+                    {\n+                        string fileName = Path.GetFileNameWithoutExtension(scriptFilePath);\n+                        scriptFiles.Add(fileName, scriptFilePath);\n+                    }\n+                }\n+                else\n+                {\n+                    Directory.CreateDirectory(fullFolderPath);","path":"K2Field.K2NE.ServiceBroker/Helpers/PowerShell/PowerShellHelper.cs","position":111,"original_position":118,"commit_id":"a2b0a1903dca7402854080f1ef39ee341e80521e","original_commit_id":"f2288915b9f1808f475c4e50b3e70dfb418113c6","user":{"login":"KonstantinBondarchuk","id":12746478,"avatar_url":"https://avatars.githubusercontent.com/u/12746478?v=3","gravatar_id":"","url":"https://api.github.com/users/KonstantinBondarchuk","html_url":"https://github.com/KonstantinBondarchuk","followers_url":"https://api.github.com/users/KonstantinBondarchuk/followers","following_url":"https://api.github.com/users/KonstantinBondarchuk/following{/other_user}","gists_url":"https://api.github.com/users/KonstantinBondarchuk/gists{/gist_id}","starred_url":"https://api.github.com/users/KonstantinBondarchuk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/KonstantinBondarchuk/subscriptions","organizations_url":"https://api.github.com/users/KonstantinBondarchuk/orgs","repos_url":"https://api.github.com/users/KonstantinBondarchuk/repos","events_url":"https://api.github.com/users/KonstantinBondarchuk/events{/privacy}","received_events_url":"https://api.github.com/users/KonstantinBondarchuk/received_events","type":"User","site_admin":false},"body":"done.","created_at":"2016-12-22T16:12:27Z","updated_at":"2016-12-22T16:12:27Z","html_url":"https://github.com/K2NE/K2NEServiceBroker/pull/81#discussion_r93650606","pull_request_url":"https://api.github.com/repos/K2NE/K2NEServiceBroker/pulls/81","_links":{"self":{"href":"https://api.github.com/repos/K2NE/K2NEServiceBroker/pulls/comments/93650606"},"html":{"href":"https://github.com/K2NE/K2NEServiceBroker/pull/81#discussion_r93650606"},"pull_request":{"href":"https://api.github.com/repos/K2NE/K2NEServiceBroker/pulls/81"}}},"pull_request":{"url":"https://api.github.com/repos/K2NE/K2NEServiceBroker/pulls/81","id":99080452,"html_url":"https://github.com/K2NE/K2NEServiceBroker/pull/81","diff_url":"https://github.com/K2NE/K2NEServiceBroker/pull/81.diff","patch_url":"https://github.com/K2NE/K2NEServiceBroker/pull/81.patch","issue_url":"https://api.github.com/repos/K2NE/K2NEServiceBroker/issues/81","number":81,"state":"open","locked":false,"title":"Add PowerShell functionality","user":{"login":"KonstantinBondarchuk","id":12746478,"avatar_url":"https://avatars.githubusercontent.com/u/12746478?v=3","gravatar_id":"","url":"https://api.github.com/users/KonstantinBondarchuk","html_url":"https://github.com/KonstantinBondarchuk","followers_url":"https://api.github.com/users/KonstantinBondarchuk/followers","following_url":"https://api.github.com/users/KonstantinBondarchuk/following{/other_user}","gists_url":"https://api.github.com/users/KonstantinBondarchuk/gists{/gist_id}","starred_url":"https://api.github.com/users/KonstantinBondarchuk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/KonstantinBondarchuk/subscriptions","organizations_url":"https://api.github.com/users/KonstantinBondarchuk/orgs","repos_url":"https://api.github.com/users/KonstantinBondarchuk/repos","events_url":"https://api.github.com/users/KonstantinBondarchuk/events{/privacy}","received_events_url":"https://api.github.com/users/KonstantinBondarchuk/received_events","type":"User","site_admin":false},"body":"Add PowershellVariablesSO, SimplePowerShellSO and DynamicPowerShellSO\r\nservice objects and all needed helpers.","created_at":"2016-12-22T10:24:34Z","updated_at":"2016-12-22T16:12:27Z","closed_at":null,"merged_at":null,"merge_commit_sha":"32ae9c8e16ba2e8ccd122f2deabf32ecf9e6b9ae","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/K2NE/K2NEServiceBroker/pulls/81/commits","review_comments_url":"https://api.github.com/repos/K2NE/K2NEServiceBroker/pulls/81/comments","review_comment_url":"https://api.github.com/repos/K2NE/K2NEServiceBroker/pulls/comments{/number}","comments_url":"https://api.github.com/repos/K2NE/K2NEServiceBroker/issues/81/comments","statuses_url":"https://api.github.com/repos/K2NE/K2NEServiceBroker/statuses/a2b0a1903dca7402854080f1ef39ee341e80521e","head":{"label":"KonstantinBondarchuk:master","ref":"master","sha":"a2b0a1903dca7402854080f1ef39ee341e80521e","user":{"login":"KonstantinBondarchuk","id":12746478,"avatar_url":"https://avatars.githubusercontent.com/u/12746478?v=3","gravatar_id":"","url":"https://api.github.com/users/KonstantinBondarchuk","html_url":"https://github.com/KonstantinBondarchuk","followers_url":"https://api.github.com/users/KonstantinBondarchuk/followers","following_url":"https://api.github.com/users/KonstantinBondarchuk/following{/other_user}","gists_url":"https://api.github.com/users/KonstantinBondarchuk/gists{/gist_id}","starred_url":"https://api.github.com/users/KonstantinBondarchuk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/KonstantinBondarchuk/subscriptions","organizations_url":"https://api.github.com/users/KonstantinBondarchuk/orgs","repos_url":"https://api.github.com/users/KonstantinBondarchuk/repos","events_url":"https://api.github.com/users/KonstantinBondarchuk/events{/privacy}","received_events_url":"https://api.github.com/users/KonstantinBondarchuk/received_events","type":"User","site_admin":false},"repo":{"id":77133029,"name":"K2NEServiceBroker","full_name":"KonstantinBondarchuk/K2NEServiceBroker","owner":{"login":"KonstantinBondarchuk","id":12746478,"avatar_url":"https://avatars.githubusercontent.com/u/12746478?v=3","gravatar_id":"","url":"https://api.github.com/users/KonstantinBondarchuk","html_url":"https://github.com/KonstantinBondarchuk","followers_url":"https://api.github.com/users/KonstantinBondarchuk/followers","following_url":"https://api.github.com/users/KonstantinBondarchuk/following{/other_user}","gists_url":"https://api.github.com/users/KonstantinBondarchuk/gists{/gist_id}","starred_url":"https://api.github.com/users/KonstantinBondarchuk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/KonstantinBondarchuk/subscriptions","organizations_url":"https://api.github.com/users/KonstantinBondarchuk/orgs","repos_url":"https://api.github.com/users/KonstantinBondarchuk/repos","events_url":"https://api.github.com/users/KonstantinBondarchuk/events{/privacy}","received_events_url":"https://api.github.com/users/KonstantinBondarchuk/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/KonstantinBondarchuk/K2NEServiceBroker","description":"The k2NE Service Broker","fork":true,"url":"https://api.github.com/repos/KonstantinBondarchuk/K2NEServiceBroker","forks_url":"https://api.github.com/repos/KonstantinBondarchuk/K2NEServiceBroker/forks","keys_url":"https://api.github.com/repos/KonstantinBondarchuk/K2NEServiceBroker/keys{/key_id}","collaborators_url":"https://api.github.com/repos/KonstantinBondarchuk/K2NEServiceBroker/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/KonstantinBondarchuk/K2NEServiceBroker/teams","hooks_url":"https://api.github.com/repos/KonstantinBondarchuk/K2NEServiceBroker/hooks","issue_events_url":"https://api.github.com/repos/KonstantinBondarchuk/K2NEServiceBroker/issues/events{/number}","events_url":"https://api.github.com/repos/KonstantinBondarchuk/K2NEServiceBroker/events","assignees_url":"https://api.github.com/repos/KonstantinBondarchuk/K2NEServiceBroker/assignees{/user}","branches_url":"https://api.github.com/repos/KonstantinBondarchuk/K2NEServiceBroker/branches{/branch}","tags_url":"https://api.github.com/repos/KonstantinBondarchuk/K2NEServiceBroker/tags","blobs_url":"https://api.github.com/repos/KonstantinBondarchuk/K2NEServiceBroker/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/KonstantinBondarchuk/K2NEServiceBroker/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/KonstantinBondarchuk/K2NEServiceBroker/git/refs{/sha}","trees_url":"https://api.github.com/repos/KonstantinBondarchuk/K2NEServiceBroker/git/trees{/sha}","statuses_url":"https://api.github.com/repos/KonstantinBondarchuk/K2NEServiceBroker/statuses/{sha}","languages_url":"https://api.github.com/repos/KonstantinBondarchuk/K2NEServiceBroker/languages","stargazers_url":"https://api.github.com/repos/KonstantinBondarchuk/K2NEServiceBroker/stargazers","contributors_url":"https://api.github.com/repos/KonstantinBondarchuk/K2NEServiceBroker/contributors","subscribers_url":"https://api.github.com/repos/KonstantinBondarchuk/K2NEServiceBroker/subscribers","subscription_url":"https://api.github.com/repos/KonstantinBondarchuk/K2NEServiceBroker/subscription","commits_url":"https://api.github.com/repos/KonstantinBondarchuk/K2NEServiceBroker/commits{/sha}","git_commits_url":"https://api.github.com/repos/KonstantinBondarchuk/K2NEServiceBroker/git/commits{/sha}","comments_url":"https://api.github.com/repos/KonstantinBondarchuk/K2NEServiceBroker/comments{/number}","issue_comment_url":"https://api.github.com/repos/KonstantinBondarchuk/K2NEServiceBroker/issues/comments{/number}","contents_url":"https://api.github.com/repos/KonstantinBondarchuk/K2NEServiceBroker/contents/{+path}","compare_url":"https://api.github.com/repos/KonstantinBondarchuk/K2NEServiceBroker/compare/{base}...{head}","merges_url":"https://api.github.com/repos/KonstantinBondarchuk/K2NEServiceBroker/merges","archive_url":"https://api.github.com/repos/KonstantinBondarchuk/K2NEServiceBroker/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/KonstantinBondarchuk/K2NEServiceBroker/downloads","issues_url":"https://api.github.com/repos/KonstantinBondarchuk/K2NEServiceBroker/issues{/number}","pulls_url":"https://api.github.com/repos/KonstantinBondarchuk/K2NEServiceBroker/pulls{/number}","milestones_url":"https://api.github.com/repos/KonstantinBondarchuk/K2NEServiceBroker/milestones{/number}","notifications_url":"https://api.github.com/repos/KonstantinBondarchuk/K2NEServiceBroker/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/KonstantinBondarchuk/K2NEServiceBroker/labels{/name}","releases_url":"https://api.github.com/repos/KonstantinBondarchuk/K2NEServiceBroker/releases{/id}","deployments_url":"https://api.github.com/repos/KonstantinBondarchuk/K2NEServiceBroker/deployments","created_at":"2016-12-22T09:50:42Z","updated_at":"2016-12-22T09:50:44Z","pushed_at":"2016-12-22T15:37:50Z","git_url":"git://github.com/KonstantinBondarchuk/K2NEServiceBroker.git","ssh_url":"git@github.com:KonstantinBondarchuk/K2NEServiceBroker.git","clone_url":"https://github.com/KonstantinBondarchuk/K2NEServiceBroker.git","svn_url":"https://github.com/KonstantinBondarchuk/K2NEServiceBroker","homepage":null,"size":480,"stargazers_count":0,"watchers_count":0,"language":"C#","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"K2NE:master","ref":"master","sha":"6feee92a857eae6497ddac76e5d89438e22da4b4","user":{"login":"K2NE","id":10414606,"avatar_url":"https://avatars.githubusercontent.com/u/10414606?v=3","gravatar_id":"","url":"https://api.github.com/users/K2NE","html_url":"https://github.com/K2NE","followers_url":"https://api.github.com/users/K2NE/followers","following_url":"https://api.github.com/users/K2NE/following{/other_user}","gists_url":"https://api.github.com/users/K2NE/gists{/gist_id}","starred_url":"https://api.github.com/users/K2NE/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/K2NE/subscriptions","organizations_url":"https://api.github.com/users/K2NE/orgs","repos_url":"https://api.github.com/users/K2NE/repos","events_url":"https://api.github.com/users/K2NE/events{/privacy}","received_events_url":"https://api.github.com/users/K2NE/received_events","type":"Organization","site_admin":false},"repo":{"id":30723169,"name":"K2NEServiceBroker","full_name":"K2NE/K2NEServiceBroker","owner":{"login":"K2NE","id":10414606,"avatar_url":"https://avatars.githubusercontent.com/u/10414606?v=3","gravatar_id":"","url":"https://api.github.com/users/K2NE","html_url":"https://github.com/K2NE","followers_url":"https://api.github.com/users/K2NE/followers","following_url":"https://api.github.com/users/K2NE/following{/other_user}","gists_url":"https://api.github.com/users/K2NE/gists{/gist_id}","starred_url":"https://api.github.com/users/K2NE/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/K2NE/subscriptions","organizations_url":"https://api.github.com/users/K2NE/orgs","repos_url":"https://api.github.com/users/K2NE/repos","events_url":"https://api.github.com/users/K2NE/events{/privacy}","received_events_url":"https://api.github.com/users/K2NE/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/K2NE/K2NEServiceBroker","description":"The k2NE Service Broker","fork":false,"url":"https://api.github.com/repos/K2NE/K2NEServiceBroker","forks_url":"https://api.github.com/repos/K2NE/K2NEServiceBroker/forks","keys_url":"https://api.github.com/repos/K2NE/K2NEServiceBroker/keys{/key_id}","collaborators_url":"https://api.github.com/repos/K2NE/K2NEServiceBroker/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/K2NE/K2NEServiceBroker/teams","hooks_url":"https://api.github.com/repos/K2NE/K2NEServiceBroker/hooks","issue_events_url":"https://api.github.com/repos/K2NE/K2NEServiceBroker/issues/events{/number}","events_url":"https://api.github.com/repos/K2NE/K2NEServiceBroker/events","assignees_url":"https://api.github.com/repos/K2NE/K2NEServiceBroker/assignees{/user}","branches_url":"https://api.github.com/repos/K2NE/K2NEServiceBroker/branches{/branch}","tags_url":"https://api.github.com/repos/K2NE/K2NEServiceBroker/tags","blobs_url":"https://api.github.com/repos/K2NE/K2NEServiceBroker/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/K2NE/K2NEServiceBroker/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/K2NE/K2NEServiceBroker/git/refs{/sha}","trees_url":"https://api.github.com/repos/K2NE/K2NEServiceBroker/git/trees{/sha}","statuses_url":"https://api.github.com/repos/K2NE/K2NEServiceBroker/statuses/{sha}","languages_url":"https://api.github.com/repos/K2NE/K2NEServiceBroker/languages","stargazers_url":"https://api.github.com/repos/K2NE/K2NEServiceBroker/stargazers","contributors_url":"https://api.github.com/repos/K2NE/K2NEServiceBroker/contributors","subscribers_url":"https://api.github.com/repos/K2NE/K2NEServiceBroker/subscribers","subscription_url":"https://api.github.com/repos/K2NE/K2NEServiceBroker/subscription","commits_url":"https://api.github.com/repos/K2NE/K2NEServiceBroker/commits{/sha}","git_commits_url":"https://api.github.com/repos/K2NE/K2NEServiceBroker/git/commits{/sha}","comments_url":"https://api.github.com/repos/K2NE/K2NEServiceBroker/comments{/number}","issue_comment_url":"https://api.github.com/repos/K2NE/K2NEServiceBroker/issues/comments{/number}","contents_url":"https://api.github.com/repos/K2NE/K2NEServiceBroker/contents/{+path}","compare_url":"https://api.github.com/repos/K2NE/K2NEServiceBroker/compare/{base}...{head}","merges_url":"https://api.github.com/repos/K2NE/K2NEServiceBroker/merges","archive_url":"https://api.github.com/repos/K2NE/K2NEServiceBroker/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/K2NE/K2NEServiceBroker/downloads","issues_url":"https://api.github.com/repos/K2NE/K2NEServiceBroker/issues{/number}","pulls_url":"https://api.github.com/repos/K2NE/K2NEServiceBroker/pulls{/number}","milestones_url":"https://api.github.com/repos/K2NE/K2NEServiceBroker/milestones{/number}","notifications_url":"https://api.github.com/repos/K2NE/K2NEServiceBroker/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/K2NE/K2NEServiceBroker/labels{/name}","releases_url":"https://api.github.com/repos/K2NE/K2NEServiceBroker/releases{/id}","deployments_url":"https://api.github.com/repos/K2NE/K2NEServiceBroker/deployments","created_at":"2015-02-12T20:49:20Z","updated_at":"2016-11-07T09:14:29Z","pushed_at":"2016-12-22T15:37:51Z","git_url":"git://github.com/K2NE/K2NEServiceBroker.git","ssh_url":"git@github.com:K2NE/K2NEServiceBroker.git","clone_url":"https://github.com/K2NE/K2NEServiceBroker.git","svn_url":"https://github.com/K2NE/K2NEServiceBroker","homepage":null,"size":471,"stargazers_count":4,"watchers_count":4,"language":"C#","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":12,"mirror_url":null,"open_issues_count":23,"forks":12,"open_issues":23,"watchers":4,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/K2NE/K2NEServiceBroker/pulls/81"},"html":{"href":"https://github.com/K2NE/K2NEServiceBroker/pull/81"},"issue":{"href":"https://api.github.com/repos/K2NE/K2NEServiceBroker/issues/81"},"comments":{"href":"https://api.github.com/repos/K2NE/K2NEServiceBroker/issues/81/comments"},"review_comments":{"href":"https://api.github.com/repos/K2NE/K2NEServiceBroker/pulls/81/comments"},"review_comment":{"href":"https://api.github.com/repos/K2NE/K2NEServiceBroker/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/K2NE/K2NEServiceBroker/pulls/81/commits"},"statuses":{"href":"https://api.github.com/repos/K2NE/K2NEServiceBroker/statuses/a2b0a1903dca7402854080f1ef39ee341e80521e"}}}}
{"actor":{"display_login":"KonstantinBondarchuk"}}