Office 365

Checking and Providing Full and SendAs delegate access on O365 Exchange Online

&NewLine;<&excl;-- WP QUADS Content Ad Plugin v&period; 2&period;0&period;93 -->&NewLine;<div class&equals;"quads-location quads-ad2526 " id&equals;"quads-ad2526" style&equals;"float&colon;none&semi;margin&colon;0px 3px 3px 3px&semi;padding&colon;0px 0px 0px 0px&semi;" data-lazydelay&equals;"0">&NewLine;&NewLine;<&sol;div>&NewLine;&NewLine;<h2 class&equals;"wp-block-heading">Delegate Permissions<&sol;h2>&NewLine;&NewLine;&NewLine;&NewLine;<p>This is a code that I have wrote recently to check if an account have Full and SendAs access on target mailboxes in CSV and give the option to choose whether to provide this access or not&period;<&sol;p>&NewLine;<&excl;-- WP QUADS Content Ad Plugin v&period; 2&period;0&period;93 -->&NewLine;<div class&equals;"quads-location quads-ad2522 " id&equals;"quads-ad2522" style&equals;"float&colon;none&semi;margin&colon;0px 3px 3px 3px&semi;padding&colon;0px 0px 0px 0px&semi;" data-lazydelay&equals;"0">&NewLine;&NewLine;<&sol;div>&NewLine;&NewLine;<&excl;-- WP QUADS Content Ad Plugin v&period; 2&period;0&period;93 -->&NewLine;<div class&equals;"quads-location quads-ad2527 " id&equals;"quads-ad2527" style&equals;"float&colon;none&semi;margin&colon;0px 3px 3px 3px&semi;padding&colon;0px 0px 0px 0px&semi;" data-lazydelay&equals;"0">&NewLine;&NewLine;<&sol;div>&NewLine;&NewLine;<&excl;-- WP QUADS Content Ad Plugin v&period; 2&period;0&period;93 -->&NewLine;<div class&equals;"quads-location quads-ad2530 " id&equals;"quads-ad2530" style&equals;"float&colon;none&semi;margin&colon;0px 3px 3px 3px&semi;padding&colon;0px 0px 0px 0px&semi;" data-lazydelay&equals;"0">&NewLine;&NewLine;<&sol;div>&NewLine;&NewLine;&NewLine;&NewLine;&NewLine;<h2 class&equals;"wp-block-heading">Checking First&colon;<&sol;h2>&NewLine;&NewLine;&NewLine;&NewLine;<p>You&&num;8217&semi;ll need to provide two things to get this code working&comma; First the Source account that will need access to the mailboxes&period; in this case referred to as &&num;8220&semi;ServiceAccount&&num;8221&semi;&period; <&sol;p>&NewLine;&NewLine;&NewLine;&NewLine;<p>CSV List of Mailbxoes&colon;<&sol;p>&NewLine;&NewLine;&NewLine;&NewLine;<p>You&&num;8217&semi;ll need to provide list of Mailboxes of the users you&&num;8217&semi;d like to provide access to&comma; the List must be user&&num;8217&semi;s Identity either UPN or SMTP would be fine&period; <&sol;p>&NewLine;<&excl;-- WP QUADS Content Ad Plugin v&period; 2&period;0&period;93 -->&NewLine;<div class&equals;"quads-location quads-ad2528 " id&equals;"quads-ad2528" style&equals;"float&colon;none&semi;margin&colon;0px 3px 3px 3px&semi;padding&colon;0px 0px 0px 0px&semi;" data-lazydelay&equals;"0">&NewLine;&NewLine;<&sol;div>&NewLine;&NewLine;&NewLine;&NewLine;&NewLine;<p>The Service account&&num;8217&semi;s Identity must be the UPN attribute&period; <&sol;p>&NewLine;&NewLine;&NewLine;&NewLine;<p>If you would like to improve this code please do comment or get in touch directly<&sol;p>&NewLine;<&excl;-- WP QUADS Content Ad Plugin v&period; 2&period;0&period;93 -->&NewLine;<div class&equals;"quads-location quads-ad2531 " id&equals;"quads-ad2531" style&equals;"float&colon;none&semi;margin&colon;0px 3px 3px 3px&semi;padding&colon;0px 0px 0px 0px&semi;" data-lazydelay&equals;"0">&NewLine;&NewLine;<&sol;div>&NewLine;&NewLine;&NewLine;&NewLine;&NewLine;<p>Thanks <&sol;p>&NewLine;&NewLine;&NewLine;&NewLine;<pre class&equals;"EnlighterJSRAW" data-enlighter-language&equals;"generic" data-enlighter-theme&equals;"" data-enlighter-highlight&equals;"" data-enlighter-linenumbers&equals;"" data-enlighter-lineoffset&equals;"" data-enlighter-title&equals;"" data-enlighter-group&equals;"">&num;Connect to Exchange&NewLine;&num;Connect &amp&semi; Login to ExchangeOnline &lpar;MFA&rpar;&NewLine;&NewLine;try&NewLine;&lbrace;&NewLine; Get-Clutter -Identity user&commat;domain&period;com -ErrorAction Stop > &dollar;null&NewLine;&rcub;&NewLine;catch &NewLine;&lbrace;&NewLine;Connect-ExchangeOnline&NewLine;&rcub;&NewLine;&NewLine; &dollar;Users &equals; import-csv 'C&colon;&bsol;CSV&bsol;MailboxListIsHere&period;csv'&NewLine; &dollar;ServiceAccount &equals; 'Your Account that will access other Mailboxes' &num;&sol;&sol; Please change the SVC account before running the code&NewLine; &NewLine;&NewLine; foreach &lpar;&dollar;User in &dollar;users&rpar;&NewLine; &lbrace;&NewLine; &dollar;Mailbox &equals; &dollar;User&period;Identity&NewLine; &NewLine; &num;Checking Full Access&NewLine; &dollar;Full &equals; Get-MailboxPermission -Identity &dollar;Mailbox -User &dollar;ServiceAccount&NewLine; If &lpar;&dollar;Full&period;AccessRights -eq "FullAccess"&rpar;&NewLine; &lbrace;&NewLine; Write-Host -f Green &dollar;&lpar;&dollar;ServiceAccount&rpar; "Already has Full access to &dollar;Mailbox&period;"&rcub;&NewLine; &NewLine; Else&NewLine; &lbrace;&NewLine; &dollar;Answer1 &equals; Read-Host "Do you want to assign &dollar;&lpar;&dollar;ServiceAccount&rpar; Full access to &dollar;Mailbox &lpar;Yes or No&rpar;"&NewLine; If &lpar;&dollar;Answer1 -eq "Yes"&rpar;&NewLine; &lbrace;&NewLine; Try&lbrace;&NewLine; Add-MailboxPermission -Identity &dollar;Mailbox -User &dollar;ServiceAccount -AccessRights FullAccess&NewLine; Write-Host -f DarkGreen &dollar;&lpar;&dollar;ServiceAccount&rpar; "Send-as access has been added to &dollar;Mailbox"&NewLine; &rcub;&NewLine; &NewLine; Catch&lbrace; &lpar;&dollar;Full&period;AccessRights -eq "FullAccess"&rpar;&rcub;&NewLine; &NewLine; &rcub;&NewLine; &NewLine; &rcub;&NewLine; &NewLine; &dollar;SendAs &equals; Get-RecipientPermission -Identity &dollar;Mailbox -Trustee &dollar;ServiceAccount -AccessRights SendAs&NewLine; if&lpar;&dollar;SendAs&period;AccessRights -eq "SendAs"&rpar; &lbrace;&NewLine; Write-Host -f Green &dollar;&lpar;&dollar;ServiceAccount&rpar; "Already has SendAs access to &dollar;Mailbox&period;"&NewLine; &rcub;&NewLine; Else&NewLine; &lbrace;&NewLine; &dollar;Answer2 &equals; Read-Host "Do you want to assign &dollar;&lpar;&dollar;ServiceAccount&rpar; Send-as access to &dollar;Mailbox &lpar;Yes or No&rpar;"&NewLine; If &lpar;&dollar;Answer2 -eq "Yes"&rpar;&NewLine; &lbrace;&NewLine; Try&lbrace;&NewLine; Add-RecipientPermission -Identity &dollar;Mailbox -AccessRights SendAs -Trustee &dollar;ServiceAccount&NewLine; Write-Host -f Green &dollar;&lpar;&dollar;ServiceAccount&rpar; "has Send-as access on &dollar;Mailbox"&NewLine; &rcub;&NewLine; Catch&lbrace;&lpar;&dollar;SendAs&period;AccessRights -eq "Sendas"&rpar;&rcub;&rcub;&NewLine; else&lbrace;Exit&rcub;&NewLine; &rcub;&NewLine; &rcub;&NewLine; &rcub;&NewLine; &NewLine; &NewLine;<&sol;pre>&NewLine;<&sol;p>&NewLine;<&excl;-- WP QUADS Content Ad Plugin v&period; 2&period;0&period;93 -->&NewLine;<div class&equals;"quads-location quads-ad2525 " id&equals;"quads-ad2525" style&equals;"float&colon;none&semi;margin&colon;0px 3px 3px 3px&semi;padding&colon;0px 0px 0px 0px&semi;" data-lazydelay&equals;"0">&NewLine;&NewLine;<&sol;div>&NewLine;&NewLine;

