Public/New-JiraGroup.ps1
function New-JiraGroup { [CmdletBinding( SupportsShouldProcess )] param( [Parameter( Mandatory )] [Alias('Name')] [String[]] $GroupName, [PSCredential] $Credential ) begin { Write-Verbose "[$($MyInvocation.MyCommand.Name)] Function started" $server = Get-JiraConfigServer -ErrorAction Stop $resourceURi = "$server/rest/api/latest/group" } process { Write-DebugMessage "[$($MyInvocation.MyCommand.Name)] ParameterSetName: $($PsCmdlet.ParameterSetName)" Write-DebugMessage "[$($MyInvocation.MyCommand.Name)] PSBoundParameters: $($PSBoundParameters | Out-String)" foreach ($_group in $GroupName) { Write-Verbose "[$($MyInvocation.MyCommand.Name)] Processing [$_group]" Write-Debug "[$($MyInvocation.MyCommand.Name)] Processing `$_group [$_group]" $requestBody = @{ "name" = $_group } $parameter = @{ URI = $resourceURi Method = "POST" Body = ConvertTo-Json -InputObject $requestBody Credential = $Credential } Write-Debug "[$($MyInvocation.MyCommand.Name)] Invoking JiraMethod with `$parameter" if ($PSCmdlet.ShouldProcess($GroupName, "Creating group [$GroupName] to JIRA")) { $result = Invoke-JiraMethod @parameter Write-Output (ConvertTo-JiraGroup -InputObject $result) } } } end { Write-Verbose "[$($MyInvocation.MyCommand.Name)] Complete" } } |