Deleting Meeting Requests made by terminated users

给你一囗甜甜゛ 提交于 2019-12-01 13:12:29

问题


Need to delete the meeting requests made by terminated users from all the conference rooms for multiple terminated users at a time.

below is the script which i built to delete the meetings requests for two terminated users from all the conference rooms. i used OR operator if i want to delete the meetings for two terminated users(kind:calendar from:sasi OR Kalai). How can i add more than two terminated users at a time? i have more than 500 terminated users to delete their meetings requests from all the conference rooms.

Write-Progress -Activity "Preparing" -Status "Retrieving mailbox list" -PercentComplete 0
$rooms=get-mailbox -recipienttypedetails roommailbox -resultsize unlimited -warningaction:silentlycontinue| where {$_.name -notlike "*test*"}

$count=$rooms.count

foreach($room in $rooms)

{


    $i=$i+1
    $percentage=$i/$count*100


    Write-Progress -Activity "Collecting mailbox details" -Status "Processing mailbox $i of $Count - $room" -PercentComplete $percentage

$room | search-mailbox -searchquery "kind:calendar from:sasi OR Kalai" -targetmailbox sankar_munirathinam@domain.com -targetfolder "Deleting Meeting" -deletecontent -force

}

回答1:


So if I understand the above correctly, you'd do the following? and you can take the "deletecontent -force" if this is merely investigative?

Write-Progress -Activity "Preparing" -Status "Retrieving mailbox list" -PercentComplete 0
$rooms=get-mailbox -recipienttypedetails roommailbox -resultsize unlimited -    
warningaction:silentlycontinue| where {$_.name -notlike "*test*"}

$count=$rooms.count
$TerminatedUsers = Get-Content .\TerminatedUsersList.txt
foreach ($User in $TerminatedUsers) {
foreach($room in $rooms)

{


$i=$i+1
$percentage=$i/$count*100


Write-Progress -Activity "Collecting mailbox details" -Status "Processing mailbox $i of $Count -
$room" -PercentComplete $percentage

$room | search-mailbox -searchquery "kind:calendar from:$($user)" -targetmailbox    
administrator@domain.com -targetfolder "Deleting Meeting" -deletecontent -force

}
}



回答2:


I think I can actually answer this for you! My first answer (that I can remember) on stack:)

You should put the terminated users' usernames (or some other identifier) in a text file, then insert a new line below your line

$count=$rooms.count

that is

$TerminatedUsers = Get-Content .\TerminatedUsersList.txt.

Then add another line that is

foreach ($User in $TerminatedUsers) {

Then add a final closing curly brace } to the very end of your script.

Finally, change your from:sasi OR Kalai to from:$($User)

This will loop through each of the terminated users, and for each one of them, it will search all of the room mailboxes for their meetings.

I hope this makes sense for you.



来源:https://stackoverflow.com/questions/14524919/deleting-meeting-requests-made-by-terminated-users

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!