From 8a45a5c133279787ae00583f567cda00d239be40 Mon Sep 17 00:00:00 2001 From: SgtWilko Date: Tue, 1 Oct 2019 02:36:55 +0100 Subject: [PATCH 1/6] Disable progress during webrequests for speed --- JiraPS/Public/Invoke-JiraMethod.ps1 | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/JiraPS/Public/Invoke-JiraMethod.ps1 b/JiraPS/Public/Invoke-JiraMethod.ps1 index 6b5cc9f4..bf11ca16 100644 --- a/JiraPS/Public/Invoke-JiraMethod.ps1 +++ b/JiraPS/Public/Invoke-JiraMethod.ps1 @@ -152,6 +152,11 @@ function Invoke-JiraMethod { #endregion Constructe IWR Parameter #region Execute the actual query + # Normal ProgressPreference really slows down invoke-webrequest as it tries to update the screen for bytes received. + # By setting ProgressPreference to silentlyContinue it doesn't try to update the screen and speeds up the downloads. + # See https://stackoverflow.com/a/43477248/2641196 + $oldProgressPreference = $progressPreference + $progressPreference = 'silentlyContinue' try { Write-Verbose "[$($MyInvocation.MyCommand.Name)] $($splatParameters.Method) $($splatParameters.Uri)" Write-Debug "[$($MyInvocation.MyCommand.Name)] Invoke-WebRequest with `$splatParameters: $($splatParameters | Out-String)" @@ -164,6 +169,8 @@ function Invoke-JiraMethod { $exception = $_ $webResponse = $exception.Exception.Response } + # Reset the progressPreference to the value it was before the Invoke-WebRequest + $progressPreference = $oldProgressPreference Write-Debug "[$($MyInvocation.MyCommand.Name)] Executed WebRequest. Access `$webResponse to see details" Test-ServerResponse -InputObject $webResponse -Cmdlet $Cmdlet From 65a673e2694fb4dcc3de57b9eaf20ab89186af2f Mon Sep 17 00:00:00 2001 From: John Heusinger Date: Thu, 24 Oct 2019 21:18:28 +0200 Subject: [PATCH 2/6] Add and handle new 'active' parameter --- JiraPS/Public/Set-JiraUser.ps1 | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/JiraPS/Public/Set-JiraUser.ps1 b/JiraPS/Public/Set-JiraUser.ps1 index f9175e04..1907f4cb 100644 --- a/JiraPS/Public/Set-JiraUser.ps1 +++ b/JiraPS/Public/Set-JiraUser.ps1 @@ -55,6 +55,10 @@ function Set-JiraUser { [String] $EmailAddress, + [Parameter( ParameterSetName = 'ByNamedParameters' )] + [Boolean] + $Active, + [Parameter( Position = 1, Mandatory, ParameterSetName = 'ByHashtable' )] [Hashtable] $Property, @@ -90,7 +94,7 @@ function Set-JiraUser { switch ($PSCmdlet.ParameterSetName) { 'ByNamedParameters' { - if (-not ($DisplayName -or $EmailAddress)) { + if (-not ($DisplayName -or $EmailAddress -or $PSBoundParameters.ContainsKey('Active'))) { $errorMessage = @{ Category = "InvalidArgument" CategoryActivity = "Validating Arguments" @@ -107,6 +111,10 @@ function Set-JiraUser { if ($EmailAddress) { $requestBody.emailAddress = $EmailAddress } + + if ($PSBoundParameters.ContainsKey('Active')) { + $requestBody.active = $Active + } } 'ByHashtable' { $requestBody = $Property From 5f4330c2c64f90e30f6926c7c097c5b96dd66b0a Mon Sep 17 00:00:00 2001 From: John Heusinger Date: Sat, 26 Oct 2019 18:42:24 +0200 Subject: [PATCH 3/6] Update help to reflect addition of '-Active' parameter --- docs/en-US/commands/Set-JiraUser.md | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/docs/en-US/commands/Set-JiraUser.md b/docs/en-US/commands/Set-JiraUser.md index b3d9078e..a90681b7 100644 --- a/docs/en-US/commands/Set-JiraUser.md +++ b/docs/en-US/commands/Set-JiraUser.md @@ -18,7 +18,7 @@ Modifies user properties in JIRA ### ByNamedParameters (Default) ```powershell -Set-JiraUser [-User] [-DisplayName ] [-EmailAddress ] [-Credential ] +Set-JiraUser [-User] [-DisplayName ] [-EmailAddress ] [[-Active] ] [-Credential ] [-PassThru] [-WhatIf] [-Confirm] [] ``` @@ -104,6 +104,22 @@ Accept pipeline input: False Accept wildcard characters: False ``` +### -Active + +Sets user to active or inactive. + +```yaml +Type: Boolean +Parameter Sets: ByNamedParameters +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + ### -Property Hashtable (dictionary) of additional information to set. @@ -204,10 +220,7 @@ to the JIRA user modified. Otherwise, this function does not provide output. ## NOTES -It is currently NOT possible to enable and disable users with this function. -JIRA does not currently provide this ability via their REST API. - -> If you'd like to see this ability added to JIRA and to this module, please vote on Atlassian's site for this issue: [https://jira.atlassian.com/browse/JRA-37294](https://jira.atlassian.com/browse/JRA-37294) +The '-Active' parameter is supported only in Jira Server version 8.3.0 and above. This function requires either the `-Credential` parameter to be passed or a persistent JIRA session. See `New-JiraSession` for more details. From af5ef9613d010989445104f1176db9d98490a337 Mon Sep 17 00:00:00 2001 From: John Heusinger Date: Sat, 26 Oct 2019 18:50:01 +0200 Subject: [PATCH 4/6] Fix line break --- docs/en-US/commands/Set-JiraUser.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/en-US/commands/Set-JiraUser.md b/docs/en-US/commands/Set-JiraUser.md index a90681b7..eeff4aee 100644 --- a/docs/en-US/commands/Set-JiraUser.md +++ b/docs/en-US/commands/Set-JiraUser.md @@ -18,8 +18,8 @@ Modifies user properties in JIRA ### ByNamedParameters (Default) ```powershell -Set-JiraUser [-User] [-DisplayName ] [-EmailAddress ] [[-Active] ] [-Credential ] - [-PassThru] [-WhatIf] [-Confirm] [] +Set-JiraUser [-User] [-DisplayName ] [-EmailAddress ] [[-Active] ] + [-Credential ] [-PassThru] [-WhatIf] [-Confirm] [] ``` ### ByHashtable From 813c9d0e6f98a2bf913f45d8968bcb80184e5729 Mon Sep 17 00:00:00 2001 From: John Heusinger Date: Sun, 27 Oct 2019 09:25:06 +0100 Subject: [PATCH 5/6] Fix formatting --- docs/en-US/commands/Set-JiraUser.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/en-US/commands/Set-JiraUser.md b/docs/en-US/commands/Set-JiraUser.md index eeff4aee..3b589718 100644 --- a/docs/en-US/commands/Set-JiraUser.md +++ b/docs/en-US/commands/Set-JiraUser.md @@ -220,7 +220,7 @@ to the JIRA user modified. Otherwise, this function does not provide output. ## NOTES -The '-Active' parameter is supported only in Jira Server version 8.3.0 and above. +The `-Active` parameter is supported only in Jira Server version 8.3.0 and above. This function requires either the `-Credential` parameter to be passed or a persistent JIRA session. See `New-JiraSession` for more details. From 9d2ad836b99e2edad2eeb049f806e2fe70a88c3d Mon Sep 17 00:00:00 2001 From: AtlassianPS Automated User Date: Sun, 23 Feb 2020 12:11:53 +0100 Subject: [PATCH 6/6] Bomped version to 2.13 --- CHANGELOG.md | 14 +++++++++++++- JiraPS/JiraPS.psd1 | 2 +- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6a00ffff..f22a6420 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,16 @@ ## [NEXT VERSION] - YYYY-MM-DD +## [2.13] - 2020-02-23 + +### Added + +- Add support for activation/deactivation of accounts via `Set-JiraUser` (#385, [@johnheusinger]) + +### Changed + +- Removed progress bar from `Invoke-WebRequest` for better performance (#380, [@sgtwilko]) + ## [2.12] - 2019-08-15 ### Added @@ -30,7 +40,7 @@ ### Added - Parameter for retrieving information about a specific user with `Get-JiraUser` (#328, [@michalporeba]) - - this implementations will be changed with the next major update in favor of #306 + - this implementations will be changed with the next major update in favor of #306 ### Changed @@ -346,6 +356,7 @@ which is in turn inspired by the [Vagrant](https://github.com/mitchellh/vagrant/ [@ebekker]: https://github.com/ebekker [@hmmwhatsthisdo]: https://github.com/hmmwhatsthisdo [@jkknorr]: https://github.com/jkknorr +[@johnheusinger]: https://github.com/johnheusinger [@kb-cs]: https://github.com/kb-cs [@kittholland]: https://github.com/kittholland [@liamleane]: https://github.com/LiamLeane @@ -355,6 +366,7 @@ which is in turn inspired by the [Vagrant](https://github.com/mitchellh/vagrant/ [@mirrorgleam]: https://github.com/mirrorgleam [@nojp]: https://github.com/nojp [@padgers]: https://github.com/padgers +[@sgtwilko]: https://github.com/sgtwilko [@thepsadmin]: https://github.com/ThePSAdmin [@tuxgoose]: https://github.com/tuxgoose [@vercellone]: https://github.com/vercellone diff --git a/JiraPS/JiraPS.psd1 b/JiraPS/JiraPS.psd1 index 8fbafac0..71fca9ed 100644 --- a/JiraPS/JiraPS.psd1 +++ b/JiraPS/JiraPS.psd1 @@ -4,7 +4,7 @@ RootModule = 'JiraPS.psm1' # Version number of this module. - ModuleVersion = '2.12' + ModuleVersion = '2.13' # Supported PSEditions # CompatiblePSEditions = @()