{"action":"created","comment":{"url":"https://api.github.com/repos/Azure/azure-devtestlab/pulls/comments/121723453","pull_request_review_id":43773661,"id":121723453,"diff_hunk":"@@ -1,148 +1,293 @@\n # Downloads the Visual Studio Online Build Agent, installs on the new machine, registers with the Visual\r\n # Studio Online account, and adds to the specified build agent pool\r\n-\r\n [CmdletBinding()]\r\n-Param(\r\n-    [Parameter(Mandatory=$true)]\r\n-    [ValidateNotNullOrEmpty()]\r\n-    $vstsAccount,\r\n-    \r\n-    [Parameter(Mandatory=$true)]\r\n-    [ValidateNotNullOrEmpty()]\r\n-    $vstsUserPassword,\r\n-    \r\n-    [Parameter(Mandatory=$true)]\r\n-    [ValidateNotNullOrEmpty()]\r\n-    $agentName,\r\n-    \r\n-    [Parameter(Mandatory=$true)]\r\n-    [ValidateNotNullOrEmpty()]\r\n-    $poolname,\r\n-\r\n-    [Parameter(Mandatory=$true)]\r\n-    [ValidateNotNullOrEmpty()]\r\n-    $windowsLogonAccount,\r\n-\r\n-    [Parameter(Mandatory=$true)]\r\n-    [AllowEmptyString()]\r\n-    $windowsLogonPassword,\r\n-    \r\n-    [Parameter(Mandatory=$true)]\r\n+param(\r\n+    [string] $vstsAccount,\r\n+    [string] $vstsUserPassword,\r\n+    [string] $agentName,\r\n+    [string] $poolname,\r\n+    [string] $windowsLogonAccount,\r\n+    [string] $windowsLogonPassword,\r\n     [ValidatePattern(\"[c-zC-Z]\")]\r\n     [ValidateLength(1, 1)]\r\n-    [String]$driveLetter,\r\n-    \r\n-    [Parameter(Mandatory=$true)]\r\n-    [AllowEmptyString()]\r\n-    $workDirectory\r\n+    [string] $driveLetter,\r\n+    [string] $workDirectory\r\n )\r\n \r\n+###################################################################################################\r\n+\r\n+#\r\n+# PowerShell configurations\r\n+#\r\n+\r\n+# NOTE: Because the $ErrorActionPreference is \"Stop\", this script will stop on first failure.\r\n+#       This is necessary to ensure we capture errors inside the try-catch-finally block.\r\n $ErrorActionPreference = \"Stop\"\r\n \r\n-trap\r\n+# Ensure we set the working directory to that of the script.\r\n+pushd $PSScriptRoot\r\n+\r\n+# Configure strict debugging.\r\n+Set-PSDebug -Strict\r\n+\r\n+###################################################################################################\r\n+\r\n+#\r\n+# Functions used in this script.\r\n+#\r\n+\r\n+function Handle-LastError\r\n {\r\n-    $_ | Write-Error -ErrorAction Continue\r\n-    exit 1\r\n+    [CmdletBinding()]\r\n+    param(\r\n+    )\r\n+\r\n+    $message = $error[0].Exception.Message\r\n+    if ($message)\r\n+    {\r\n+        Write-Host -Object \"ERROR: $message\" -ForegroundColor Red\r\n+    }\r\n+    \r\n+    # IMPORTANT NOTE: Throwing a terminating error (using $ErrorActionPreference = \"Stop\") still\r\n+    # returns exit code zero from the PowerShell script when using -File. The workaround is to\r\n+    # NOT use -File when calling this script and leverage the try-catch-finally block and return\r\n+    # a non-zero exit code from the catch block.\r\n+    exit -1\r\n }\r\n \r\n-if ($vstsAccount -match \"https*://\" -or $vstsAccount -match \"visualstudio.com\")\r\n+function Test-Parameters\r\n {\r\n-    Write-Error \"VSTS account should not be the URL, just the account name.\"\r\n+    [CmdletBinding()]\r\n+    param(\r\n+        [string] $VstsAccount,\r\n+        [string] $WorkDirectory\r\n+    )\r\n+    \r\n+    if ($VstsAccount -match \"https*://\" -or $VstsAccount -match \"visualstudio.com\")\r\n+    {\r\n+        Write-Error \"VSTS account '$VstsAccount' should not be the URL, just the account name.\"\r\n+    }\r\n+\r\n+    if (![string]::IsNullOrWhiteSpace($WorkDirectory) -and !(Test-ValidPath -Path $WorkDirectory))\r\n+    {\r\n+        Write-Error \"Work directory '$WorkDirectory' is not a valid path.\"\r\n+    }\r\n }\r\n \r\n-if ($workDirectory -ne \"\" -and !(Test-Path -Path $workDirectory -IsValid -ErrorAction Ignore))\r\n+function Test-ValidPath\r\n {\r\n-    Write-Error \"Work Directory '$workDirectory' is not a valid path.\"\r\n+    param(\r\n+        [string] $Path\r\n+    )\r\n+    \r\n+    $isValid = Test-Path -Path $Path -IsValid -PathType Container\r\n+    \r\n+    try\r\n+    {\r\n+        [IO.Path]::GetFullPath($workDirectory) | Out-Null\r","path":"Artifacts/windows-vsts-build-agent/vsts-agent-install.ps1","position":126,"original_position":126,"commit_id":"da7672fb7031b2d1a9b36420fc9487eaa017c9ff","original_commit_id":"da7672fb7031b2d1a9b36420fc9487eaa017c9ff","user":{"login":"joerage","id":14829176,"avatar_url":"https://avatars3.githubusercontent.com/u/14829176?v=3","gravatar_id":"","url":"https://api.github.com/users/joerage","html_url":"https://github.com/joerage","followers_url":"https://api.github.com/users/joerage/followers","following_url":"https://api.github.com/users/joerage/following{/other_user}","gists_url":"https://api.github.com/users/joerage/gists{/gist_id}","starred_url":"https://api.github.com/users/joerage/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/joerage/subscriptions","organizations_url":"https://api.github.com/users/joerage/orgs","repos_url":"https://api.github.com/users/joerage/repos","events_url":"https://api.github.com/users/joerage/events{/privacy}","received_events_url":"https://api.github.com/users/joerage/received_events","type":"User","site_admin":false},"body":"Where is this coming from?","created_at":"2017-06-13T16:06:22Z","updated_at":"2017-06-13T16:23:29Z","html_url":"https://github.com/Azure/azure-devtestlab/pull/247#discussion_r121723453","pull_request_url":"https://api.github.com/repos/Azure/azure-devtestlab/pulls/247","_links":{"self":{"href":"https://api.github.com/repos/Azure/azure-devtestlab/pulls/comments/121723453"},"html":{"href":"https://github.com/Azure/azure-devtestlab/pull/247#discussion_r121723453"},"pull_request":{"href":"https://api.github.com/repos/Azure/azure-devtestlab/pulls/247"}}},"pull_request":{"url":"https://api.github.com/repos/Azure/azure-devtestlab/pulls/247","id":125400907,"html_url":"https://github.com/Azure/azure-devtestlab/pull/247","diff_url":"https://github.com/Azure/azure-devtestlab/pull/247.diff","patch_url":"https://github.com/Azure/azure-devtestlab/pull/247.patch","issue_url":"https://api.github.com/repos/Azure/azure-devtestlab/issues/247","number":247,"state":"open","locked":false,"title":"Fixing artifact structure","user":{"login":"leovms","id":14631204,"avatar_url":"https://avatars3.githubusercontent.com/u/14631204?v=3","gravatar_id":"","url":"https://api.github.com/users/leovms","html_url":"https://github.com/leovms","followers_url":"https://api.github.com/users/leovms/followers","following_url":"https://api.github.com/users/leovms/following{/other_user}","gists_url":"https://api.github.com/users/leovms/gists{/gist_id}","starred_url":"https://api.github.com/users/leovms/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/leovms/subscriptions","organizations_url":"https://api.github.com/users/leovms/orgs","repos_url":"https://api.github.com/users/leovms/repos","events_url":"https://api.github.com/users/leovms/events{/privacy}","received_events_url":"https://api.github.com/users/leovms/received_events","type":"User","site_admin":false},"body":"- Updating artifact structure to correctly bubble up errors and provide step updates.\r\n- Refactored into more manageable functions.","created_at":"2017-06-13T15:59:10Z","updated_at":"2017-06-13T16:23:29Z","closed_at":null,"merged_at":null,"merge_commit_sha":"4cbfa4223618c3f8d69b25bf048001d071a1c728","assignee":null,"assignees":[],"requested_reviewers":[],"milestone":null,"commits_url":"https://api.github.com/repos/Azure/azure-devtestlab/pulls/247/commits","review_comments_url":"https://api.github.com/repos/Azure/azure-devtestlab/pulls/247/comments","review_comment_url":"https://api.github.com/repos/Azure/azure-devtestlab/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Azure/azure-devtestlab/issues/247/comments","statuses_url":"https://api.github.com/repos/Azure/azure-devtestlab/statuses/da7672fb7031b2d1a9b36420fc9487eaa017c9ff","head":{"label":"leovms:master","ref":"master","sha":"da7672fb7031b2d1a9b36420fc9487eaa017c9ff","user":{"login":"leovms","id":14631204,"avatar_url":"https://avatars3.githubusercontent.com/u/14631204?v=3","gravatar_id":"","url":"https://api.github.com/users/leovms","html_url":"https://github.com/leovms","followers_url":"https://api.github.com/users/leovms/followers","following_url":"https://api.github.com/users/leovms/following{/other_user}","gists_url":"https://api.github.com/users/leovms/gists{/gist_id}","starred_url":"https://api.github.com/users/leovms/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/leovms/subscriptions","organizations_url":"https://api.github.com/users/leovms/orgs","repos_url":"https://api.github.com/users/leovms/repos","events_url":"https://api.github.com/users/leovms/events{/privacy}","received_events_url":"https://api.github.com/users/leovms/received_events","type":"User","site_admin":false},"repo":{"id":93896689,"name":"azure-devtestlab","full_name":"leovms/azure-devtestlab","owner":{"login":"leovms","id":14631204,"avatar_url":"https://avatars3.githubusercontent.com/u/14631204?v=3","gravatar_id":"","url":"https://api.github.com/users/leovms","html_url":"https://github.com/leovms","followers_url":"https://api.github.com/users/leovms/followers","following_url":"https://api.github.com/users/leovms/following{/other_user}","gists_url":"https://api.github.com/users/leovms/gists{/gist_id}","starred_url":"https://api.github.com/users/leovms/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/leovms/subscriptions","organizations_url":"https://api.github.com/users/leovms/orgs","repos_url":"https://api.github.com/users/leovms/repos","events_url":"https://api.github.com/users/leovms/events{/privacy}","received_events_url":"https://api.github.com/users/leovms/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/leovms/azure-devtestlab","description":"Azure DevTestLab artifacts, scripts and samples","fork":true,"url":"https://api.github.com/repos/leovms/azure-devtestlab","forks_url":"https://api.github.com/repos/leovms/azure-devtestlab/forks","keys_url":"https://api.github.com/repos/leovms/azure-devtestlab/keys{/key_id}","collaborators_url":"https://api.github.com/repos/leovms/azure-devtestlab/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/leovms/azure-devtestlab/teams","hooks_url":"https://api.github.com/repos/leovms/azure-devtestlab/hooks","issue_events_url":"https://api.github.com/repos/leovms/azure-devtestlab/issues/events{/number}","events_url":"https://api.github.com/repos/leovms/azure-devtestlab/events","assignees_url":"https://api.github.com/repos/leovms/azure-devtestlab/assignees{/user}","branches_url":"https://api.github.com/repos/leovms/azure-devtestlab/branches{/branch}","tags_url":"https://api.github.com/repos/leovms/azure-devtestlab/tags","blobs_url":"https://api.github.com/repos/leovms/azure-devtestlab/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/leovms/azure-devtestlab/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/leovms/azure-devtestlab/git/refs{/sha}","trees_url":"https://api.github.com/repos/leovms/azure-devtestlab/git/trees{/sha}","statuses_url":"https://api.github.com/repos/leovms/azure-devtestlab/statuses/{sha}","languages_url":"https://api.github.com/repos/leovms/azure-devtestlab/languages","stargazers_url":"https://api.github.com/repos/leovms/azure-devtestlab/stargazers","contributors_url":"https://api.github.com/repos/leovms/azure-devtestlab/contributors","subscribers_url":"https://api.github.com/repos/leovms/azure-devtestlab/subscribers","subscription_url":"https://api.github.com/repos/leovms/azure-devtestlab/subscription","commits_url":"https://api.github.com/repos/leovms/azure-devtestlab/commits{/sha}","git_commits_url":"https://api.github.com/repos/leovms/azure-devtestlab/git/commits{/sha}","comments_url":"https://api.github.com/repos/leovms/azure-devtestlab/comments{/number}","issue_comment_url":"https://api.github.com/repos/leovms/azure-devtestlab/issues/comments{/number}","contents_url":"https://api.github.com/repos/leovms/azure-devtestlab/contents/{+path}","compare_url":"https://api.github.com/repos/leovms/azure-devtestlab/compare/{base}...{head}","merges_url":"https://api.github.com/repos/leovms/azure-devtestlab/merges","archive_url":"https://api.github.com/repos/leovms/azure-devtestlab/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/leovms/azure-devtestlab/downloads","issues_url":"https://api.github.com/repos/leovms/azure-devtestlab/issues{/number}","pulls_url":"https://api.github.com/repos/leovms/azure-devtestlab/pulls{/number}","milestones_url":"https://api.github.com/repos/leovms/azure-devtestlab/milestones{/number}","notifications_url":"https://api.github.com/repos/leovms/azure-devtestlab/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/leovms/azure-devtestlab/labels{/name}","releases_url":"https://api.github.com/repos/leovms/azure-devtestlab/releases{/id}","deployments_url":"https://api.github.com/repos/leovms/azure-devtestlab/deployments","created_at":"2017-06-09T21:03:59Z","updated_at":"2017-06-09T21:04:01Z","pushed_at":"2017-06-13T15:57:02Z","git_url":"git://github.com/leovms/azure-devtestlab.git","ssh_url":"git@github.com:leovms/azure-devtestlab.git","clone_url":"https://github.com/leovms/azure-devtestlab.git","svn_url":"https://github.com/leovms/azure-devtestlab","homepage":null,"size":35458,"stargazers_count":0,"watchers_count":0,"language":"PowerShell","has_issues":false,"has_projects":true,"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":"Azure:master","ref":"master","sha":"9cfbd08fae3b805e646129181f8e8a1c475c3927","user":{"login":"Azure","id":6844498,"avatar_url":"https://avatars3.githubusercontent.com/u/6844498?v=3","gravatar_id":"","url":"https://api.github.com/users/Azure","html_url":"https://github.com/Azure","followers_url":"https://api.github.com/users/Azure/followers","following_url":"https://api.github.com/users/Azure/following{/other_user}","gists_url":"https://api.github.com/users/Azure/gists{/gist_id}","starred_url":"https://api.github.com/users/Azure/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Azure/subscriptions","organizations_url":"https://api.github.com/users/Azure/orgs","repos_url":"https://api.github.com/users/Azure/repos","events_url":"https://api.github.com/users/Azure/events{/privacy}","received_events_url":"https://api.github.com/users/Azure/received_events","type":"Organization","site_admin":false},"repo":{"id":42144605,"name":"azure-devtestlab","full_name":"Azure/azure-devtestlab","owner":{"login":"Azure","id":6844498,"avatar_url":"https://avatars3.githubusercontent.com/u/6844498?v=3","gravatar_id":"","url":"https://api.github.com/users/Azure","html_url":"https://github.com/Azure","followers_url":"https://api.github.com/users/Azure/followers","following_url":"https://api.github.com/users/Azure/following{/other_user}","gists_url":"https://api.github.com/users/Azure/gists{/gist_id}","starred_url":"https://api.github.com/users/Azure/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Azure/subscriptions","organizations_url":"https://api.github.com/users/Azure/orgs","repos_url":"https://api.github.com/users/Azure/repos","events_url":"https://api.github.com/users/Azure/events{/privacy}","received_events_url":"https://api.github.com/users/Azure/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Azure/azure-devtestlab","description":"Azure DevTestLab artifacts, scripts and samples","fork":false,"url":"https://api.github.com/repos/Azure/azure-devtestlab","forks_url":"https://api.github.com/repos/Azure/azure-devtestlab/forks","keys_url":"https://api.github.com/repos/Azure/azure-devtestlab/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Azure/azure-devtestlab/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Azure/azure-devtestlab/teams","hooks_url":"https://api.github.com/repos/Azure/azure-devtestlab/hooks","issue_events_url":"https://api.github.com/repos/Azure/azure-devtestlab/issues/events{/number}","events_url":"https://api.github.com/repos/Azure/azure-devtestlab/events","assignees_url":"https://api.github.com/repos/Azure/azure-devtestlab/assignees{/user}","branches_url":"https://api.github.com/repos/Azure/azure-devtestlab/branches{/branch}","tags_url":"https://api.github.com/repos/Azure/azure-devtestlab/tags","blobs_url":"https://api.github.com/repos/Azure/azure-devtestlab/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Azure/azure-devtestlab/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Azure/azure-devtestlab/git/refs{/sha}","trees_url":"https://api.github.com/repos/Azure/azure-devtestlab/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Azure/azure-devtestlab/statuses/{sha}","languages_url":"https://api.github.com/repos/Azure/azure-devtestlab/languages","stargazers_url":"https://api.github.com/repos/Azure/azure-devtestlab/stargazers","contributors_url":"https://api.github.com/repos/Azure/azure-devtestlab/contributors","subscribers_url":"https://api.github.com/repos/Azure/azure-devtestlab/subscribers","subscription_url":"https://api.github.com/repos/Azure/azure-devtestlab/subscription","commits_url":"https://api.github.com/repos/Azure/azure-devtestlab/commits{/sha}","git_commits_url":"https://api.github.com/repos/Azure/azure-devtestlab/git/commits{/sha}","comments_url":"https://api.github.com/repos/Azure/azure-devtestlab/comments{/number}","issue_comment_url":"https://api.github.com/repos/Azure/azure-devtestlab/issues/comments{/number}","contents_url":"https://api.github.com/repos/Azure/azure-devtestlab/contents/{+path}","compare_url":"https://api.github.com/repos/Azure/azure-devtestlab/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Azure/azure-devtestlab/merges","archive_url":"https://api.github.com/repos/Azure/azure-devtestlab/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Azure/azure-devtestlab/downloads","issues_url":"https://api.github.com/repos/Azure/azure-devtestlab/issues{/number}","pulls_url":"https://api.github.com/repos/Azure/azure-devtestlab/pulls{/number}","milestones_url":"https://api.github.com/repos/Azure/azure-devtestlab/milestones{/number}","notifications_url":"https://api.github.com/repos/Azure/azure-devtestlab/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Azure/azure-devtestlab/labels{/name}","releases_url":"https://api.github.com/repos/Azure/azure-devtestlab/releases{/id}","deployments_url":"https://api.github.com/repos/Azure/azure-devtestlab/deployments","created_at":"2015-09-08T23:32:52Z","updated_at":"2017-06-07T18:26:09Z","pushed_at":"2017-06-13T15:59:11Z","git_url":"git://github.com/Azure/azure-devtestlab.git","ssh_url":"git@github.com:Azure/azure-devtestlab.git","clone_url":"https://github.com/Azure/azure-devtestlab.git","svn_url":"https://github.com/Azure/azure-devtestlab","homepage":null,"size":35481,"stargazers_count":100,"watchers_count":100,"language":"PowerShell","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":143,"mirror_url":null,"open_issues_count":12,"forks":143,"open_issues":12,"watchers":100,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/Azure/azure-devtestlab/pulls/247"},"html":{"href":"https://github.com/Azure/azure-devtestlab/pull/247"},"issue":{"href":"https://api.github.com/repos/Azure/azure-devtestlab/issues/247"},"comments":{"href":"https://api.github.com/repos/Azure/azure-devtestlab/issues/247/comments"},"review_comments":{"href":"https://api.github.com/repos/Azure/azure-devtestlab/pulls/247/comments"},"review_comment":{"href":"https://api.github.com/repos/Azure/azure-devtestlab/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Azure/azure-devtestlab/pulls/247/commits"},"statuses":{"href":"https://api.github.com/repos/Azure/azure-devtestlab/statuses/da7672fb7031b2d1a9b36420fc9487eaa017c9ff"}}}}
{"actor":{"display_login":"joerage"}}