Quantcast
Channel: Windows PowerShell forum
Viewing all articles
Browse latest Browse all 21975

I need help about script to bulk remove something

$
0
0

Hi all,

I need to compose a PowerShell script to bulk remove some items
Here is an example:
1. First, I run:

PS C:\Users\> Get-ManagementRoleEntry "test1\*"

Name                           Role                      Parameters
----                           ----                      ----------
Add-MailboxFolderPermission    test1                {AccessRights, Confirm, ErrorAction, ErrorVariable...}
Add-MailboxPermission          test1                {AccessRights, AutoMapping, Confirm, Deny...}
Add-RecipientPermission        test1                {AccessRights, Confirm, ErrorAction, ErrorVariable...}
a
b
c

2. The cmdlets (too many) to remove something is:
Remove-ManagementRoleEntry -Identity "test1\Add-MailboxFolderPermission"
Remove-ManagementRoleEntry -Identity "test1\Add-MailboxPermission"
Remove-ManagementRoleEntry -Identity "test1\Add-RecipientPermission"
Remove-ManagementRoleEntry -Identity "test1\a"
Remove-ManagementRoleEntry -Identity "test1\b"
Remove-ManagementRoleEntry -Identity "test1\c"

We can find that it uses the value of the Name coloum of the output in the first cmdlet. Maybe we have some ways to just call the values of the Name coloum got from the first cmdlet (in text mode?) and use it to bulk run the second cmdlet (Remove-ManagementRoleEntry)?
I can accept involve other things to achieve the goal, such as using CSV files.

TIA


Viewing all articles
Browse latest Browse all 21975

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>