Export Office 365 users from specific domain and change their passwords

&NewLine;<&excl;-- WP QUADS Content Ad Plugin v&period; 2&period;0&period;92 -->&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;<p>First of all you will need to connect to your tenant with your global admin account using the following script<&sol;p>&NewLine;<&excl;-- WP QUADS Content Ad Plugin v&period; 2&period;0&period;92 -->&NewLine;<div class&equals;"quads-location quads-ad2524 " id&equals;"quads-ad2524" 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;92 -->&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;<&excl;-- WP QUADS Content Ad Plugin v&period; 2&period;0&period;92 -->&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;&NewLine;&NewLine;&NewLine;<p>Import-Module MSOnline<&sol;p>&NewLine;&NewLine;&NewLine;&NewLine;<p>&dollar;O365Cred &equals; Get-Credential<&sol;p>&NewLine;&NewLine;&NewLine;&NewLine;<p>&dollar;O365Session &equals; New-PSSession –ConfigurationName Microsoft&period;Exchange -ConnectionUri<a href&equals;"https&colon;&sol;&sol;www&period;google&period;com&sol;url&quest;q&equals;https&percnt;3A&percnt;2F&percnt;2Fps&period;outlook&period;com&percnt;2Fpowershell&amp&semi;sa&equals;D&amp&semi;sntz&equals;1&amp&semi;usg&equals;AFQjCNG6kFRYvmIcjlQdnFK1Kf4g8-0vgg" target&equals;"&lowbar;blank" rel&equals;"noreferrer noopener">https&colon;&sol;&sol;ps&period;outlook&period;com&sol;powershell<&sol;a> -Credential &dollar;O365Cred -Authentication Basic -AllowRedirection<&sol;p>&NewLine;&NewLine;&NewLine;&NewLine;<p>Import-PSSession &dollar;O365Session<&sol;p>&NewLine;&NewLine;&NewLine;&NewLine;<p>Connect-MsolService –Credential &dollar;O365Cred<&sol;p>&NewLine;&NewLine;&NewLine;&NewLine;<p>After connecting you will need to type the following command line which will export all users in a specific domain that&&num;8217&semi;s added to your portal if you have more than one domain added there&period;<&sol;p>&NewLine;&NewLine;&NewLine;&NewLine;<p>Get-MsolUser -DomainName Domain&period;com &vert; Select UserPrincipalName &vert; Export-Csv C&colon;&bsol;users&period;csv –NoTypeInformation<&sol;p>&NewLine;<&excl;-- WP QUADS Content Ad Plugin v&period; 2&period;0&period;92 -->&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;<figure class&equals;"wp-block-image"><img src&equals;"http&colon;&sol;&sol;lh6&period;ggpht&period;com&sol;-Mb2RzsW7GkA&sol;VN3zkjoC0UI&sol;AAAAAAAAMrE&sol;MIQRvSHpJyc&sol;clip&lowbar;image001&lowbar;thumb&percnt;25255B1&percnt;25255D&period;png&quest;imgmax&equals;800" alt&equals;"clip&lowbar;image001"&sol;> &NewLine;&NewLine;<&excl;-- WP QUADS Content Ad Plugin v&period; 2&period;0&period;92 -->&NewLine;<div class&equals;"quads-location quads-ad2529 " id&equals;"quads-ad2529" 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;<&sol;figure>&NewLine;&NewLine;&NewLine;&NewLine;<p>Change passwords for those users by using the following command and pressing enter you&&num;8217&semi;ll be giving a line to enter your new password that you wanna set for all users in the exported file&period;<&sol;p>&NewLine;&NewLine;&NewLine;&NewLine;<p>&dollar;PASS &equals; Read-Host<&sol;p>&NewLine;&NewLine;&NewLine;&NewLine;<figure class&equals;"wp-block-image"><img src&equals;"http&colon;&sol;&sol;lh3&period;ggpht&period;com&sol;-4u7J1rAQ18A&sol;VN3zmf-EBbI&sol;AAAAAAAAMrU&sol;WbDQ8PNUo0Y&sol;clip&lowbar;image002&lowbar;thumb&percnt;25255B1&percnt;25255D&period;png&quest;imgmax&equals;800" alt&equals;"clip&lowbar;image002"&sol;><&sol;figure>&NewLine;&NewLine;&NewLine;&NewLine;<p>Run this command to change the passwords<&sol;p>&NewLine;&NewLine;&NewLine;&NewLine;<p>Import-Csv C&colon;&bsol;Users&period;csv &vert; &percnt; &lbrace;Set-MsolUserPassword -userPrincipalName &dollar;&lowbar;&period;UserPrincipalName -NewPassword &dollar;PASS -ForceChangePassword &dollar;True&rcub;<&sol;p>&NewLine;&NewLine;&NewLine;&NewLine;<figure class&equals;"wp-block-image"><img src&equals;"http&colon;&sol;&sol;lh6&period;ggpht&period;com&sol;-04McFQJ9Nz0&sol;VN3zoPH0YHI&sol;AAAAAAAAMrk&sol;XZc-xCUyw8I&sol;clip&lowbar;image003&lowbar;thumb&percnt;25255B1&percnt;25255D&period;png&quest;imgmax&equals;800" alt&equals;"clip&lowbar;image003"&sol;><&sol;figure>&NewLine;&NewLine;&NewLine;&NewLine;<p>That&&num;8217&semi;s it&period; Now users inside the exported csv file have the new password which you have just set&period;<&sol;p>&NewLine;&NewLine;&NewLine;&NewLine;<p>Note that users will be prompted to reset their passwords upon login&comma; if you don&&num;8217&semi;t want this to happen you can remove the -ForceChangePassword &dollar;True parameter&period;<&sol;p>&NewLine;<&excl;-- WP QUADS Content Ad Plugin v&period; 2&period;0&period;92 -->&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;&NewLine;&NewLine;&NewLine;<p>del&period;icio&period;us Tags&colon; <a href&equals;"http&colon;&sol;&sol;www&period;google&period;com&sol;url&quest;q&equals;http&percnt;3A&percnt;2F&percnt;2Fdel&period;icio&period;us&percnt;2Fpopular&percnt;2FOffice365&amp&semi;sa&equals;D&amp&semi;sntz&equals;1&amp&semi;usg&equals;AFQjCNGSTlfkH-KDWW6MMgoVtonTkrUcZg" target&equals;"&lowbar;blank" rel&equals;"noreferrer noopener">Office365<&sol;a>&comma;<a href&equals;"http&colon;&sol;&sol;www&period;google&period;com&sol;url&quest;q&equals;http&percnt;3A&percnt;2F&percnt;2Fdel&period;icio&period;us&percnt;2Fpopular&percnt;2FOffice&percnt;2B365&amp&semi;sa&equals;D&amp&semi;sntz&equals;1&amp&semi;usg&equals;AFQjCNESMLAbwuAQ0Ic0oEcAZd5bseYYaQ" target&equals;"&lowbar;blank" rel&equals;"noreferrer noopener">Office 365<&sol;a>&comma;<a href&equals;"http&colon;&sol;&sol;www&period;google&period;com&sol;url&quest;q&equals;http&percnt;3A&percnt;2F&percnt;2Fdel&period;icio&period;us&percnt;2Fpopular&percnt;2FExchange&percnt;2BOnline&amp&semi;sa&equals;D&amp&semi;sntz&equals;1&amp&semi;usg&equals;AFQjCNGAKLITuQ2LKs3cbIDQ6lHsaXomBA" target&equals;"&lowbar;blank" rel&equals;"noreferrer noopener">Exchange Online<&sol;a>&comma;<a href&equals;"http&colon;&sol;&sol;www&period;google&period;com&sol;url&quest;q&equals;http&percnt;3A&percnt;2F&percnt;2Fdel&period;icio&period;us&percnt;2Fpopular&percnt;2FAzure&amp&semi;sa&equals;D&amp&semi;sntz&equals;1&amp&semi;usg&equals;AFQjCNE&lowbar;bbK04iwfa1UOx5IWXxHCM4JfgA" target&equals;"&lowbar;blank" rel&equals;"noreferrer noopener">Azure<&sol;a><br><&sol;p>&NewLine;&NewLine;<&excl;-- WP QUADS Content Ad Plugin v&period; 2&period;0&period;92 -->&NewLine;<div class&equals;"quads-location quads-ad2523 " id&equals;"quads-ad2523" 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

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

Delegate Permissions This is a code that I have wrote recently to check if an…

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

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