<!-- WP QUADS Content Ad Plugin v. 2.0.93 -->
<div class="quads-location quads-ad2526 " id="quads-ad2526" style="float:none;margin:0px 3px 3px 3px;padding:0px 0px 0px 0px;" data-lazydelay="0">

</div>

<h1 class="wp-block-heading" id="h.p_ID_32">Export users licenses and information O365</h1>



<p></p>



<p>In order to Export users licenses and information from Office 365 you will have to use the following script.</p>
<!-- WP QUADS Content Ad Plugin v. 2.0.93 -->
<div class="quads-location quads-ad2528 " id="quads-ad2528" style="float:none;margin:0px 3px 3px 3px;padding:0px 0px 0px 0px;" data-lazydelay="0">

</div>

<!-- WP QUADS Content Ad Plugin v. 2.0.93 -->
<div class="quads-location quads-ad2527 " id="quads-ad2527" style="float:none;margin:0px 3px 3px 3px;padding:0px 0px 0px 0px;" data-lazydelay="0">

</div>

<!-- WP QUADS Content Ad Plugin v. 2.0.93 -->
<div class="quads-location quads-ad2522 " id="quads-ad2522" style="float:none;margin:0px 3px 3px 3px;padding:0px 0px 0px 0px;" data-lazydelay="0">

</div>




<p>First you will need to connect to MS Online service with a Global admin account</p>



<p>Connect-MsolService</p>



