{"action":"created","comment":{"url":"https://api.github.com/repos/vMotioned/PowerShell/pulls/comments/24474440","id":24474440,"diff_hunk":"@@ -77,96 +92,98 @@\n     Date:    08/29/2012\n     PSVer:   2.0/3.0\n     Updated: 05/30/2013\n-    UpdNote: \n+    UpdNote:\n #>\n \n-[CmdletBinding()]\n+[CmdletBinding(PositionalBinding = $true)]\n param (\n \t[Parameter(Position = 0,\n \t\t\t   ValueFromPipeline = $true,\n \t\t\t   ValueFromPipelineByPropertyName = $true)]\n-\t[Alias(\"CN\", \"Computer\")]\n-\t[String[]]$ComputerName = \"$env:COMPUTERNAME\",\n-\t\n-\t[parameter(Mandatory = $false,\n-\t\t\t   Position = 1)]\n-\t[String]$ErrorLog\n+\t[Alias('CN', 'Computer')]\n+\t[String[]]$ComputerName = \"$env:COMPUTERNAME\"\n )\n \n BEGIN {\n-\t# Adjusting ErrorActionPreference to stop on all errors, since using [Microsoft.Win32.RegistryKey]\n-\t# does not have a native ErrorAction Parameter, this may need to be changed if used within another\n-\t# function.\n-\t$TempErrAct = $ErrorActionPreference\n-\t$ErrorActionPreference = \"Stop\"\n-} # End BEGIN Script Block\n+\n+\t<# Adjusting ErrorActionPreference to stop on all errors, since using [Microsoft.Win32.RegistryKey]\n+\t does not have a native ErrorAction Parameter, this may need to be changed if used within another\n+\t function. #>\n+\t$defaultEAPref = $ErrorActionPreference\n+\t$ErrorActionPreference = 'Stop'\n+\n+} # end BEGIN block\n+\n PROCESS {\n-\tForeach ($Computer in $ComputerName) {\n-\t\tTry {\n+\n+\tforeach ($computer in $ComputerName) {\n+\n+\t\ttry {\n+\n \t\t\t# Setting pending values to false to cut down on the number of else statements\n-\t\t\t$PendFileRename, $Pending = $false, $false\n-\t\t\t\n-\t\t\t# Setting CBSRebootPend to null since not all versions of Windows has this value\n-\t\t\t$CBSRebootPend = $null\n-\t\t\t\n+\t\t\t[bool]$pendingFileRename = $false\n+\t\t\t[bool]$pending = $false\n+\n+\t\t\t# Setting cbsRebootPending to null since not all versions of Windows has this value\n+\t\t\t$cbsRebootPending = $null\n+\n \t\t\t# Querying WMI for build version\n-\t\t\t$WMI_OS = Get-WmiObject -Class Win32_OperatingSystem -Property BuildNumber, CSName -ComputerName $Computer\n-\t\t\t\n+\t\t\t$wmiWin32Os = Get-WmiObject -ComputerName $computer -Query 'SELECT BuildNumber,CSName FROM win32_OperatingSystem'\n+\n \t\t\t# Making registry connection to the local/remote computer\n-\t\t\t$RegCon = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey([Microsoft.Win32.RegistryHive]\"LocalMachine\", $Computer)\n-\t\t\t\n+\t\t\t$regConnection = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey([Microsoft.Win32.RegistryHive]'LocalMachine', $computer)\n+\n \t\t\t# If Vista/2008 & Above query the CBS Reg Key\n-\t\t\tIf ($WMI_OS.BuildNumber -ge 6001) {\n-\t\t\t\t$RegSubKeysCBS = $RegCon.OpenSubKey(\"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Component Based Servicing\\\").GetSubKeyNames()\n-\t\t\t\t$CBSRebootPend = $RegSubKeysCBS -contains \"RebootPending\"\n-\t\t\t\t\n-\t\t\t} #End If ($WMI_OS.BuildNumber -ge 6001)\n-\t\t\t\n+\t\t\tif ($wmiWin32Os.BuildNumber -ge 6001) {\n+\n+\t\t\t\t$regCbsSubkey = $regConnection.OpenSubKey('SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Component Based Servicing\\').GetSubKeyNames()\n+\t\t\t\t$cbsRebootPending = $regCbsSubkey -contains 'RebootPending'\n+\n+\t\t\t} #End if $wmiWin32Os.BuildNumber\n+\n \t\t\t# Query WUAU from the registry\n-\t\t\t$RegWUAU = $RegCon.OpenSubKey(\"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\WindowsUpdate\\Auto Update\\\")\n-\t\t\t$RegWUAURebootReq = $RegWUAU.GetSubKeyNames()\n-\t\t\t$WUAURebootReq = $RegWUAURebootReq -contains \"RebootRequired\"\n-\t\t\t\n+\t\t\t$regWindowsUpdate = $regConnection.OpenSubKey('SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\WindowsUpdate\\Auto Update\\')\n+\t\t\t$regWindowsUpdateKeys = $regWindowsUpdate.GetSubKeyNames()\n+\t\t\t$windowsUpdateRebootPending = $regWindowsUpdateKeys -contains 'RebootRequired'\n+\n \t\t\t# Query PendingFileRenameOperations from the registry\n-\t\t\t$RegSubKeySM = $RegCon.OpenSubKey(\"SYSTEM\\CurrentControlSet\\Control\\Session Manager\\\")\n-\t\t\t\n+\t\t\t$regPendingFileRename = $regConnection.OpenSubKey('SYSTEM\\CurrentControlSet\\Control\\Session Manager\\')\n+\t\t\t$regPFROQuery = $regPendingFileRename.GetValue('PendingFileRenameOperations', $null)","path":"Get-PendingReboot.ps1","position":202,"original_position":202,"commit_id":"bcd90ada248b883ad43e86e0cd17a758f99e13df","original_commit_id":"bcd90ada248b883ad43e86e0cd17a758f99e13df","user":{"login":"vScripter","id":3757585,"avatar_url":"https://avatars.githubusercontent.com/u/3757585?v=3","gravatar_id":"","url":"https://api.github.com/users/vScripter","html_url":"https://github.com/vScripter","followers_url":"https://api.github.com/users/vScripter/followers","following_url":"https://api.github.com/users/vScripter/following{/other_user}","gists_url":"https://api.github.com/users/vScripter/gists{/gist_id}","starred_url":"https://api.github.com/users/vScripter/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vScripter/subscriptions","organizations_url":"https://api.github.com/users/vScripter/orgs","repos_url":"https://api.github.com/users/vScripter/repos","events_url":"https://api.github.com/users/vScripter/events{/privacy}","received_events_url":"https://api.github.com/users/vScripter/received_events","type":"User","site_admin":false},"body":"This was the main change; line 151 did not exist, which was returning nothing, therefore leaving room for incorrect findings","created_at":"2015-02-11T04:50:50Z","updated_at":"2015-02-11T04:50:50Z","html_url":"https://github.com/vMotioned/PowerShell/pull/10#discussion_r24474440","pull_request_url":"https://api.github.com/repos/vMotioned/PowerShell/pulls/10","_links":{"self":{"href":"https://api.github.com/repos/vMotioned/PowerShell/pulls/comments/24474440"},"html":{"href":"https://github.com/vMotioned/PowerShell/pull/10#discussion_r24474440"},"pull_request":{"href":"https://api.github.com/repos/vMotioned/PowerShell/pulls/10"}}},"pull_request":{"url":"https://api.github.com/repos/vMotioned/PowerShell/pulls/10","id":29068169,"html_url":"https://github.com/vMotioned/PowerShell/pull/10","diff_url":"https://github.com/vMotioned/PowerShell/pull/10.diff","patch_url":"https://github.com/vMotioned/PowerShell/pull/10.patch","issue_url":"https://api.github.com/repos/vMotioned/PowerShell/issues/10","number":10,"state":"open","locked":false,"title":"minor refactor of Get-PendingReboot.ps1","user":{"login":"vScripter","id":3757585,"avatar_url":"https://avatars.githubusercontent.com/u/3757585?v=3","gravatar_id":"","url":"https://api.github.com/users/vScripter","html_url":"https://github.com/vScripter","followers_url":"https://api.github.com/users/vScripter/followers","following_url":"https://api.github.com/users/vScripter/following{/other_user}","gists_url":"https://api.github.com/users/vScripter/gists{/gist_id}","starred_url":"https://api.github.com/users/vScripter/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vScripter/subscriptions","organizations_url":"https://api.github.com/users/vScripter/orgs","repos_url":"https://api.github.com/users/vScripter/repos","events_url":"https://api.github.com/users/vScripter/events{/privacy}","received_events_url":"https://api.github.com/users/vScripter/received_events","type":"User","site_admin":false},"body":"","created_at":"2015-02-11T04:46:15Z","updated_at":"2015-02-11T04:50:50Z","closed_at":null,"merged_at":null,"merge_commit_sha":"8405d53cd31d7ab1fd649eafa43ac4f0105c9b23","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/vMotioned/PowerShell/pulls/10/commits","review_comments_url":"https://api.github.com/repos/vMotioned/PowerShell/pulls/10/comments","review_comment_url":"https://api.github.com/repos/vMotioned/PowerShell/pulls/comments/{number}","comments_url":"https://api.github.com/repos/vMotioned/PowerShell/issues/10/comments","statuses_url":"https://api.github.com/repos/vMotioned/PowerShell/statuses/bcd90ada248b883ad43e86e0cd17a758f99e13df","head":{"label":"vScripter:master","ref":"master","sha":"bcd90ada248b883ad43e86e0cd17a758f99e13df","user":{"login":"vScripter","id":3757585,"avatar_url":"https://avatars.githubusercontent.com/u/3757585?v=3","gravatar_id":"","url":"https://api.github.com/users/vScripter","html_url":"https://github.com/vScripter","followers_url":"https://api.github.com/users/vScripter/followers","following_url":"https://api.github.com/users/vScripter/following{/other_user}","gists_url":"https://api.github.com/users/vScripter/gists{/gist_id}","starred_url":"https://api.github.com/users/vScripter/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vScripter/subscriptions","organizations_url":"https://api.github.com/users/vScripter/orgs","repos_url":"https://api.github.com/users/vScripter/repos","events_url":"https://api.github.com/users/vScripter/events{/privacy}","received_events_url":"https://api.github.com/users/vScripter/received_events","type":"User","site_admin":false},"repo":{"id":29144490,"name":"PowerShell","full_name":"vScripter/PowerShell","owner":{"login":"vScripter","id":3757585,"avatar_url":"https://avatars.githubusercontent.com/u/3757585?v=3","gravatar_id":"","url":"https://api.github.com/users/vScripter","html_url":"https://github.com/vScripter","followers_url":"https://api.github.com/users/vScripter/followers","following_url":"https://api.github.com/users/vScripter/following{/other_user}","gists_url":"https://api.github.com/users/vScripter/gists{/gist_id}","starred_url":"https://api.github.com/users/vScripter/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vScripter/subscriptions","organizations_url":"https://api.github.com/users/vScripter/orgs","repos_url":"https://api.github.com/users/vScripter/repos","events_url":"https://api.github.com/users/vScripter/events{/privacy}","received_events_url":"https://api.github.com/users/vScripter/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/vScripter/PowerShell","description":"Handy PowerShell Scripts","fork":true,"url":"https://api.github.com/repos/vScripter/PowerShell","forks_url":"https://api.github.com/repos/vScripter/PowerShell/forks","keys_url":"https://api.github.com/repos/vScripter/PowerShell/keys{/key_id}","collaborators_url":"https://api.github.com/repos/vScripter/PowerShell/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/vScripter/PowerShell/teams","hooks_url":"https://api.github.com/repos/vScripter/PowerShell/hooks","issue_events_url":"https://api.github.com/repos/vScripter/PowerShell/issues/events{/number}","events_url":"https://api.github.com/repos/vScripter/PowerShell/events","assignees_url":"https://api.github.com/repos/vScripter/PowerShell/assignees{/user}","branches_url":"https://api.github.com/repos/vScripter/PowerShell/branches{/branch}","tags_url":"https://api.github.com/repos/vScripter/PowerShell/tags","blobs_url":"https://api.github.com/repos/vScripter/PowerShell/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/vScripter/PowerShell/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/vScripter/PowerShell/git/refs{/sha}","trees_url":"https://api.github.com/repos/vScripter/PowerShell/git/trees{/sha}","statuses_url":"https://api.github.com/repos/vScripter/PowerShell/statuses/{sha}","languages_url":"https://api.github.com/repos/vScripter/PowerShell/languages","stargazers_url":"https://api.github.com/repos/vScripter/PowerShell/stargazers","contributors_url":"https://api.github.com/repos/vScripter/PowerShell/contributors","subscribers_url":"https://api.github.com/repos/vScripter/PowerShell/subscribers","subscription_url":"https://api.github.com/repos/vScripter/PowerShell/subscription","commits_url":"https://api.github.com/repos/vScripter/PowerShell/commits{/sha}","git_commits_url":"https://api.github.com/repos/vScripter/PowerShell/git/commits{/sha}","comments_url":"https://api.github.com/repos/vScripter/PowerShell/comments{/number}","issue_comment_url":"https://api.github.com/repos/vScripter/PowerShell/issues/comments/{number}","contents_url":"https://api.github.com/repos/vScripter/PowerShell/contents/{+path}","compare_url":"https://api.github.com/repos/vScripter/PowerShell/compare/{base}...{head}","merges_url":"https://api.github.com/repos/vScripter/PowerShell/merges","archive_url":"https://api.github.com/repos/vScripter/PowerShell/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/vScripter/PowerShell/downloads","issues_url":"https://api.github.com/repos/vScripter/PowerShell/issues{/number}","pulls_url":"https://api.github.com/repos/vScripter/PowerShell/pulls{/number}","milestones_url":"https://api.github.com/repos/vScripter/PowerShell/milestones{/number}","notifications_url":"https://api.github.com/repos/vScripter/PowerShell/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/vScripter/PowerShell/labels{/name}","releases_url":"https://api.github.com/repos/vScripter/PowerShell/releases{/id}","created_at":"2015-01-12T16:24:09Z","updated_at":"2015-02-11T04:45:25Z","pushed_at":"2015-02-11T04:45:24Z","git_url":"git://github.com/vScripter/PowerShell.git","ssh_url":"git@github.com:vScripter/PowerShell.git","clone_url":"https://github.com/vScripter/PowerShell.git","svn_url":"https://github.com/vScripter/PowerShell","homepage":null,"size":229,"stargazers_count":0,"watchers_count":0,"language":"PowerShell","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":"vMotioned:master","ref":"master","sha":"ff688a71459f213fb0ca15da69c0a4d54f4d409d","user":{"login":"vMotioned","id":10499609,"avatar_url":"https://avatars.githubusercontent.com/u/10499609?v=3","gravatar_id":"","url":"https://api.github.com/users/vMotioned","html_url":"https://github.com/vMotioned","followers_url":"https://api.github.com/users/vMotioned/followers","following_url":"https://api.github.com/users/vMotioned/following{/other_user}","gists_url":"https://api.github.com/users/vMotioned/gists{/gist_id}","starred_url":"https://api.github.com/users/vMotioned/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vMotioned/subscriptions","organizations_url":"https://api.github.com/users/vMotioned/orgs","repos_url":"https://api.github.com/users/vMotioned/repos","events_url":"https://api.github.com/users/vMotioned/events{/privacy}","received_events_url":"https://api.github.com/users/vMotioned/received_events","type":"Organization","site_admin":false},"repo":{"id":12774336,"name":"PowerShell","full_name":"vMotioned/PowerShell","owner":{"login":"vMotioned","id":10499609,"avatar_url":"https://avatars.githubusercontent.com/u/10499609?v=3","gravatar_id":"","url":"https://api.github.com/users/vMotioned","html_url":"https://github.com/vMotioned","followers_url":"https://api.github.com/users/vMotioned/followers","following_url":"https://api.github.com/users/vMotioned/following{/other_user}","gists_url":"https://api.github.com/users/vMotioned/gists{/gist_id}","starred_url":"https://api.github.com/users/vMotioned/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vMotioned/subscriptions","organizations_url":"https://api.github.com/users/vMotioned/orgs","repos_url":"https://api.github.com/users/vMotioned/repos","events_url":"https://api.github.com/users/vMotioned/events{/privacy}","received_events_url":"https://api.github.com/users/vMotioned/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/vMotioned/PowerShell","description":"Handy PowerShell Scripts","fork":false,"url":"https://api.github.com/repos/vMotioned/PowerShell","forks_url":"https://api.github.com/repos/vMotioned/PowerShell/forks","keys_url":"https://api.github.com/repos/vMotioned/PowerShell/keys{/key_id}","collaborators_url":"https://api.github.com/repos/vMotioned/PowerShell/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/vMotioned/PowerShell/teams","hooks_url":"https://api.github.com/repos/vMotioned/PowerShell/hooks","issue_events_url":"https://api.github.com/repos/vMotioned/PowerShell/issues/events{/number}","events_url":"https://api.github.com/repos/vMotioned/PowerShell/events","assignees_url":"https://api.github.com/repos/vMotioned/PowerShell/assignees{/user}","branches_url":"https://api.github.com/repos/vMotioned/PowerShell/branches{/branch}","tags_url":"https://api.github.com/repos/vMotioned/PowerShell/tags","blobs_url":"https://api.github.com/repos/vMotioned/PowerShell/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/vMotioned/PowerShell/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/vMotioned/PowerShell/git/refs{/sha}","trees_url":"https://api.github.com/repos/vMotioned/PowerShell/git/trees{/sha}","statuses_url":"https://api.github.com/repos/vMotioned/PowerShell/statuses/{sha}","languages_url":"https://api.github.com/repos/vMotioned/PowerShell/languages","stargazers_url":"https://api.github.com/repos/vMotioned/PowerShell/stargazers","contributors_url":"https://api.github.com/repos/vMotioned/PowerShell/contributors","subscribers_url":"https://api.github.com/repos/vMotioned/PowerShell/subscribers","subscription_url":"https://api.github.com/repos/vMotioned/PowerShell/subscription","commits_url":"https://api.github.com/repos/vMotioned/PowerShell/commits{/sha}","git_commits_url":"https://api.github.com/repos/vMotioned/PowerShell/git/commits{/sha}","comments_url":"https://api.github.com/repos/vMotioned/PowerShell/comments{/number}","issue_comment_url":"https://api.github.com/repos/vMotioned/PowerShell/issues/comments/{number}","contents_url":"https://api.github.com/repos/vMotioned/PowerShell/contents/{+path}","compare_url":"https://api.github.com/repos/vMotioned/PowerShell/compare/{base}...{head}","merges_url":"https://api.github.com/repos/vMotioned/PowerShell/merges","archive_url":"https://api.github.com/repos/vMotioned/PowerShell/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/vMotioned/PowerShell/downloads","issues_url":"https://api.github.com/repos/vMotioned/PowerShell/issues{/number}","pulls_url":"https://api.github.com/repos/vMotioned/PowerShell/pulls{/number}","milestones_url":"https://api.github.com/repos/vMotioned/PowerShell/milestones{/number}","notifications_url":"https://api.github.com/repos/vMotioned/PowerShell/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/vMotioned/PowerShell/labels{/name}","releases_url":"https://api.github.com/repos/vMotioned/PowerShell/releases{/id}","created_at":"2013-09-12T03:49:12Z","updated_at":"2015-02-08T04:34:15Z","pushed_at":"2015-02-08T04:34:15Z","git_url":"git://github.com/vMotioned/PowerShell.git","ssh_url":"git@github.com:vMotioned/PowerShell.git","clone_url":"https://github.com/vMotioned/PowerShell.git","svn_url":"https://github.com/vMotioned/PowerShell","homepage":null,"size":490,"stargazers_count":0,"watchers_count":0,"language":"PowerShell","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":5,"forks":1,"open_issues":5,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/vMotioned/PowerShell/pulls/10"},"html":{"href":"https://github.com/vMotioned/PowerShell/pull/10"},"issue":{"href":"https://api.github.com/repos/vMotioned/PowerShell/issues/10"},"comments":{"href":"https://api.github.com/repos/vMotioned/PowerShell/issues/10/comments"},"review_comments":{"href":"https://api.github.com/repos/vMotioned/PowerShell/pulls/10/comments"},"review_comment":{"href":"https://api.github.com/repos/vMotioned/PowerShell/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/vMotioned/PowerShell/pulls/10/commits"},"statuses":{"href":"https://api.github.com/repos/vMotioned/PowerShell/statuses/bcd90ada248b883ad43e86e0cd17a758f99e13df"}}}}