powershell 2.0

For script in the previous post, I needed a tool that would convert PowerShell script to HTML format. Surprisingly numerous online tools somehow completely ignored PowerShell, so I found PowerShell scripts that would do the job: PowerShell Syntax Highlighting by Lee Holmes, an extended version by Helge Klein, and different implementation, which will only work on PowerShell 2.0 by Jeff Hillman.

# Those constants normally do not change[string]$LOGIN_URL=“http://{0}/login.jsp?os_username={1}&os_password={2}&os_destination=/secure/”[string]$CREATE_URL=“http://{0}/secure/CreateIssueDetails.jspa?pid={1}&{2}&Create=Create&atl_token={3}”[string]$TOKEN_PREFIX=‘<meta id=”atlassian-token” name=”atlassian-token” content=”‘[string]$TOKEN_SUFFIX=‘”>’

function loginToJira($server,$user,$pwd) {

[string]$postUrl=$url-f$user,$pwd

[System.Net.WebRequest] $webRequest= [System.Net.WebRequest]::Create($postUrl)$webRequest.CookieContainer =New-object System.Net.CookieContainer
[System.Net.WebResponse] $webResponse=$webRequest.getResponse()# TO DO: Response can be verified here# One of the ways to check if request was successful is to read $webResponse.StatusDescription, e.g.Write-Host“status = “$webResponse.StatusDescription;

$resStream=$webResponse.GetResponseStream()
[System.IO.StreamReader]$streamReader=New-Object System.IO.StreamReader -argumentList $resStream$res=$streamReader.ReadToEnd()# TO DO: Here it can be verified if the issue was posted successully, by looking into $res# If issue is not posted, Jira will return HTML similar to the page seeing by the user who tried to post issue with missing / problematic fields
}