<p>Get-MsolUser -All |Where {$_.IsLicensed -eq $true } |Select DisplayName,UsageLocation,@{n=&#8221;Licenses <a href="mailto:Type" target="_blank" rel="noreferrer noopener">Type&#8221;;e={$_.Licenses.AccountSKUid}},SignInName,UserPrincipalName,@{n=&#8221;ProxyAddresses&#8221;;e={$_.ProxyAddresses}}|</a> Export-csv -Path C:\ExportlicenseUsage.csv –notype</p>



<figure class="wp-block-image"><a href="http://lh3.googleusercontent.com/-X3Gn6_MH3iY/VUykRVsOcBI/AAAAAAAAOng/OX_AEtLO3y0/s1600-h/image%25255B2%25255D.png" target="_blank" rel="noreferrer noopener"><img src="https://lh3.googleusercontent.com/gu_tNzscBTRci995y22Sf9wO-YROZUm8dJKXHsv2mq2dfHFYqlwpx19S41ymsJjscZKoiAQzZFU7uYL3t-zMVCOD7JdvmUsXmrVavrELot4RCu-AWqk=w371" alt="image"/></a> 

<!-- WP QUADS Content Ad Plugin v. 2.0.93 -->
<div class="quads-location quads-ad2523 " id="quads-ad2523" style="float:none;margin:0px 3px 3px 3px;padding:0px 0px 0px 0px;" data-lazydelay="0">

</div>
 
</figure>



<figure class="wp-block-image"><a href="http://lh3.googleusercontent.com/-AUY5CmHGr1k/VUykTOL8hII/AAAAAAAAOnw/y9yEsKZGIA0/s1600-h/clip_image001%25255B3%25255D.png" target="_blank" rel="noreferrer noopener"><img src="https://lh5.googleusercontent.com/sqDEJXhgycg7sCsDJCh5xSLxhxA9_v2jdoNJvwg7D3Jh6-mW2tgJ1YevGgdhGYYQFNvo2Xpv3aesNdVXL4hJYkLBMb987i3k4R-e3BcX89eOZDRpyBs=w673" alt="clip_image001"/></a></figure>



<p>This will export a file called “ExportLicenseUsage.csv” to your C root drive. you can open this file with Microsoft Excel and find out all the useful information that you’re looking for.</p>



<p>Hope this helps </p>



<h1 class="wp-block-heading" id="h.p_ID_114"><a href="https://www.moh10ly.com/blog/office-365/useful-powershell-cmdlets#h.p_ID_114"></a>Testing Office 365 SMTP relay</h1>



<p></p>



<p>In order to test Office 365 SMTP relay you will have to create a user with an Exchange online license. After the email is activated for this user you can test this user for relay with the following powershell.</p>



<p>First connect to Microsoft Online service with this user that you’ll be using for relaying.</p>



<p><strong>$msolcred = Get-Credential</strong></p>



<p>Next edit the following powershell with the user’s e-mail and the recipient&#8217;s too</p>



<p>Send-MailMessage –From <a href="mailto:RelaySMTPuser@domain.com" target="_blank" rel="noreferrer noopener">RelaySMTPuser@domain.com</a> –To <a href="mailto:destinationuser@gmail.com" target="_blank" rel="noreferrer noopener">destinationuser@gmail.com</a> –Subject “Test Email” –Body “Test SMTP Relay Service” -SmtpServersmtp.office365.com -Credential $msolcred -UseSsl -Port 587</p>



<figure class="wp-block-image"><img src="https://lh4.googleusercontent.com/A5kjt64iyoJbqmsVIBoMcYVK2dkFGW3v-Tp64AvOXfOgYh3TTeMJZjDmV3UybaWGuNY3G9A=w70" alt="Smile"/></figure>



<figure class="wp-block-image"><a href="http://lh3.googleusercontent.com/-cxGnGOu_2uQ/VUyiXSlarQI/AAAAAAAAOm0/kqLNtJJTb90/s1600-h/clip_image001%25255B3%25255D.png" target="_blank" rel="noreferrer noopener"><img src="https://lh5.googleusercontent.com/NlHC64WV1gPYm6tCazO_Lw0oE01qpY-IOET9cU0RBD3FM-i_3mCSikRMs39OGjlPI-ABIjVmUpoa_MxutfALNgGB99_DFm6fQOb0pJcrrq2n_-QSUw=w673" alt="clip_image001"/></a></figure>



<figure class="wp-block-image"><a href="http://lh3.googleusercontent.com/-t3h4t8x9sgM/VUyiZYm4I1I/AAAAAAAAOnE/WynFyHOqF2k/s1600-h/clip_image002%25255B3%25255D.png" target="_blank" rel="noreferrer noopener"><img src="https://lh6.googleusercontent.com/i0ls3eQjx_CqpeUthBE_fUPbUtGYMm_xh9V2lZawROHFBh4Q5j3b7qQYpIV_3C_t0lkC0Kk5E4xVdW44JYMg9iqcB14Mf2q__6xfKm9TpJi4LGR_IE8=w673" alt="clip_image002"/></a></figure>



<p><a href="https://technet.microsoft.com/en-us/library/dn554323(v=exchg.150).aspx">https://technet.microsoft.com/en-us/library/dn554323(v=exchg.150).aspx</a></p>



<p>This test is known as Client SMTP submission you can also use a different method for multiple devices where you can configure them all to point to a single server (IIS) in a method known as IIS for relay with Office 365 however, all the methods what involve office 365 (Only) for relay will require a user with Exchange online license assigned to it.</p>



<p><a href="https://technet.microsoft.com/en-us/library/dn592151%28v=exchg.150%29.aspx">https://technet.microsoft.com/en-us/library/dn592151%28v=exchg.150%29.aspx</a></p>



<h1 class="wp-block-heading" id="h.p_ID_196"><a href="https://www.moh10ly.com/blog/office-365/useful-powershell-cmdlets#h.p_ID_196"></a>Search for users start with particular letters in the display name</h1>



<p><em> <a href="https://plus.google.com/111669386109520391003" target="_blank" rel="noreferrer noopener">Mohammed Hamada</a> <a href="http://www.google.com/url?q=http%3A%2F%2Fwww.moh10ly.website%2F2015%2F05%2Fsearch-for-users-start-with-particular.html&;sa=D&;sntz=1&;usg=AFQjCNFZvya-icvdRaS2K1NHtz8fFHF30A" target="_blank" rel="noreferrer noopener">5:49 AM</a> <a href="http://www.google.com/url?q=http%3A%2F%2Fwww.moh10ly.website%2Fsearch%2Flabel%2FExchange%2520Online&;sa=D&;sntz=1&;usg=AFQjCNFn-Lovc3bYH-iMZ7z1cgz7MaQx4A" target="_blank" rel="noreferrer noopener">Exchange Online</a> , <a href="http://www.google.com/url?q=http%3A%2F%2Fwww.moh10ly.website%2Fsearch%2Flabel%2FOffice%2520365&;sa=D&;sntz=1&;usg=AFQjCNEqFMqLATWUzWZh_qry3mf8-Y7IeQ" target="_blank" rel="noreferrer noopener">Office 365</a> , <a href="http://www.google.com/url?q=http%3A%2F%2Fwww.moh10ly.website%2Fsearch%2Flabel%2FOffice365&;sa=D&;sntz=1&;usg=AFQjCNEhTbzgkSYkr7BhPJsVlwYBr1FkxA" target="_blank" rel="noreferrer noopener">Office365</a> , <a href="http://www.google.com/url?q=http%3A%2F%2Fwww.moh10ly.website%2Fsearch%2Flabel%2FPowershell&;sa=D&;sntz=1&;usg=AFQjCNGywUoJxzWVxpA-mnFUbAQ6lN8Wig" target="_blank" rel="noreferrer noopener">Powershell</a></em></p>



<p>To search your Office 365 users with particular initial characters</p>



<p>First connect to Microsoft Online Service</p>



<p>To Search for users whom their display names contain “Top” you can use the following powershell</p>



<p>get-msoluser -all | where-object {$_.displayname -like &#8220;top*&#8221;} | ft displayname,userprincipalname,proxyaddresses</p>



<figure class="wp-block-image"><a href="http://lh3.googleusercontent.com/-sFeohqQnsQs/VUywvJDoE4I/AAAAAAAAOoQ/daHPRDP-ndA/s1600-h/clip_image001%25255B3%25255D.png" target="_blank" rel="noreferrer noopener"><img src="https://lh5.googleusercontent.com/nIV96KJ0pneJUPoMmgeBsFVdnxTUvQXAgIyTzhdQerArXBGomB5z2Vr4tKZsUCNYw69ufBKF=w371" alt="clip_image001"/></a></figure>



<figure class="wp-block-image"><a href="http://lh3.googleusercontent.com/-kxhVDddYUsc/VUyww3WNJzI/AAAAAAAAOoc/Mgwy0le9yQs/s1600-h/image%25255B2%25255D.png" target="_blank" rel="noreferrer noopener"><img src="https://lh6.googleusercontent.com/4mEZqFVNUJfBk-veFvFgixAv9HLuw2sPNq-hEWv1nCAw8XhPoY_NcEq-UAd-MudnrO0F6FHlAUguNRNmHiiYMrvmMmRqh6y8MAiZimYUOkOCANirtrU=w673" alt="image"/></a></figure>



<p>Search for users whom their UPN contains “TOP” in the start</p>



<p><strong>get-msoluser -all | where-object {$_.userprincipalname -like &#8220;top*&#8221;} | ft displayname,userprincipalname,proxyaddresses</strong></p>
<!-- WP QUADS Content Ad Plugin v. 2.0.93 -->
<div class="quads-location quads-ad2524 " id="quads-ad2524" style="float:none;margin:0px 3px 3px 3px;padding:0px 0px 0px 0px;" data-lazydelay="0">

</div>




<figure class="wp-block-image"><a href="http://lh3.googleusercontent.com/-ikqF7SXV3_A/VUywy9VcDqI/AAAAAAAAOow/4G9tGACGugo/s1600-h/image%25255B5%25255D.png" target="_blank" rel="noreferrer noopener"><img src="https://lh6.googleusercontent.com/O6RRecnuamliVP8kQy7-gOU9jYZJ-tBI0Y5HV88FLxGIfd0hKL6zuO9N3fEhxYbv2u2Yyq8=w673" alt="image"/></a></figure>



<h1 class="wp-block-heading" id="h.p_ID_302"><a href="https://www.moh10ly.com/blog/office-365/useful-powershell-cmdlets#h.p_ID_302"></a>Office 365: Add additional accepted domain to SMTP Address</h1>



<p><em> <a href="https://plus.google.com/111669386109520391003" target="_blank" rel="noreferrer noopener">Mohammed Hamada</a> <a href="http://www.google.com/url?q=http%3A%2F%2Fwww.moh10ly.website%2F2015%2F05%2Foffice-365-add-additional-accepted.html&;sa=D&;sntz=1&;usg=AFQjCNE4ld4jIvBm8c94HSn7FAPPuYQAow" target="_blank" rel="noreferrer noopener">5:50 AM</a> <a href="http://www.google.com/url?q=http%3A%2F%2Fwww.moh10ly.website%2Fsearch%2Flabel%2FExchange%2520Online&;sa=D&;sntz=1&;usg=AFQjCNFn-Lovc3bYH-iMZ7z1cgz7MaQx4A" target="_blank" rel="noreferrer noopener">Exchange Online</a> , <a href="http://www.google.com/url?q=http%3A%2F%2Fwww.moh10ly.website%2Fsearch%2Flabel%2FOffice%2520365&;sa=D&;sntz=1&;usg=AFQjCNEqFMqLATWUzWZh_qry3mf8-Y7IeQ" target="_blank" rel="noreferrer noopener">Office 365</a> , <a href="http://www.google.com/url?q=http%3A%2F%2Fwww.moh10ly.website%2Fsearch%2Flabel%2FOffice365&;sa=D&;sntz=1&;usg=AFQjCNEhTbzgkSYkr7BhPJsVlwYBr1FkxA" target="_blank" rel="noreferrer noopener">Office365</a> , <a href="http://www.google.com/url?q=http%3A%2F%2Fwww.moh10ly.website%2Fsearch%2Flabel%2FPowershell&;sa=D&;sntz=1&;usg=AFQjCNGywUoJxzWVxpA-mnFUbAQ6lN8Wig" target="_blank" rel="noreferrer noopener">Powershell</a></em></p>



<p>If you have configured Hybrid integration between Exchange 2010/2013 with Office 365 using dirSnyc or Azure active directory sync tool and then stopped the synchronization. The accepted domains and additional domains will be removed from the user’s Attributes on the cloud and in order to add these accepted domains again to all of the Office 365 users..</p>



<p>First we’ll have to connect to Exchange online with the following powershell tool. so Launch Azure powershell as Admin and copy the following line by line.</p>



<p>1- $UserCredential = Get-Credential</p>



<p>2- $Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri<a href="https://www.google.com/url?q=https%3A%2F%2Foutlook.office365.com%2Fpowershell-liveid%2F&;sa=D&;sntz=1&;usg=AFQjCNE74gmiYTRnnzPfYTBhAB0rGbcT2Q" target="_blank" rel="noreferrer noopener">https://outlook.office365.com/powershell-liveid/</a> -Credential $UserCredential -Authentication Basic -AllowRedirection</p>



<p>3- Import-PSSession $Session</p>



<figure class="wp-block-image"><a href="http://lh3.googleusercontent.com/-G6-8Dd02zXI/VVCla1TY5_I/AAAAAAAAOpY/TQ8DPyD821A/s1600-h/image%25255B2%25255D.png" target="_blank" rel="noreferrer noopener"><img src="https://lh6.googleusercontent.com/z4w8ej3wIyvfoLcq-EgHmRO66iYoX6yQMN1u1FjnlKuIWKPtPg5MMkleLNYWiqlToKZRlUgQS0sNWSh6RS2JsbZve1wejOx6opKQlhfoUEHlDsYsWeZ3=w673" alt="image"/></a></figure>



<p>First we’ll show/view user’s existing SMTP addresses, in order to do so we’ll use the following PowerShell cmdlet</p>



<p>For all users</p>



<p>4- <strong>Get-Mailbox | fl –property Alias, WindowsLiveID, EmailAddresses</strong></p>



<p>For one user</p>



<p><strong>Get-Mailbox –Identity <a href="mailto:user@domain.com" target="_blank" rel="noreferrer noopener">user@domain.com</a> | fl –property Alias, WindowsLiveID, EmailAddresses</strong></p>



<figure class="wp-block-image"><a href="http://lh3.googleusercontent.com/-mQ2d9ibLTXM/VVClcnKQ-rI/AAAAAAAAOpk/N0p7EZG3W90/s1600-h/image%25255B5%25255D.png" target="_blank" rel="noreferrer noopener"><img src="https://lh3.googleusercontent.com/xYdEWJASdbPRqE2pdmMaeBbNxXB8aQZUbOTCCDKmC47yTJ0bkw0GkIUNha-OGS03TvYeIsjZJ8qpvnEKuiaxAWvAbhv4DCBtit9xbSdddwE4imA09TQ=w673" alt="image"/></a></figure>



<p>Procedure to add an additional accepted domain to all users in the Office 365 tenant.</p>



<p><strong>Note:</strong></p>



<p>The domain must be verified on Office 365 first before applying those steps</p>



<p>1-</p>



<p>$users = Get-Mailbox</p>



<p>2-</p>



<p>foreach ($a in $users) {$a.emailaddresses.add(&#8220;smtp:$($a.alias)@AdditionalDomain.com&#8221;)}</p>



<figure class="wp-block-image"><a href="http://lh3.googleusercontent.com/--KKiuS3dZGI/VVCleVxoolI/AAAAAAAAOp0/spx82OvzcBc/s1600-h/image%25255B8%25255D.png" target="_blank" rel="noreferrer noopener"><img src="https://lh6.googleusercontent.com/gtXlvB-8OMAOhH0Z54b0r_aYRBE4_6zBd6ExODu1BaxG2xFv2li_Gw8dgWO8D4pYuXJ7XmbQyBxH-v9XwyKRb4KcB_zWQams0IhrEMaGUdKql791Li8=w371" alt="image"/></a></figure>



<figure class="wp-block-image"><a href="http://lh3.googleusercontent.com/-NW1MErWMJsY/VVClgKGJPbI/AAAAAAAAOqI/n5k9LfAC48Y/s1600-h/image%25255B11%25255D.png" target="_blank" rel="noreferrer noopener"><img src="https://lh6.googleusercontent.com/WC3AA2qRyMk_wvit2vsfl_aCGbbp5Q8KfhbYOe8pr4a_fyZy7kHTE1nhCApmRHWOOBGPELctjYtpv7Y3oSvNsibE0e7UtowoLYnFR8p9KV4JKsrFgQ=w673" alt="image"/></a></figure>



<p>3-</p>
<!-- WP QUADS Content Ad Plugin v. 2.0.93 -->
<div class="quads-location quads-ad2531 " id="quads-ad2531" style="float:none;margin:0px 3px 3px 3px;padding:0px 0px 0px 0px;" data-lazydelay="0">

</div>




<figure class="wp-block-image"><a href="http://lh3.googleusercontent.com/-pXRJwiCwFPk/VVClh8bZq6I/AAAAAAAAOqY/E9nOWDD3mbE/s1600-h/clip_image003%25255B3%25255D.png" target="_blank" rel="noreferrer noopener"><img src="https://lh4.googleusercontent.com/-SywZ5EJJCOhJZ0pA4_BJaPKsmA0sHI1n_X7B4DTDriV3TUwGmJm392KTTv8coSNC-m49-GcZfCzp5gp0flGSIZnsJfdc4U3AAt9f08-IePX-wZeSeI=w673" alt="clip_image003"/></a></figure>



<p>$users | %{Set-Mailbox $_.Identity -WindowsEmailAddress $_.WindowsEmailAddress}<br></p>

<!-- WP QUADS Content Ad Plugin v. 2.0.93 -->
<div class="quads-location quads-ad2525 " id="quads-ad2525" style="float:none;margin:0px 3px 3px 3px;padding:0px 0px 0px 0px;" data-lazydelay="0">

</div>


Reset and manage your Active Directory users' Passwords Active Directory is one of the most…
Finding Exchange Database hidden mailboxes. Story:Maybe you have been in this situation before, trying to…
If you're using a Proxy server in your firewall or in your network and have…
Story:I got some clients that have reported some of their users being locked out and…
Delegate Permissions This is a code that I have wrote recently to check if an…
Story: I got a request from a client who constantly gets CVs and have to…