moh10ly

Recent Posts

Reset passwords for Active Directory Users

Reset and manage your Active Directory users' Passwords Active Directory is one of the most…

3 years ago

Finding Exchange Database hidden mailboxes. ​

Finding Exchange Database hidden mailboxes. Story:Maybe you have been in this situation before, trying to…

3 years ago

Setting up ADConnect and PTA (Password auth through) servers agents behind proxy

If you're using a Proxy server in your firewall or in your network and have…

3 years ago

Get Report of Active Directory Locked Accounts and Machine they logged in from

Story:I got some clients  that have reported some of their users being locked out and…

3 years ago

Retrieving attachments from Exchange mailbox using python

Story: I got a request from a client who constantly gets CVs and have to…

4 years ago

550 relay not permitted distribution group contact

550 relay not permitted distribution group contact Symptoms When trying to add an external contact…

4 years ago

Warning: Undefined array key "adsense_ad_type" in /www/wwwroot/www.moh10ly.com/wp-content/plugins/quick-adsense-reloaded/includes/amp-condition-display.php on line 298

Warning: Undefined array key "adsense_ad_type" in /www/wwwroot/www.moh10ly.com/wp-content/plugins/quick-adsense-reloaded/includes/amp-condition-display.php on line 298

Warning: Undefined array key "adsense_ad_type" in /www/wwwroot/www.moh10ly.com/wp-content/plugins/quick-adsense-reloaded/includes/amp-condition-display.php on line 298

