Skip to content

Initial Push#1

Merged
rdonovan92 merged 9 commits intomainfrom
Initial-Release
Mar 24, 2026
Merged

Initial Push#1
rdonovan92 merged 9 commits intomainfrom
Initial-Release

Conversation

@rdonovan92
Copy link
Copy Markdown
Contributor

@rdonovan92 rdonovan92 commented Mar 17, 2026

Initial push, added first batch of functions and pester template for module release

@rdonovan92 rdonovan92 changed the title Initial Release Initial Push Mar 18, 2026
Copy link
Copy Markdown

@baristaTam baristaTam left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is awesome, Richard! I just have some easy cleanup items I commented on below. Let me know when these are taken care of and I'll approve!

Authorization = "Bearer $($Script:BoxSession.AccessToken)"
}

$Form = @{
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason not to just make Form an optional param on invoke-boxrestcall and simplify this?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No preferences here, just something I didn't think about doing and would be happy to look at this as an improvement in the near future

Returns a link to the folder.

.EXAMPLE
New-BoxFolderCollaboration -FolderName "Finance" -Collaborators $Users
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This example seems to include a parameter that isn't valid, and seems to omit several parameters that are marked mandatory.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just updated this, nice catch!

Comment on lines +44 to +46
if ($Login.Count -ne $Role.Count) {
throw "Login and Role counts must match."
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Making two arrays that match exactly to set permissions seems like it could be error prone if there are very many collaborators? Getting off by one might set a lot of incorrect permissions. You could consider for a future improvement taking an powershell object with key value pairs for the user and role such as:

$obj1 = {
    user = "user@example.com"
    role = "reader"
}

Or alternately, parameters Login and Role could be set to only accept a single string instead of an array and then use ValueFromPipelineByPropertyName so that objects could be sent from the pipeline.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I initially had tried the powershell object, but for some reason, i couldn't get it to send the login and role properly, this is something I would definitely like to improve on.

Body = $FolderBody
}

$FolderResponse = Invoke-BoxRestCall @CreateFolder
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would this be more modular if it was a separate function? i.e. Have a function for New-BoxFolder and then turn this function into something like New-Collaborator (or whatever the proper pwsh verb might be)?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is probably the way, this was created initially with a very specific need in mind, but breaking is probably the way to go.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That would also allow us to in the future add collaborators to an existing folder.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Splitting into two functions and then using ValueFromPipelineByPropertyName for the add collaborator piece would keep the function login much simpler as well.


$Target = "$($Login[$i]) as $($Role[$i])"

if ($PSCmdlet.ShouldProcess("Box Folder $FolderId", "Add collaborator $Target")) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just curious, Does this work if using the WhatIf flag? $FolderId wouldn't exist at this point, right? Or am I thinking about this wrong?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This does indeed for example, it would look like:
What if: Performing the operation "Create folder 'BoxAPITest1'" on target "Box".

@rdonovan92 rdonovan92 merged commit 509370a into main Mar 24, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants