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

[BUG] Add-PnPGroupMember does not respect -ErrorAction Stop #2273

Closed
5 tasks
iloving opened this issue Aug 24, 2022 · 2 comments
Closed
5 tasks

[BUG] Add-PnPGroupMember does not respect -ErrorAction Stop #2273

iloving opened this issue Aug 24, 2022 · 2 comments
Assignees
Labels
bug Something isn't working reproduced Issue reproduced after testing

Comments

@iloving
Copy link

iloving commented Aug 24, 2022

I have the following statement:
Add-PnPGroupMember -Group "$groupName" -LoginName "$memberToAdd" -Connection $Connection -ErrorAction Stop

While testing my script, sharepoint failed during the execution of this statement. My script should have subsequently aborted, and it didn't.

Expected behavior

The script should have stopped executing

Actual behavior

Add-PnPGroupMember: /PATH/TO/MY/SCRIPT.ps1:500:5
Line |
500 | Add-PnPGroupMember -Group "$groupName" -LoginName "$memberToAdd" …
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| User cannot be found.

and then kept running.

Steps to reproduce behavior

Do whatever it takes to make the cmdlet throw an error, such as using an non-existent user or group.

What is the version of the Cmdlet module you are running?

1.10

Which operating system/environment are you running PnP PowerShell on?

  • Windows
  • Linux
  • [X ] MacOS
  • Azure Cloud Shell
  • Azure Functions
  • Other : please specify
@iloving iloving added the bug Something isn't working label Aug 24, 2022
@KoenZomers
Copy link
Collaborator

Hi @iloving. Nice find that this doesn't work. I've added support for using -ErrorAction:Stop to all PnP cmdlets in PR #2288. Notice though that not all PnP PowerShell cmdlets are set up in a way that they will deal with this properly yet, but a lot of them will, including Add-PnPGroupMember.

@KoenZomers KoenZomers added the reproduced Issue reproduced after testing label Aug 29, 2022
@KoenZomers KoenZomers self-assigned this Aug 29, 2022
@gautamdsheth
Copy link
Collaborator

Hi, this has been merged and will be available in the latest nightly from tomorrow onwards !
Thanks for raising this issue and thanks @KoenZomers for fixing it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working reproduced Issue reproduced after testing
Projects
None yet
Development

No branches or pull requests

3 participants