Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update-GSUser support for unarchiving #379

Closed
dominikduennebacke opened this issue Feb 21, 2023 · 2 comments
Closed

Update-GSUser support for unarchiving #379

dominikduennebacke opened this issue Feb 21, 2023 · 2 comments

Comments

@dominikduennebacke
Copy link

Update-GSUser allows archiving a user via the switch parameter Archived. However I did not find a way to unarchive a user in the same manner. Ideally the parameter should be changed from type [switch] to [bool] where $true represents archiving and $false unarchiving.

Current behavior for archiving

Update-GSUser -User "john.doe@test.com" -Archived

Desired behavior

# Archiving
Update-GSUser -User "john.doe@test.com" -Archived $true

# Unarchiving
Update-GSUser -User "john.doe@test.com" -Archived $false

This would match the Google Admin SDK API method users.update.

PUT https://admin.googleapis.com/admin/directory/v1/users/john.doe@test.com
{
  "archived": false
}
@jeffreymcclain
Copy link

jeffreymcclain commented Oct 16, 2023

I know this Issue was opened a while ago, but just to verify does

Update-GSUser -User "john.doe@test.com" -Archived:$true

and

Update-GSUser -User "john.doe@test.com" -Archived:$false

work as expected with the existing function and meet your desired use case?

According to the Microsoft documentation for PowerShell Switch parameter design considerations
"Explicitly setting a switch from a boolean can be done with -MySwitch:$boolValue and in splatting with $params = @{ MySwitch = $boolValue }.

To your point, the Update-GSUser.ps1 function parameters could be changed from switches to booleans, but this might break existing uses of the function by other users. Someone could also create an alternate version of the function that has booleans instead of switches as a difference, but that also seems a bit excessive if the above workaround is functional.

@dominikduennebacke
Copy link
Author

Hi @jeffreymcclain, sorry for my late reply as well.

Update-GSUser -User "john.doe@test.com" -Archived:$false does work as expected. Thanks for pointing it out. I was not aware you can explicitly set a swich parameter.

I have hence closed the ticket.

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

No branches or pull requests

2 participants