{"id":1388,"date":"2018-03-09T09:21:28","date_gmt":"2018-03-09T07:21:28","guid":{"rendered":"https:\/\/msb365.abstergo.ch\/?p=1388"},"modified":"2023-06-23T13:25:09","modified_gmt":"2023-06-23T11:25:09","slug":"another-10-useful-powershell-cmdlets-for-exchange","status":"publish","type":"post","link":"https:\/\/www.msb365.blog\/?p=1388","title":{"rendered":"Another 10 useful PowerShell cmdlets for Exchange"},"content":{"rendered":"<p>After all the positive feedback to my article \u201c<a href=\"https:\/\/msb365.abstergo.ch\/?p=1202\" target=\"_blank\" rel=\"noopener\">10 Useful PowerShell cmdlets for Exchange<\/a>\u201d (thanks again to <a href=\"https:\/\/www.linkedin.com\/in\/spgoodman\" target=\"_blank\" rel=\"noopener\">Steve Goodman<\/a>), I have decided to write a second part of it with another 10 useful PowerShell commands for Exchange and Office 365.<\/p>\n<p>Same procedure as the last time. Some of you may already know the commands, but for some of you they are maybe new\u2026<\/p>\n<p>In any case, I wish you fun with reading this article\u2026<\/p>\n<p>\u00a0<\/p>\n<p>This time, I will start with a command for Office365 and Exchange\u2026<\/p>\n<p>\u00a0<\/p>\n<hr \/>\n<h4>1 GET-MIGRATIONUSER<\/h4>\n<p>\u00a0<\/p>\n<p>Migrating mailboxes from one Exchange to another, or even to Exchange Online is no rocket science anymore. How to do that, we can find in many articles in the Tech Blogs all over the world. I want to write here about how to check the status of the migration. All we need to do is to connect by PowerShell to the right endpoint. In this example, I am connecting to the Exchange Online by using the following command:<\/p>\n<pre class=\"\">$UserCredential = Get-Credential\r\n$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https:\/\/outlook.office365.com\/powershell-liveid\/ -Credential $UserCredential -Authentication Basic -AllowRedirection\r\nImport-PSSession $Session<\/pre>\n<p>\u00a0<\/p>\n<p>After I am connected to my endpoint, I can check the status of the migration batch with the following command:<\/p>\n<pre class=\"\">Get-MigrationUser -BatchId StagedBatch1 | Get-MigrationUserStatistics<\/pre>\n<p>As we can see in the screen shot, we get the status of any move request\u00a0within our migration batch.<\/p>\n<p><img fetchpriority=\"high\" decoding=\"async\" class=\"alignnone size-full wp-image-1390\" src=\"https:\/\/msb365.abstergo.ch\/wp-content\/uploads\/2018\/02\/1-7.png\" alt=\"\" width=\"802\" height=\"260\" srcset=\"https:\/\/msb365.abstergo.ch\/wp-content\/uploads\/2018\/02\/1-7.png 802w, https:\/\/msb365.abstergo.ch\/wp-content\/uploads\/2018\/02\/1-7-300x97.png 300w, https:\/\/msb365.abstergo.ch\/wp-content\/uploads\/2018\/02\/1-7-768x249.png 768w, https:\/\/msb365.abstergo.ch\/wp-content\/uploads\/2018\/02\/1-7-600x195.png 600w, https:\/\/msb365.abstergo.ch\/wp-content\/uploads\/2018\/02\/1-7-780x253.png 780w\" sizes=\"(max-width: 802px) 100vw, 802px\" \/><\/p>\n<p>By knowing this command and understanding PowerShell, we are free to modify this command as well. Here\u00b4s another example:<\/p>\n<pre class=\"\">Get-MigrationUser -BatchId BATCH | where {$_.Status -ne 'Completed'} | Get-MigrationUserStatistics<\/pre>\n<p>In this example, only those mailboxes will be shown, which don\u2019t have the status \u201ccompleted\u201d. This is very helpful\u00a0to keep an easy overview of huge migration batches .<\/p>\n<hr \/>\n<p>\u00a0<\/p>\n<h4>2 GET-MESSAGETRACKINGLOG<\/h4>\n<p>By working as an Exchange administrator or in 2<sup>nd<\/sup> level support, one of the main tasks is to track messages. Microsoft has created the Exchange Toolbox for this.<\/p>\n<p><img decoding=\"async\" class=\"alignnone size-full wp-image-1391\" src=\"https:\/\/msb365.abstergo.ch\/wp-content\/uploads\/2018\/02\/2-5.png\" alt=\"\" width=\"315\" height=\"114\" srcset=\"https:\/\/msb365.abstergo.ch\/wp-content\/uploads\/2018\/02\/2-5.png 315w, https:\/\/msb365.abstergo.ch\/wp-content\/uploads\/2018\/02\/2-5-300x109.png 300w\" sizes=\"(max-width: 315px) 100vw, 315px\" \/><\/p>\n<p>If we start it, we can see a collection of tools, which help us to investigate some issues.<\/p>\n<p><img decoding=\"async\" class=\"alignnone size-full wp-image-1392\" src=\"https:\/\/msb365.abstergo.ch\/wp-content\/uploads\/2018\/02\/3-5.png\" alt=\"\" width=\"1041\" height=\"750\" srcset=\"https:\/\/msb365.abstergo.ch\/wp-content\/uploads\/2018\/02\/3-5.png 1041w, https:\/\/msb365.abstergo.ch\/wp-content\/uploads\/2018\/02\/3-5-300x216.png 300w, https:\/\/msb365.abstergo.ch\/wp-content\/uploads\/2018\/02\/3-5-768x553.png 768w, https:\/\/msb365.abstergo.ch\/wp-content\/uploads\/2018\/02\/3-5-1024x738.png 1024w, https:\/\/msb365.abstergo.ch\/wp-content\/uploads\/2018\/02\/3-5-600x432.png 600w, https:\/\/msb365.abstergo.ch\/wp-content\/uploads\/2018\/02\/3-5-780x562.png 780w\" sizes=\"(max-width: 1041px) 100vw, 1041px\" \/><\/p>\n<p>However, to check the Tracking Log there is a faster and easier way to do it.<\/p>\n<p>We simply can use the following PowerShell command for that:<\/p>\n<pre class=\"\">Get-MessageTrackingLog -Start \"02\/26\/2018 08:23:00\" -End \"02\/28\/2018 17:00:00\" -Recipients $recipientSMTP -Server $ExchServer<\/pre>\n<p>In my example, I was searching for all mails sent during a time range on a specific exchange server, which have been sent to a specific recipient:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1393\" src=\"https:\/\/msb365.abstergo.ch\/wp-content\/uploads\/2018\/02\/4-10.png\" alt=\"\" width=\"1457\" height=\"212\" srcset=\"https:\/\/msb365.abstergo.ch\/wp-content\/uploads\/2018\/02\/4-10.png 1457w, https:\/\/msb365.abstergo.ch\/wp-content\/uploads\/2018\/02\/4-10-300x44.png 300w, https:\/\/msb365.abstergo.ch\/wp-content\/uploads\/2018\/02\/4-10-768x112.png 768w, https:\/\/msb365.abstergo.ch\/wp-content\/uploads\/2018\/02\/4-10-1024x149.png 1024w, https:\/\/msb365.abstergo.ch\/wp-content\/uploads\/2018\/02\/4-10-600x87.png 600w, https:\/\/msb365.abstergo.ch\/wp-content\/uploads\/2018\/02\/4-10-780x113.png 780w\" sizes=\"(max-width: 1457px) 100vw, 1457px\" \/><\/p>\n<p>However, there are also some other options for searching. Instead of searching by recipient, we are also able to search by:<\/p>\n<ul>\n<li>MessageSubject<\/li>\n<li>Reference<\/li>\n<li>Sender<\/li>\n<li>InternalMessageId<\/li>\n<li>MessageId<\/li>\n<\/ul>\n<p>\u00a0<\/p>\n<p>In the most cases we search for sender, recipient or message subject. You can see the output in the example above, with which we can work\u2026<\/p>\n<p>Another option is to create a Grid-View like I described in my\u00a0<a href=\"https:\/\/msb365.abstergo.ch\/?p=1202\" target=\"_blank\" rel=\"noopener\">other article<\/a> about PowerShell commands.<\/p>\n<p>Now, I want to show you a different option for creating nice reports:<\/p>\n<p>If we use the following command:<\/p>\n<pre class=\"\">Get-MessageTrackingLog -Start \"02\/26\/2018 09:00:00\" -End \"02\/27\/2018 09:10:00\" | ConvertTo-Html > \"C:\\_DrPe\\message-track.html\"<\/pre>\n<p>We will get a report in form of an HTML file, which looks like the one below.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1394\" src=\"https:\/\/msb365.abstergo.ch\/wp-content\/uploads\/2018\/02\/5-4.png\" alt=\"\" width=\"1470\" height=\"262\" srcset=\"https:\/\/msb365.abstergo.ch\/wp-content\/uploads\/2018\/02\/5-4.png 1470w, https:\/\/msb365.abstergo.ch\/wp-content\/uploads\/2018\/02\/5-4-300x53.png 300w, https:\/\/msb365.abstergo.ch\/wp-content\/uploads\/2018\/02\/5-4-768x137.png 768w, https:\/\/msb365.abstergo.ch\/wp-content\/uploads\/2018\/02\/5-4-1024x183.png 1024w, https:\/\/msb365.abstergo.ch\/wp-content\/uploads\/2018\/02\/5-4-600x107.png 600w, https:\/\/msb365.abstergo.ch\/wp-content\/uploads\/2018\/02\/5-4-780x139.png 780w\" sizes=\"(max-width: 1470px) 100vw, 1470px\" \/><\/p>\n<hr \/>\n<p>\u00a0<\/p>\n<h4>3 SET-CALENDERPROCESSING<\/h4>\n<p>The next cmdlet works on Exchange server 2016 an on Exchange online, we can use the cmdlet to modify calendar processing options for resource mailboxes, which include the calendar attendant, resource booking assistant, and the calendar configuration. With this cmdlet we are able to do many things, let\u2019s go for some examples\u2026<\/p>\n<p>There is a company which has, let\u2019s say, 10 meeting rooms. 9 of them are free to book for all employees, but one is only available for a dedicated group in the company, e.g the HR.<\/p>\n<p>So now we need to prevent all users except the HR to be able to book this meeting room.<\/p>\n<p>To do this, we simply run the following command:<\/p>\n<pre class=\"\">Set-CalendarProcessing \"MeetingRoom1\" -BookInPolicy \"User1\",\"User2\",\"User3\",\"User4\"<\/pre>\n<p>Now we are sure, that only these users are able to make bookings for the specified meeting room.<\/p>\n<p>Another example automates the processing of calendar requests to the resource mailbox SBB23:<\/p>\n<pre class=\"\">Set-CalendarProcessing -Identity \"SBB23\" -AutomateProcessing AutoAccept -DeleteComments $true -AddOrganizerToSubject $true -AllowConflicts $false<\/pre>\n<p>With the Set-CalendarProcessing cmdlet we are also able to disable the automatic processing. Here\u00b4s an example for a company car with the license plate GR123321:<\/p>\n<pre class=\"\">Set-CalendarProcessing -Identity \"GR123321\" -AutomateProcessing None<\/pre>\n<hr \/>\n<p>\u00a0<\/p>\n<h4>4 SET-MAILBOXAUTOREPLYCONFIGURATION<\/h4>\n<p>Ready for number 4?\u00a0This cmdlet, is again one for all the Exchange admins in the field. Sometimes it happens that users go to vacation and they forget to set the Out of Office Notification. Another example is, when a user is sick for a while and there is also a need to set the Out of Office notification.<\/p>\n<p>There are different ways how to do that, but by some easy ways it could be a problem with the legal. To be fast to make it and to stay on the legal side, I prefer to user PowerShell for this task.<\/p>\n<p>In my example the user Desmond Miles went to vacation and he forgot to activate his Out of Office notification. So, to be sure that people who are writing him will receive the right notification, I use the following command:<\/p>\n<pre class=\"\">Set-MailboxAutoReplyConfiguration -Identity \"Desmond Miles\" -AutoReplyState Enabled `\r\n-InternalMessage \"I'm currently on leave until 23th April. Please contact Ezio Auditore on x72023 for urgent matters.\" `\r\n-ExternalMessage \"I'm currently on leave. Please contact our Administration Department on +41 12 345 67 89 for further assistance.\"<\/pre>\n<p>We can also schedule the time period from when till when we want to have the notification activated. Here, the way how this works:<\/p>\n<pre class=\"\">Set-MailboxAutoReplyConfiguration -Identity \"ALIAS\" -AutoReplyState Scheduled \u2013StartTime \u201c02\/28\/2018 07:00:00\u201d \u2013EndTime 03\/18\/2018 17:00:00 `\r\n-InternalMessage \"I'm currently on leave until 23th April. Please contact Ezio Auditore on x72023 for urgent matters.\" `\r\n-ExternalMessage \"I'm currently on leave. Please contact our Administration Department on +41 12 345 67 89 for further assistance.\"<\/pre>\n<hr \/>\n<p>\u00a0<\/p>\n<h4>5 NEW-MAILBOXEXPORTREQUEST<\/h4>\n<p>Here we go, halftime with the number 5\u2026<\/p>\n<p>The New-MailboxExportRequest cmdlet helps us to create a PST File from a user mailbox without the compulsion to login to the users account. This helps us, like the previous cmdlet, not to get in trouble with the legal. This command only works with on-premise Exchange servers, if you need to make a PST export from an Exchange Online mailbox, you can check <a href=\"https:\/\/msb365.abstergo.ch\/?p=901\" target=\"_blank\" rel=\"noopener\">my other article here<\/a>.<\/p>\n<p><strong>Note:<\/strong> This cmdlet is available only for the Mailbox Import Export role and by default, that role isn\u2019t assigned to a role group. To use this cmdlet, you need to add the Mailbox Import Export role to a role group (for example, to the Organization Management role group). Another requirement for exporting to a file share ist to grant the group \u201d\u00a0Exchange Trusted Subsystem\u201d read\/write permissions to the target share.<\/p>\n<p>In the first example we are going to create a PST export of the user mailbox \u201cUser01\u201d to a file share server. To do that, we can run the following command:<\/p>\n<pre class=\"\">New-MailboxExportRequest -Mailbox User01 -FilePath \u2018\\\\SERVER01\\PSTFileShare\\User01_Recovered.pst\u2019<\/pre>\n<p>How about an archive? The command is almost the same one! We only need to add the option \u201cIsArchive\u201d<\/p>\n<pre class=\"\">New-MailboxExportRequest -Mailbox User01 -FilePath \u2018\\\\SERVER01\\PSTFileShare\\User01Archive_Recovered.pst\u2019 -IsArchive\r\n<\/pre>\n<p>Sometimes we don\u2019t want to export the whole mailbox to a PST file. Imagine, we are just interested in messages with the words \u201ccompany\u201d and \u201cphone\u201d, which have been received before a specific date. For this, we can edit our command in the following way:<\/p>\n<pre class=\"\">New-MailboxExportRequest -Mailbox User01 -ContentFilter {(body -like \"*company*\") -and (body -like \"*phone*\") -and (Received -lt \"01\/01\/2012\")} -FilePath \u2018\\\\SERVER01\\PSTFileShare\\User1_CompanyPhone.pst\u2019<\/pre>\n<p>This commands can help us with the preservation of evidence, for example\u2026<\/p>\n<p>At this point, I would like to point out the following: with great power comes great responsibility!!<br \/>\nThis is a very powerful command. Be aware of it\u2026<\/p>\n<hr \/>\n<p>\u00a0<\/p>\n<h4>6 GET-PARTNERAPPLICATION<\/h4>\n<p>This command works for Exchange on-premise and for Exchange Online. With this command we are able to configure partner applications such as Microsoft SharePoint to access the resources of our Exchange environment.<\/p>\n<p>If I want to get access to data in a system, I usually have to log in (authenticate) and I must have obtained the required permissions (authorization). For users, this is a well-known process that you need to log in to the Active Directory first and then log on to the SID and their group memberships, for example, to access file shares that have ACL\u2019s associated permissions added to them. For the Exchange administration with RBAC, users are also used, but then they are granted permissions via roles.<\/p>\n<p>\u00a0<\/p>\n<p>Microsoft describes this function like:<\/p>\n<p>When Exchange 2013 receives an access request from a partner application via Exchange Web Services (EWS), it parses the www-authenticateheader of the https request, which contains the access token signed by the calling server using its private key. The auth module validates the access token using the partner application configuration. It then grants access to resources based on the RBAC permissions granted to the application. If the access token is on behalf of a user, the RBAC permissions granted to the user are checked.<\/p>\n<p>So, here\u00b4s an example how this command works for us:<\/p>\n<p>If we use the following command:<\/p>\n<pre class=\"\">Set-PartnerApplication HRApp -RefreshAuthMetadata<\/pre>\n<p>We are refreshing the auth metadata for the HRApp partner application.<\/p>\n<p>\u00a0<\/p>\n<p>Another example is, when we want to create a new HRApp partner application called HRApp:<\/p>\n<pre class=\"\">New-PartnerApplication \u2013Name HRApp \u2013ApplicationIdentifier 00000009-1234-12we-tz12-123654789wef -Realm contoso.com -UseAuthServer $true<\/pre>\n<p>The ApplicationIdentifier parameter specifies a unique application identifier for the partner application that uses an authorization server. When specifying a value for the ApplicationIdentifier parameter, you must also use the <em>UseAuthServer<\/em> parameter.<\/p>\n<p>\u00a0<\/p>\n<hr \/>\n<p>\u00a0<\/p>\n<h4>7 NEW-ITEM<\/h4>\n<p>Now let\u2019s talk about one we all know (I guess). Sometimes when I am writing a script I want to create a dedicated directory to, for example, dump out files or reports. When I write scripts alone or together with Dominic, I try to make them as universal as possible. Many things can be handled with variables, but sometimes we have to create things, in this case a directory.<\/p>\n<p>To create a directory with PowerShell we simply need one command: New-Item.<\/p>\n<p>\u00a0<\/p>\n<p>With the New-Item cmdlet we can create different things like directories, files, registry keys, etc.<\/p>\n<p>Here are some examples how to use it:<\/p>\n<p>If we want to create a new directory on the C:\\ partition for our PowerShell scripts, we can go with this command:<\/p>\n<pre class=\"\">New-Item \u2013ItemType Directory \u2013Force \u2013Path c:\\DrPe\\scripts<\/pre>\n<p>If we want to create a file in this directory, we can use almost the same command, for creating a .txt file we will use:<\/p>\n<pre class=\"\">New-Item \u2013ItemType File \u2013Path c:\\DrPe\\scripts\\demo.txt<\/pre>\n<p>How about existing files? If we try to create a new file but this file already exists, we will receive the following error message:<\/p>\n<pre class=\"\">New-Item : The file 'C:\\scripts\\new_file.txt' already exists.<\/pre>\n<p>However, if we want to overwrite the existing File, we have the option \u2013<em>Force<\/em> to overwrite the default behavior. Then the command will look like this:<\/p>\n<pre class=\"\">New-Item \u2013ItemType File \u2013Path c:\\DrPe\\scripts\\demo.txt \u2013Force<\/pre>\n<p>\u00a0<\/p>\n<hr \/>\n<p>\u00a0<\/p>\n<h4>8 NEW-MSOLUSER<\/h4>\n<p>Let\u2019s talk abit about the Office 365 cloud now. The next command is more known by using its bro <em>Get-MsolUser<\/em>.<\/p>\n<p>I want to show you now, how to create new users in the Azure Active Directory. After we have made a successful login to the Azure AD throughPowerShell and successfully downloaded the right PowerShell module before, we can use the command New-MsolUser to create new users.<\/p>\n<p>Now,I want to show you some examples, how we can do that\u2026<\/p>\n<p>If we need to create one new user, we can use the following command:<\/p>\n<pre class=\"\">New-MsolUser -DisplayName <DisplayName> -FirstName <FirstName> -LastName <LastName> -UserPrincipalName <Account> -UsageLocation <CountryCode> -LicenseAssignment <AccountSkuID> [-Password <Password>]<\/pre>\n<p>This is easy going, but to create a bulk of new user accounts there must be a easyier way\u2026 Yes, there is one!<\/p>\n<p>\u00a0<\/p>\n<p>First we need to create a CSV file. This can look like this:<\/p>\n<pre class=\"\">UserPrincipalName,FirstName,LastName,DisplayName,UsageLocation,AccountSkuId\r\nClaudeL@contoso.onmicrosoft.com,Claude,Loiselle,Claude Loiselle,US,contoso:ENTERPRISEPACK\r\nLynneB@contoso.onmicrosoft.com,Lynne,Baxter,Lynne Baxter,US,contoso:ENTERPRISEPACK\r\nShawnM@contoso.onmicrosoft.com,Shawn,Melendez,Shawn Melendez,US,contoso:ENTERPRISEPACK<\/pre>\n<p>\u00a0<\/p>\n<p>After we have created this file, we can run the following command:<\/p>\n<pre class=\"\">Import-Csv -Path <Input CSV File Path and Name> | foreach {New-MsolUser -DisplayName $_.DisplayName -FirstName $_.FirstName -LastName $_.LastName -UserPrincipalName $_.UserPrincipalName -UsageLocation $_.UsageLocation -LicenseAssignment $_.AccountSkuId [-Password $_.Password]} | Export-Csv -Path <Output CSV File Path and Name><\/pre>\n<p>Now, PowerShell is doing magic things, and all users from our CSV file will be created.<\/p>\n<p>\ud83d\ude42<\/p>\n<p>\u00a0<\/p>\n<p>With the New-MsolUser cmdlet we can also create new users and assign a license straight away:<\/p>\n<pre class=\"\">New-MsolUser -UserPrincipalName \"Desmond.Miles@contoso.com\" -DisplayName \" Desmond Miles \" -FirstName \"Desmond\" -LastName \"Miles\" -UsageLocation \"CH\" -LicenseAssignment \"Contoso:BPOS_Standard\"<\/pre>\n<p>\u00a0<\/p>\n<p>There are also a bulk of optional parameters:<\/p>\n<pre class=\"\">-AlternativeEmailAddresses # Specifies alternative mail address for the user\r\n-AlternativeMobilePhones # Specifies alternative mobile phone numbers fort he user\r\n-BlockCredential # Specifies whether the user is not able to log on using their user ID\r\n-City # Specifies the city of the user\r\n-Country # Specifies the country of the user\r\n-Department # Specifies the department of the user\r\n-DisplayName # Specifies the display name\r\n-Fax # Specifies the fax number of the user\r\n-FirstName # Specifies the first name of the user\r\n-ForceChangePassword # Indicates that the user is required to change their password at the next time they sign in\r\n-ImmutableId # Specifies the immutable ID of the federated identity of the user\r\n-LastName # Specifies the last name of the user\r\n-LastPasswordChangeTimestamp # Specifies a time when the password was last changed\r\n-LicenseAssignment # Specifies an array of licenses to assign the user\r\n-LicenseOption # Specifies the options for license assignment. Used to selectively disable individual service plans within a SKU\r\n-MobilePhone # Specifies the mobile phone number of the user\r\n-Office # Specifies the office of the user\r\n-Password # Specifies \u00a0the new password for the user.\r\n-PasswordNeverExpires # Specifies whether the user password expires periodically\r\n-PhoneNumber # Specifies the phone number of the user\r\n-PostalCode # Specifies the postal code of the user\r\n-PreferredDataLocation # Specifies the preferred data location for the user\r\n-PreferredLanguage # Specifies the preferred language of the user\r\n-SoftDeletionTimestamp # Specifies a time for soft deletion\r\n-State # Specifies the state or province where the user is located\r\n-StreetAddress # Specifies the street address of the user\r\n-StrongAuthenticationRequirements # Specifies an array of strong authentication requirements\r\n-StrongPasswordRequired # Specifies whether to require a strong password for the user\r\n-StsRefreshTokensValidFrom # Specifies a StsRefreshTokensValidFrom value.\r\n-TenantId # Specifies the unique ID of the tenant on which to perform the operation\r\n-Title # Specifies the title of the user\r\n-UsageLocation # Specifies the location of the user where services are consumed\r\n-UserPrincipalName # Specifies the user ID for this user\r\n-UserType # Specifies the user type<\/pre>\n<hr \/>\n<h4>9 GET-HOTFIX<\/h4>\n<p>So, the second to last for this article. The Get-Hotfix cmdlet gets hotfixes (also called updates) that have been installed on either the local computer (or on specified remote computers) by Windows Update, Microsoft Update, or Windows Server Update Services; the cmdlet also gets hotfixes or updates that have been installed manually by users.<\/p>\n<p>In the first example we go to check which updates were already installed on my client computer. To do that I simply run the following command:<\/p>\n<pre class=\"\">Get-Hotfix<\/pre>\n<p>\u00a0<\/p>\n<p>And as we see in the print screen, there are just a few updates installed on my machine:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1397\" src=\"https:\/\/msb365.abstergo.ch\/wp-content\/uploads\/2018\/02\/6-4.png\" alt=\"\" width=\"1021\" height=\"562\" srcset=\"https:\/\/msb365.abstergo.ch\/wp-content\/uploads\/2018\/02\/6-4.png 1021w, https:\/\/msb365.abstergo.ch\/wp-content\/uploads\/2018\/02\/6-4-300x165.png 300w, https:\/\/msb365.abstergo.ch\/wp-content\/uploads\/2018\/02\/6-4-768x423.png 768w, https:\/\/msb365.abstergo.ch\/wp-content\/uploads\/2018\/02\/6-4-600x330.png 600w, https:\/\/msb365.abstergo.ch\/wp-content\/uploads\/2018\/02\/6-4-780x429.png 780w\" sizes=\"(max-width: 1021px) 100vw, 1021px\" \/><\/p>\n<p>In the 2<sup>nd<\/sup> example I want to check which security hotfixes are installed on a list of computers. To do that we can use the following command:<\/p>\n<pre class=\"\">Get-HotFix -Description \"Security*\" -ComputerName \"Server01\", \"Server02\" -Cred \"Server01\\admin01\"<\/pre>\n<p>\u00a0<\/p>\n<p>As we see, there are a couple of patches installed:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1398\" src=\"https:\/\/msb365.abstergo.ch\/wp-content\/uploads\/2018\/02\/7-2.png\" alt=\"\" width=\"1019\" height=\"564\" srcset=\"https:\/\/msb365.abstergo.ch\/wp-content\/uploads\/2018\/02\/7-2.png 1019w, https:\/\/msb365.abstergo.ch\/wp-content\/uploads\/2018\/02\/7-2-300x166.png 300w, https:\/\/msb365.abstergo.ch\/wp-content\/uploads\/2018\/02\/7-2-768x425.png 768w, https:\/\/msb365.abstergo.ch\/wp-content\/uploads\/2018\/02\/7-2-600x332.png 600w, https:\/\/msb365.abstergo.ch\/wp-content\/uploads\/2018\/02\/7-2-780x432.png 780w\" sizes=\"(max-width: 1019px) 100vw, 1019px\" \/><\/p>\n<hr \/>\n<p>\u00a0<\/p>\n<h4>10 NEW-MANAGEMENTROLEASSIGNMENT<\/h4>\n<p>The (last) command for todays article is working for on-premise Exchange servers and for Exchange Online as well. With the New-ManagementRoleAssignment cmdlet we are able to manage roles for department groups. Maybe it sounds strange, but when I show you some examples, all will be clearer\u2026<\/p>\n<p>In the first example, I have to assign the Mail Recipient role to the 2<sup>nd<\/sup>\u00a0level helpdesk of our company. To do that I run the following command:<\/p>\n<pre class=\"\">New-ManagementRoleAssignment \u2013Role \u2018Mail Recipients\u2019 \u2013SecurityGroup \u2018Level 2 Support\u2019<\/pre>\n<p>\u00a0<\/p>\n<p>We are also able to get some information about management roles. This example assigns the MyVoiceMail role to the \u201cSales end-users\u201d role assignment policy. First, the IsEndUserRole property on the MyVoiceMail role is verified to be sure it\u2019s set to $true, indicating it\u2019s an end-user role:<\/p>\n<pre class=\"\">Get-ManagementRole \"MyVoiceMail\" | Format-Table Name, IsEndUserRole<\/pre>\n<p>\u00a0<\/p>\n<p>After the role has been verified to be an end-user role, the role is assigned to the \u201cSales end-users\u201d role assignment policy.<\/p>\n<pre class=\"\">New-ManagementRoleAssignment -Role \"MyVoiceMail\" -Policy \"Sales end-users\"<\/pre>\n<hr \/>\n<p>\u00a0<\/p>\n<h4><span style=\"color: #33cccc;\"><strong>BONUS<\/strong><\/span><\/h4>\n<p>While preparing this article, I came across another command, which I do not want to withhold from you. This command can be used in many ways, I want you to show a funny example for it.<\/p>\n<p>Since PowerShell 3.0 we can use the Invoke-RestMethod. That means we are able to put curl in our PowerShell. Here, my example what we can do with it:<\/p>\n<p>\u00a0<\/p>\n<pre class=\"\">(curl http:\/\/wttr.in\/Zurich -UserAgent \"curl\" ).Content<\/pre>\n<p>\u00a0<\/p>\n<p>I am located in Zurich Switzerland, so for me, the weather here is important. When I run the command above, it will show me following result in my PowerShell console:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1399\" src=\"https:\/\/msb365.abstergo.ch\/wp-content\/uploads\/2018\/02\/8-2.png\" alt=\"\" width=\"1023\" height=\"565\" srcset=\"https:\/\/msb365.abstergo.ch\/wp-content\/uploads\/2018\/02\/8-2.png 1023w, https:\/\/msb365.abstergo.ch\/wp-content\/uploads\/2018\/02\/8-2-300x166.png 300w, https:\/\/msb365.abstergo.ch\/wp-content\/uploads\/2018\/02\/8-2-768x424.png 768w, https:\/\/msb365.abstergo.ch\/wp-content\/uploads\/2018\/02\/8-2-600x331.png 600w, https:\/\/msb365.abstergo.ch\/wp-content\/uploads\/2018\/02\/8-2-780x431.png 780w\" sizes=\"(max-width: 1023px) 100vw, 1023px\" \/><br \/>\nGo and play around with this command a little bit. An overview of available options can be found here:\u00a0<a href=\"http:\/\/wttr.in\/:help\">http:\/\/wttr.in\/:help<\/a><\/p>\n<p>\u00a0<\/p>\n<p>I hope you enjoyed this article about another 10 PowerShell commands.<\/p>\n<p>I hope you also have a sunny day like we here, as you can see in that last screen shot\u2026 But, hopefully just a bit warmer.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>After all the positive feedback to my article \u201c10 Useful PowerShell cmdlets for Exchange\u201d (thanks again to Steve Goodman), I have decided to write a second part of it with another 10 useful PowerShell commands for Exchange and Office 365. Same procedure as the last time. Some of you may already know the commands, but [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":3019,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_crdt_document":"","om_disable_all_campaigns":false,"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"_uf_show_specific_survey":0,"_uf_disable_surveys":false,"footnotes":""},"categories":[1923,2,3],"tags":[],"class_list":["post-1388","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-microsoft-365","category-exchange","category-powershell"],"post_mailing_queue_ids":[],"_links":{"self":[{"href":"https:\/\/www.msb365.blog\/index.php?rest_route=\/wp\/v2\/posts\/1388","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.msb365.blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.msb365.blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.msb365.blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.msb365.blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1388"}],"version-history":[{"count":15,"href":"https:\/\/www.msb365.blog\/index.php?rest_route=\/wp\/v2\/posts\/1388\/revisions"}],"predecessor-version":[{"id":5240,"href":"https:\/\/www.msb365.blog\/index.php?rest_route=\/wp\/v2\/posts\/1388\/revisions\/5240"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.msb365.blog\/index.php?rest_route=\/wp\/v2\/media\/3019"}],"wp:attachment":[{"href":"https:\/\/www.msb365.blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1388"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.msb365.blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1388"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.msb365.blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1388"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}