Public/Add-MITGroupMember.ps1
function Add-MITGroupMember{ <# .SYNOPSIS Add MOVEit Transfer Group Member(s) .LINK Add members(s) to group https://docs.ipswitch.com/MOVEit/Transfer2021/Api/Rest/#operation/POSTapi/v1/groups/{Id}/members-1.0 #> [CmdletBinding()] param ( [Parameter(Mandatory, Position=0, ValueFromPipelineByPropertyName=$true)] [Alias('Id')] [string]$GroupId, [Parameter(Mandatory)] [string[]]$UserIds ) try { # Confirm the token, refreshing if necessary Confirm-MITToken # Set the Uri for this request $uri = "$script:BaseUri/groups/$GroupId/members" # Set the request headers $headers = @{ Accept = "application/json" Authorization = "Bearer $($script:Token.AccessToken)" } # Build the request body. $body = @{} switch ($PSBoundParameters.Keys) { GroupId { $body['id'] = $GroupId } UserIds { $body['userIds'] = $UserIds } } # Setup the params to splat to IRM $irmParams = @{ Uri = $uri Method = 'Post' Headers = $headers ContentType = 'application/json' Body = ($body | ConvertTo-Json) } # Send the request and output the response $response = Invoke-RestMethod @irmParams $response | Write-MITResponse -TypeName 'MITUserSimple' } catch { $PSCmdlet.ThrowTerminatingError($PSItem) } } |