Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Removed

## [0.0.4] - 2026-03-31

- Added the following functions; Get-BoxCollaboration, Set-Box Collaboration, Remove-BoxCollaboration.
Get-BoxCollaboration: Returns information about a specific collaborator
Set-BoxCollaboration: Changes an existing role for a collaborator
Remove-BoxCollaboration: Removes an existing Collaborator

## [0.0.3] - 2026-03-25

-README Fixes, updated functions list to reflect proper available functions
Expand Down
7 changes: 5 additions & 2 deletions src/UofIBox/UofIBox.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
RootModule = 'UofIBox.psm1'

# Version number of this module.
ModuleVersion = '1.0.0'
ModuleVersion = '1.0.1'

# Supported PSEditions
# CompatiblePSEditions = @()
Expand Down Expand Up @@ -78,7 +78,10 @@ FunctionsToExport = @(
'Receive-BoxFolder',
'Remove-BoxFolder',
'Remove-BoxFile',
'Send-BoxFile'
'Send-BoxFile',
'Get-BoxCollaboration',
'Set-BoxCollaboration',
'Remove-BoxCollaboration'
)


Expand Down
60 changes: 60 additions & 0 deletions src/UofIBox/functions/public/Get-BoxCollaboration.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
<#
.SYNOPSIS
Retrieves collaborators for a Box folder.

.DESCRIPTION
Gets all collaborators assigned to a folder, including their roles and status.
Supports pagination to return all collaborators.

.PARAMETER FolderId
ID of the folder.

.EXAMPLE
Get-BoxCollaboration -FolderId 123456

.EXAMPLE
Get-BoxCollaboration -FolderId 123456 | Select-Object login, role
#>

function Get-BoxCollaboration {

[CmdletBinding()]
param(
[Parameter(Mandatory)]
[string]$FolderId
)

$Limit = 100
$Offset = 0
$Results = @()

do {

$Call = @{
RelativeURI = "folders/$FolderId/collaborations?limit=$Limit&offset=$Offset"
Method = "GET"
}

$Response = Invoke-BoxRestCall @Call

if ($Response.entries) {
$Results += $Response.entries
}

$Offset += $Limit

} while ($Response.entries.Count -eq $Limit)

# Clean output
$Results | ForEach-Object {
[PSCustomObject]@{
Id = $_.id
Login = $_.accessible_by.login
Name = $_.accessible_by.name
Role = $_.role
Status = $_.status
CreatedAt = $_.created_at
ModifiedAt = $_.modified_at
}
}
}
51 changes: 51 additions & 0 deletions src/UofIBox/functions/public/Remove-BoxCollaboration.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<#
.SYNOPSIS
Removes a collaborator from a Box folder.

.DESCRIPTION
Deletes a collaboration by Collaboration ID. Supports pipeline input
from Get-BoxCollaboration.

.PARAMETER CollaborationId
ID of the collaboration to remove.

.EXAMPLE
Remove-BoxCollaboration -FolderId 123456 -CollaborationId 123456

.EXAMPLE
Get-BoxCollaboration -FolderId 123456 |
Where-Object Role -eq "viewer" |
Remove-BoxCollaboration -WhatIf
#>

function Remove-BoxCollaboration {

[CmdletBinding(SupportsShouldProcess)]
param(
[Parameter(
Mandatory,
ValueFromPipelineByPropertyName
)]
[Alias("Id")]
[string]$CollaborationId
)

process {

if (-not $CollaborationId) {
throw "CollaborationId cannot be null or empty."
}

$Target = "Collaboration ID: $CollaborationId"

if ($PSCmdlet.ShouldProcess($Target, "Remove collaborator")) {

$Call = @{
RelativeURI = "collaborations/$CollaborationId"
Method = "DELETE"
}

Invoke-BoxRestCall @Call
}
}
}
68 changes: 68 additions & 0 deletions src/UofIBox/functions/public/Set-BoxCollaboration.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
<#
.SYNOPSIS
Updates a Box collaboration role.

.DESCRIPTION
Modifies an existing collaboration, typically to change the user's role.

.PARAMETER CollaborationId
ID of the collaboration.

.PARAMETER Role
New role to assign.

.EXAMPLE
Get-BoxCollaboration -FolderId 123456 |
Where-Object Login -eq "user@company.com" |
Set-BoxCollaboration -Role co-owner
#>

function Set-BoxCollaboration {

[CmdletBinding(SupportsShouldProcess)]
param(
[Parameter(
Mandatory,
ValueFromPipelineByPropertyName
)]
[Alias("Id")]
[string]$CollaborationId,

[Parameter(Mandatory)]
[ValidateSet(
"editor",
"viewer",
"previewer",
"uploader",
"previewer uploader",
"viewer uploader",
"co-owner",
"owner"
)]
[string]$Role
)

process {

if (-not $CollaborationId) {
throw "CollaborationId cannot be null or empty."
}

$Target = "Collaboration ID: $CollaborationId"

if ($PSCmdlet.ShouldProcess($Target, "Update role to '$Role'")) {

$Body = @{
role = $Role
}

$Call = @{
RelativeURI = "collaborations/$CollaborationId"
Method = "PUT"
Body = $Body
}

Invoke-BoxRestCall @Call
}
}
}
Loading