Warning: Undefined array key "adsense_ad_type" in /www/wwwroot/www.moh10ly.com/wp-content/plugins/quick-adsense-reloaded/includes/amp-condition-display.php on line 298

Warning: Undefined array key "adsense_ad_type" in /www/wwwroot/www.moh10ly.com/wp-content/plugins/quick-adsense-reloaded/includes/amp-condition-display.php on line 298

Warning: Undefined array key "adsense_ad_type" in /www/wwwroot/www.moh10ly.com/wp-content/plugins/quick-adsense-reloaded/includes/amp-condition-display.php on line 298

Warning: Undefined array key "adsense_ad_type" in /www/wwwroot/www.moh10ly.com/wp-content/plugins/quick-adsense-reloaded/includes/amp-condition-display.php on line 298

Warning: Undefined array key "adsense_ad_type" in /www/wwwroot/www.moh10ly.com/wp-content/plugins/quick-adsense-reloaded/includes/amp-condition-display.php on line 298

Warning: Undefined array key "adsense_ad_type" in /www/wwwroot/www.moh10ly.com/wp-content/plugins/quick-adsense-reloaded/includes/amp-condition-display.php on line 298

Warning: Undefined array key "adsense_ad_type" in /www/wwwroot/www.moh10ly.com/wp-content/plugins/quick-adsense-reloaded/includes/amp-condition-display.php on line 298

Warning: Undefined array key "adsense_ad_type" in /www/wwwroot/www.moh10ly.com/wp-content/plugins/quick-adsense-reloaded/includes/amp-condition-display.php on line 298

Warning: Undefined array key "adsense_ad_type" in /www/wwwroot/www.moh10ly.com/wp-content/plugins/quick-adsense-reloaded/includes/amp-condition-display.php on line 298

Warning: Undefined array key "adsense_ad_type" in /www/wwwroot/www.moh10ly.com/wp-content/plugins/quick-adsense-reloaded/includes/amp-condition-display.php on line 298

Warning: Undefined array key "adsense_ad_type" in /www/wwwroot/www.moh10ly.com/wp-content/plugins/quick-adsense-reloaded/includes/amp-condition-display.php on line 298

Warning: Undefined array key "adsense_ad_type" in /www/wwwroot/www.moh10ly.com/wp-content/plugins/quick-adsense-reloaded/includes/amp-condition-display.php on line 298

Warning: Undefined array key "adsense_ad_type" in /www/wwwroot/www.moh10ly.com/wp-content/plugins/quick-adsense-reloaded/includes/amp-condition-display.php on line 298

Warning: Undefined array key "adsense_ad_type" in /www/wwwroot/www.moh10ly.com/wp-content/plugins/quick-adsense-reloaded/includes/amp-condition-display.php on line 298

Warning: Undefined array key "adsense_ad_type" in /www/wwwroot/www.moh10ly.com/wp-content/plugins/quick-adsense-reloaded/includes/amp-condition-display.php on line 298