AtlassianPS / JiraPS

PowerShell module to interact with Atlassian JIRA
https://AtlassianPS.org/module/JiraPS
MIT License
322 stars 131 forks source link

Unable to use New-Jirasession more than once without reboot #401

Closed rschmidt2 closed 4 years ago

rschmidt2 commented 4 years ago

Description

Steps To Reproduce

Expected behavior

Screenshots

Your Environment

Get-Module JiraPS -ListAvailable | Select Name, Version
Name   Version
----   -------
JiraPS 2.12.5 
JiraPS 2.12.4 

$PSVersionTable
Name                           Value                                                                                                                                                                       
----                           -----                                                                                                                                                                       
PSVersion                      5.1.18362.145                                                                                                                                                               
PSEdition                      Desktop                                                                                                                                                                     
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}                                                                                                                                                     
BuildVersion                   10.0.18362.145                                                                                                                                                              
CLRVersion                     4.0.30319.42000                                                                                                                                                             
WSManStackVersion              3.0                                                                                                                                                                         
PSRemotingProtocolVersion      2.3                                                                                                                                                                         
SerializationVersion           1.1.0.1                 

Possible Solution

rschmidt2 commented 4 years ago

Now, it will not do it even after a reboot. I can do get-jiraserver but anything that requires authorization fails with the same error.

rschmidt2 commented 4 years ago

remove-module jiraps update-module jiraps import-module jiraps -force $Global:loginName = cat c:\scripts\myuseremail.txt $Global:password = cat c:\scripts\tokenpassword.pwd | convertto-securestring $Global:cred = new-object -typename System.Management.Automation.PSCredential -argumentlist $loginName, $password New-JiraSession -Credential $Global:cred

And then the error about all the null values. But I checked and my input values have data in them including $cred. My password is the token password.

Resolve-DefaultParameterValue : Cannot bind argument to parameter 'Reference' because it is null. At C:\Program Files\WindowsPowerShell\Modules\jiraps\2.12.5\JiraPS.psm1:3215 char:78 Cannot index into a null array. At C:\Program Files\WindowsPowerShell\Modules\jiraps\2.12.5\JiraPS.psm1:3222 char:9 You cannot call a method on a null-valued expression. At C:\Program Files\WindowsPowerShell\Modules\jiraps\2.12.5\JiraPS.psm1:3266 char:13

rschmidt2 commented 4 years ago

I used: $cred.UserName + " : " + $cred.GetNetworkCredential().Password and my values are indeed correct.

rschmidt2 commented 4 years ago

I even created a second API Token and tried that. Same error.

rschmidt2 commented 4 years ago

It was back to working fine for a few sessions this afternoon. Now it is back to giving the error again. No change to the code.