{"action":"created","issue":{"url":"https://api.github.com/repos/tenable/Posh-Nessus/issues/2","labels_url":"https://api.github.com/repos/tenable/Posh-Nessus/issues/2/labels{/name}","comments_url":"https://api.github.com/repos/tenable/Posh-Nessus/issues/2/comments","events_url":"https://api.github.com/repos/tenable/Posh-Nessus/issues/2/events","html_url":"https://github.com/tenable/Posh-Nessus/issues/2","id":105585809,"number":2,"title":"Export report doesn't work","user":{"login":"davidwallis3101","id":13855486,"avatar_url":"https://avatars.githubusercontent.com/u/13855486?v=3","gravatar_id":"","url":"https://api.github.com/users/davidwallis3101","html_url":"https://github.com/davidwallis3101","followers_url":"https://api.github.com/users/davidwallis3101/followers","following_url":"https://api.github.com/users/davidwallis3101/following{/other_user}","gists_url":"https://api.github.com/users/davidwallis3101/gists{/gist_id}","starred_url":"https://api.github.com/users/davidwallis3101/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/davidwallis3101/subscriptions","organizations_url":"https://api.github.com/users/davidwallis3101/orgs","repos_url":"https://api.github.com/users/davidwallis3101/repos","events_url":"https://api.github.com/users/davidwallis3101/events{/privacy}","received_events_url":"https://api.github.com/users/davidwallis3101/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2015-09-09T12:25:01Z","updated_at":"2015-09-09T16:02:27Z","closed_at":null,"body":"I've identified an issue with scan.ps1\r\n\r\nin the section for Export-Nessus scan you have:\r\n\r\n        foreach($Connection in $ToProcess)\r\n        {\r\n            $path =  \"/scans/$($ScanId)/export\"\r\n            Write-Verbose -Message \"Exporting scan with Id of $($ScanId) in $($Format) format.\"\r\n            $FileID = InvokeNessusRestRequest -SessionObject $Connections -Path $path  -Method 'Post' -Parameter $ExportParams\r\n            if ($FileID -is [psobject])\r\n            {\r\n                $FileStatus = ''\r\n                while ($FileStatus.status -ne 'ready')\r\n                {\r\n                    try\r\n                    {\r\n                        $FileStatus = InvokeNessusRestRequest -SessionObject $Connections -Path \"/scans/$($ScanId)/export/$($FileID.file)/status\"  -Method 'Get'\r\n                        Write-Verbose -Message \"Status of export is $($FileStatus.status)\"\r\n                    }\r\n                    catch\r\n                    {\r\n                        break\r\n                    }\r\n                    Start-Sleep -Seconds 1\r\n                }\r\n                if ($FileStatus.status -eq 'ready')\r\n                {\r\n                    Write-Verbose -Message \"Downloading report to $($OutFile)\"\r\n                    InvokeNessusRestRequest -SessionObject $Connection -Path \"/scans/$($ScanId)/export/$($FileID.file)/download\" -Method 'Get' -OutFile $OutFile\r\n                }\r\n            }\r\n        }\r\n\r\nHowever $connections refers to the collection of objects from the foreach statement and wants swapping to be $connection on each instance, I've tested this and it works ok here :)\r\n\r\n        foreach($Connection in $ToProcess)\r\n        {\r\n            $path =  \"/scans/$($ScanId)/export\"\r\n            Write-Verbose -Message \"Exporting scan with Id of $($ScanId) in $($Format) format.\"\r\n            $FileID = InvokeNessusRestRequest -SessionObject $Connection -Path $path  -Method 'Post' -Parameter $ExportParams\r\n            if ($FileID -is [psobject])\r\n            {\r\n                $FileStatus = ''\r\n                while ($FileStatus.status -ne 'ready')\r\n                {\r\n                    try\r\n                    {\r\n                        $FileStatus = InvokeNessusRestRequest -SessionObject $Connection -Path \"/scans/$($ScanId)/export/$($FileID.file)/status\"  -Method 'Get'\r\n                        Write-Verbose -Message \"Status of export is $($FileStatus.status)\"\r\n                    }\r\n                    catch\r\n                    {\r\n                        break\r\n                    }\r\n                    Start-Sleep -Seconds 1\r\n                }\r\n                if ($FileStatus.status -eq 'ready')\r\n                {\r\n                    Write-Verbose -Message \"Downloading report to $($OutFile)\"\r\n                    InvokeNessusRestRequest -SessionObject $Connection -Path \"/scans/$($ScanId)/export/$($FileID.file)/download\" -Method 'Get' -OutFile $OutFile\r\n                }\r\n            }\r\n        }"},"comment":{"url":"https://api.github.com/repos/tenable/Posh-Nessus/issues/comments/138957211","html_url":"https://github.com/tenable/Posh-Nessus/issues/2#issuecomment-138957211","issue_url":"https://api.github.com/repos/tenable/Posh-Nessus/issues/2","id":138957211,"user":{"login":"darkoperator","id":521246,"avatar_url":"https://avatars.githubusercontent.com/u/521246?v=3","gravatar_id":"","url":"https://api.github.com/users/darkoperator","html_url":"https://github.com/darkoperator","followers_url":"https://api.github.com/users/darkoperator/followers","following_url":"https://api.github.com/users/darkoperator/following{/other_user}","gists_url":"https://api.github.com/users/darkoperator/gists{/gist_id}","starred_url":"https://api.github.com/users/darkoperator/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/darkoperator/subscriptions","organizations_url":"https://api.github.com/users/darkoperator/orgs","repos_url":"https://api.github.com/users/darkoperator/repos","events_url":"https://api.github.com/users/darkoperator/events{/privacy}","received_events_url":"https://api.github.com/users/darkoperator/received_events","type":"User","site_admin":false},"created_at":"2015-09-09T16:02:27Z","updated_at":"2015-09-09T16:02:27Z","body":"On validation of the Chapter what Regex are you mentioning? ValidateSet is not a regex it just makes sure in PS that one or more of those values are only accepted and gives the engine the info so it can be tab completed in the session. "}}