Skip to content

Commit c7b4707

Browse files
committed
Merge branch 'main' into TP-chrisda
2 parents 583b16f + 51589eb commit c7b4707

21 files changed

+216
-49
lines changed

exchange/docs-conceptual/exchange-online-powershell-v2.md

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ title: About the Exchange Online PowerShell V2 module and V3 module
33
ms.author: chrisda
44
author: chrisda
55
manager: dansimp
6-
ms.date: 6/21/2023
6+
ms.date: 7/5/2023
77
ms.audience: Admin
88
audience: Admin
99
ms.topic: article
@@ -62,13 +62,15 @@ Version 3.0.0 or later is known as the EXO V3 module. The EXO V3 module improves
6262

6363
- REST API cmdlets have the same cmdlet names and work just like their remote PowerShell equivalents, so you don't need to update any of your scripts.
6464

65+
The [Invoke-Command](/powershell/module/microsoft.powershell.core/invoke-command) cmdlet doesn't work in REST API connections. For alternatives, see [Workarounds for Invoke-Command scenarios in REST API connections](invoke-command-workarounds-rest-api.md).
66+
6567
- In Exchange Online PowerShell and in Security & Compliance PowerShell, all of the available remote PowerShell cmdlets are backed by the REST API.
6668

6769
- In Exchange Online PowerShell and in Security & Compliance PowerShell, REST API connections are used by default. You need to use the _UseRPSSession_ switch in the **Connect-ExchangeOnline** or **Connect-IPPSSession** command to access cmdlets in remote PowerShell mode.
6870

6971
- Consider the following items if you connect to Exchange Online PowerShell or Security & Compliance PowerShell in remote PowerShell mode:
7072
- [Basic authentication in WinRM](#turn-on-basic-authentication-in-winrm) is required on your client computer.
71-
- If you don't connect i remote PowerShell mode, you have access to REST API cmdlets _only_.
73+
- If you don't connect in remote PowerShell mode, you have access to REST API cmdlets _only_.
7274
- The end of remote PowerShell support in Exchange Online PowerShell has been announced. For more information, see [Announcing Deprecation of Remote PowerShell (RPS) Protocol in Exchange Online PowerShell](https://aka.ms/RPSDeprecation).
7375

7476
- A few REST API cmdlets in Exchange Online PowerShell have been updated with the experimental _UseCustomRouting_ switch. This switch routes the command directly to the required Mailbox server, and might improve overall performance.
@@ -132,9 +134,7 @@ Connect-ExchangeOnline -EnableErrorReporting -LogDirectoryPath <Path to store lo
132134
133135
## Cmdlets in the Exchange Online PowerShell module
134136

135-
All versions of the module contain nine exclusive **Get-EXO\*** cmdlets for Exchange Online PowerShell that are optimized for speed in bulk data retrieval scenarios (thousands and thousands of objects). The older related remote PowerShell cmdlets are still available.
136-
137-
The improved Exchange Online PowerShell cmdlets that are available only in the module are listed in the following table:
137+
All versions of the module contain nine exclusive **Get-EXO\*** cmdlets for Exchange Online PowerShell that are optimized for speed in bulk data retrieval scenarios (thousands and thousands of objects). The improved Exchange Online PowerShell cmdlets that are available only in the module are listed in the following table:
138138

139139
|EXO module cmdlet|Older related cmdlet|
140140
|---|---|
@@ -148,6 +148,9 @@ The improved Exchange Online PowerShell cmdlets that are available only in the m
148148
|[Get-EXOMailboxFolderPermission](/powershell/module/exchange/get-exomailboxfolderpermission)|[Get-MailboxFolderPermission](/powershell/module/exchange/get-mailboxfolderpermission)|
149149
|[Get-EXOMobileDeviceStatistics](/powershell/module/exchange/get-exomobiledevicestatistics)|[Get-MobileDeviceStatistics](/powershell/module/exchange/get-mobiledevicestatistics)|
150150

151+
> [!NOTE]
152+
> If you open multiple connections to Exchange Online PowerShell in the same window, the **Get-EXO\*** cmdlets are always associated with the last (most recent) Exchange Online PowerShell connection. Run the following command to find the REST API session where the **Get-EXO\*** cmdlets are run: `Get-ConnectionInformation | Where-Object {$_.ConnectionUsedForInbuiltCmdlets -eq $true}`. If the last Exchange Online PowerShell connection used remote PowerShell, the **Get-EXO\*** cmdlets are run in that connection (and the output of the **Get-ConnectionInformation** command is meaningless).
153+
151154
The connection-related cmdlets in the module are listed in the following table:
152155

153156
|EXO module cmdlet|Older related cmdlet|Comments|
Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
---
2+
title: Workarounds for Invoke-Command scenarios in REST API connections
3+
ms.author: chrisda
4+
author: chrisda
5+
manager: dansimp
6+
ms.date: 7/5/2023
7+
ms.audience: Admin
8+
audience: Admin
9+
ms.topic: article
10+
ms.service: exchange-powershell
11+
ms.reviewer:
12+
ms.localizationpriority: normal
13+
ms.collection: Strat_EX_Admin
14+
ms.custom:
15+
ms.assetid:
16+
search.appverid: MET150
17+
description: "Learn about the alternatives to Invoke-Command commands in REST API connections using the EXO V3 module."
18+
---
19+
20+
# Workarounds for Invoke-Command scenarios in REST API connections
21+
22+
In multiple connections to Exchange Online or Security & Compliance PowerShell in the same window, you use the [Invoke-Command](/powershell/module/microsoft.powershell.core/invoke-command) cmdlet to run scripts or commands in a specific remote PowerShell session. But, the **Invoke-Command** cmdlet doesn't work in [REST API connections](exchange-online-powershell-v2.md#updates-for-the-exo-v3-module) to Exchange Online or Security & Compliance PowerShell.
23+
24+
This article offers REST API alternatives for scenarios that that use **Invoke-Command** commands.
25+
26+
## Scenario 1: Run Exchange Online cmdlets
27+
28+
This example finds the identity of any other user (`$Us = $User.Identity`).
29+
30+
> [!TIP]
31+
> Other commands were required to get the values of `$User` and therefore `$Us`. Those commands aren't important. The overall approach that's being used is what's important.
32+
33+
- **In a remote PowerShell session**: Use the **Get-PSSession** cmdlet to store the remote PowerShell session details in the variable named `$Session`, and then run the following command:
34+
35+
```powershell
36+
Invoke-Command -Session $Session -ScriptBlock {Get-User $Using:Us | Select-Object DistinguishedName, ExternalDirectoryObjectId} -ErrorAction SilentlyContinue
37+
```
38+
39+
- **In a REST API session**: Run the following command:
40+
41+
```powershell
42+
Get-User $Us | Format-List DistinguishedName, ExternalDirectoryObjectId
43+
```
44+
45+
This example finds the identity of a group member:
46+
47+
- **In a remote PowerShell session**: Use the **Get-PSSession** cmdlet to store the remote PowerShell session details in the variable named `$Session`, and then run the following command:
48+
49+
```powershell
50+
Invoke-Command -Session $Session -ScriptBlock {Get-Recipient -Filter "Members -eq '$($User.DistinguishedName)'" -RecipientTypeDetails MailUniversalDistributionGroup | Select-Object DisplayName, ExternalDirectoryObjectId, RecipientTypeDetails} -ErrorAction SilentlyContinue -HideComputerName
51+
```
52+
53+
- **In a REST API session**: Run the following command:
54+
55+
```powershell
56+
Get-Recipient -Filter "Members -eq '$($User.DistinguishedName)'" -RecipientTypeDetails MailUniversalDistributionGroup | Format-List DisplayName, ExternalDirectoryObjectId, RecipientTypeDetails
57+
```
58+
59+
## Scenario 2: Run Exchange Online cmdlets and expand specific properties
60+
61+
This example finds all mailboxes where the GrantSendOnBehalfTo permission is set, and then returns the users who have the permission on the mailbox.
62+
63+
- **In a remote PowerShell session**: Use the **Get-PSSession** cmdlet to store the remote PowerShell session details in the variable named `$Session`, and then run the following command:
64+
65+
```powershell
66+
Invoke-Command -Session $Session -ScriptBlock {Get-Mailbox -Filter "GrantSendOnBehalfTo -ne `$null" -ErrorAction SilentlyContinue | Select-Object ExternalDirectoryObjectId, GrantSendOnBehalfTo -ExpandProperty GrantSendOnBehalfTo}
67+
```
68+
69+
- **In a REST API session**: Run the following command:
70+
71+
```powershell
72+
$mailboxes = Get-Mailbox -Filter "GrantSendOnBehalfTo -ne `$null"
73+
74+
foreach ($mailbox in $mailboxes)
75+
76+
{
77+
$users = $mailbox | Select-Object GrantSendOnBehalfTo -ExpandProperty GrantSendOnBehalfTo | Get-User
78+
79+
$users | Select-Object Name, Guid
80+
}
81+
```
82+
83+
## Scenario 3: Run Exchange Online cmdlets in a specific PowerShell session when multiple sessions are present
84+
85+
This example shows how to create two PowerShell sessions in the same window and run the **Get-Mailbox** cmdlet in each session.
86+
87+
- **In a remote PowerShell session**:
88+
1. Use the **Get-PSSession** cmdlet to store the first remote PowerShell session details in the variable named `$Session1`.
89+
2. Use the **Get-PSSession** cmdlet to store the second remote PowerShell session details in the variable named `$Session2`.
90+
3. Run the following commands:
91+
92+
```powershell
93+
Invoke-Command -Session $Session1 -ScriptBlock {Get-Mailbox -ResultSize 1}
94+
95+
Invoke-Command -Session $Session2 -ScriptBlock {Get-Mailbox -ResultSize 1}
96+
```
97+
98+
- **In a REST API session**:
99+
1. In the first **Connect-ExchangeOnline** command, use the parameter _Prefix_ with the value C1.
100+
2. Store the first REST API connection details in the variable named `$ConnectionInfo1` by running the following command:
101+
102+
```powershell
103+
$ConnectionInfo1 = Get-ConnectionInformation | Where-Object { $_.ModulePrefix -eq "C1"}
104+
```
105+
106+
3. In the second **Connect-ExchangeOnline** command, use the parameter _Prefix_ with the value C2.
107+
4. Store the second REST API connection details in the variable named `$ConnectionInfo2` by running the following command:
108+
109+
```powershell
110+
$ConnectionInfo1 = Get-ConnectionInformation | Where-Object { $_.ModulePrefix -eq "C2"}
111+
```
112+
113+
5. Now you can run commands in either session. For example:
114+
115+
```powershell
116+
$CommandStr1 = "Get-$($ConnectionInfo1.ModulePrefix)Mailbox -ResultSize 10"
117+
118+
Invoke-Expression $CommandStr1
119+
```
120+
121+
Or
122+
123+
```powershell
124+
$CommandStr2 = "Get-$($ConnectionInfo2.ModulePrefix)Mailbox -ResultSize 10"
125+
126+
Invoke-Expression $CommandStr2
127+
```

exchange/docs-conceptual/toc.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@
3838
href: connect-exo-powershell-managed-identity.md
3939
- name: Connect using C#
4040
href: connect-to-exo-powershell-c-sharp.md
41+
- name: Workarounds for Invoke-Command in REST API connections
42+
href: invoke-command-workarounds-rest-api.md
4143
- name: Enable or disable access to Exchange Online PowerShell
4244
href: disable-access-to-exchange-online-powershell.md
4345
- name: Exchange cmdlet syntax

exchange/exchange-ps/exchange/New-AutoSensitivityLabelRule.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ The AnyOfRecipientAddressContainsWords parameter specifies a condition for the a
168168
- Multiple words: `no_reply,urgent,...`
169169
- Multiple words and phrases: `"phrase 1",word1,"phrase with , or spaces",word2,...`
170170

171-
The maximum individual word or phrase length is 128 characters. The maximum number of words or phrases is 50.
171+
The maximum individual word or phrase length is 128 characters. The maximum number of words or phrases is 600.
172172

173173
You can use this condition in auto-labeling policies that are scoped only to Exchange.
174174

@@ -359,7 +359,7 @@ The ExceptIfAnyOfRecipientAddressContainsWords parameter specifies an exception
359359
- Multiple words: `no_reply,urgent,...`
360360
- Multiple words and phrases: `"phrase 1",word1,"phrase with , or spaces",word2,...`
361361

362-
The maximum individual word or phrase length is 128 characters. The maximum number of words or phrases is 50.
362+
The maximum individual word or phrase length is 128 characters. The maximum number of words or phrases is 600.
363363

364364
You can use this exception in auto-labeling policies that are scoped only to Exchange.
365365

exchange/exchange-ps/exchange/New-DlpComplianceRule.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -428,7 +428,7 @@ The AnyOfRecipientAddressContainsWords parameter specifies a condition for the D
428428
- Multiple words: `no_reply,urgent,...`
429429
- Multiple words and phrases: `"phrase 1",word1,"phrase with , or spaces",word2,...`
430430

431-
The maximum individual word or phrase length is 128 characters. The maximum number of words or phrases is 50.
431+
The maximum individual word or phrase length is 128 characters. The maximum number of words or phrases is 600.
432432

433433
You can use this condition in DLP policies that are scoped only to Exchange.
434434

@@ -979,7 +979,7 @@ The ExceptIfAnyOfRecipientAddressContainsWords parameter specifies an exception
979979
- Multiple words: `no_reply,urgent,...`
980980
- Multiple words and phrases: `"phrase 1",word1,"phrase with , or spaces",word2,...`
981981

982-
The maximum individual word or phrase length is 128 characters. The maximum number of words or phrases is 50.
982+
The maximum individual word or phrase length is 128 characters. The maximum number of words or phrases is 600.
983983

984984
You can use this exception in DLP policies that are scoped only to Exchange.
985985

exchange/exchange-ps/exchange/New-HostedContentFilterPolicy.md

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -740,17 +740,13 @@ Accept wildcard characters: False
740740
```
741741

742742
### -LanguageBlockList
743-
The LanguageBlockList parameter specifies the email content languages that are marked as spam when the EnableLanguageBlockList parameter value is $true. A valid value is a supported ISO 639-1 two-letter language code:
743+
The LanguageBlockList parameter specifies the email content languages that are marked as spam when the EnableLanguageBlockList parameter value is $true. A valid value is a supported uppercase ISO 639-1 two-letter language code:
744744

745-
af, ar, az, be, bg, bn, br, bs, ca, cs, cy, da, de, el, en, eo, es, et, eu, fa, fi, fo, fr, fy, ga, gl, gu, ha, he, hi, hr, hu, hy, id, is, it, ja, ka, kk, kl, kn, ko, ku, ky, la, lb, lt, lv, mi, mk, ml, mn, mr, ms, mt, nb, nl, nn, pa, pl, ps, pt, rm, ro, ru, se, sk, sl, sq, sr, sv, sw, ta, te, th, tl, tr, uk, ur, uz, vi, wen, yi, zh-cn, zh-tw, and zu.
745+
AF, AR, AZ, BE, BG, BN, BR, BS, CA, CS, CY, DA, DE, EL, EN, EO, ES, ET, EU, FA, FI, FO, FR, FY, GA, GL, GU, HA, HE, HI, HR, HU, HY, ID, IS, IT, JA, KA, KK, KL, KN, KO, KU, KY, LA, LB, LT, LV, MI, MK, ML, MN, MR, MS, MT, NB, NL, NN, PA, PL, PS, PT, RM, RO, RU, SE, SK, SL, SQ, SR, SV, SW, TA, TE, TH, TL, TR, UK, UR, UZ, VI, WEN, YI, ZH-CN, ZH-TW, and ZU.
746746

747-
A reference for two-letter language codes is available at [ISO 639-2](https://www.loc.gov/standards/iso639-2/php/code_list.php). Note that not all possible language codes are available as input for this parameter.
747+
A reference for two-letter language codes is available at [ISO 639-2](https://www.loc.gov/standards/iso639-2/php/code_list.php). Not all possible language codes are available as input for this parameter.
748748

749-
To enter multiple values and overwrite any existing entries, use the following syntax: `Value1,Value2,...ValueN`.
750-
751-
To add or remove one or more values without affecting any existing entries, use the following syntax: `@{Add="Value1","Value2"...; Remove="Value3","Value4"...}`.
752-
753-
To empty the list, use the value $null.
749+
You can specify multiple values separated by commas.
754750

755751
```yaml
756752
Type: MultiValuedProperty

exchange/exchange-ps/exchange/New-TenantAllowBlockListSpoofItems.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,7 @@ For information about the parameter sets in the Syntax section below, see [Excha
2121
## SYNTAX
2222

2323
```
24-
New-TenantAllowBlockListSpoofItems [-Identity] <HostedConnectionFilterPolicyIdParameter> -Action <String>
25-
-SendingInfrastructure <String> -SpoofedUser <String> -SpoofType <String>
24+
New-TenantAllowBlockListSpoofItems [-Identity] <HostedConnectionFilterPolicyIdParameter> -Action <String> -SendingInfrastructure <String> -SpoofedUser <String> -SpoofType <String>
2625
[-Confirm]
2726
[-WhatIf]
2827
[<CommonParameters>]

exchange/exchange-ps/exchange/Search-UnifiedAuditLog.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,11 @@ Accept wildcard characters: False
193193
```
194194

195195
### -ObjectIds
196-
The ObjectIds parameter filters the log entries by object ID. The object ID is the target object that was acted upon, and depends on the RecordType and Operations values of the event. For example, for SharePoint operations, the object ID is the URL path to a file, folder, or site. For Azure Active Directory operations, the object ID is the account name or GUID value of the account.
196+
The ObjectIds parameter filters the log entries by object ID. The object ID is the target object that was acted upon, and depends on the RecordType and Operations values of the event.
197+
198+
For example, for SharePoint operations, the object ID is the URL path to a file, folder, or site. To search logs in a site, add a wildcard (\*) in front of the site URL (for example, `"https://contoso.sharepoint.com/sites/test/*"`).
199+
200+
For Azure Active Directory operations, the object ID is the account name or GUID value of the account.
197201

198202
The ObjectId value appears in the AuditData (also known as Details) property of the event.
199203

exchange/exchange-ps/exchange/Set-AutoSensitivityLabelRule.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ The AnyOfRecipientAddressContainsWords parameter specifies a condition for the a
151151
- Multiple words: `no_reply,urgent,...`
152152
- Multiple words and phrases: `"phrase 1",word1,"phrase with , or spaces",word2,...`
153153

154-
The maximum individual word or phrase length is 128 characters. The maximum number of words or phrases is 50.
154+
The maximum individual word or phrase length is 128 characters. The maximum number of words or phrases is 600.
155155

156156
You can use this condition in auto-labeling policies that are scoped only to Exchange.
157157

@@ -342,7 +342,7 @@ The ExceptIfAnyOfRecipientAddressContainsWords parameter specifies an exception
342342
- Multiple words: `no_reply,urgent,...`
343343
- Multiple words and phrases: `"phrase 1",word1,"phrase with , or spaces",word2,...`
344344

345-
The maximum individual word or phrase length is 128 characters. The maximum number of words or phrases is 50.
345+
The maximum individual word or phrase length is 128 characters. The maximum number of words or phrases is 600.
346346

347347
You can use this exception in auto-labeling policies that are scoped only to Exchange.
348348

exchange/exchange-ps/exchange/Set-DlpComplianceRule.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -362,7 +362,7 @@ The AnyOfRecipientAddressContainsWords parameter specifies a condition for the D
362362
- Multiple words: `no_reply,urgent,...`
363363
- Multiple words and phrases: `"phrase 1",word1,"phrase with , or spaces",word2,...`
364364

365-
The maximum individual word or phrase length is 128 characters. The maximum number of words or phrases is 50.
365+
The maximum individual word or phrase length is 128 characters. The maximum number of words or phrases is 600.
366366

367367
You can use this condition in DLP policies that are scoped only to Exchange.
368368

@@ -911,7 +911,7 @@ The ExceptIfAnyOfRecipientAddressContainsWords parameter specifies an exception
911911
- Multiple words: `no_reply,urgent,...`
912912
- Multiple words and phrases: `"phrase 1",word1,"phrase with , or spaces",word2,...`
913913

914-
The maximum individual word or phrase length is 128 characters. The maximum number of words or phrases is 50.
914+
The maximum individual word or phrase length is 128 characters. The maximum number of words or phrases is 600.
915915

916916
You can use this exception in DLP policies that are scoped only to Exchange.
917917

exchange/exchange-ps/exchange/Set-HostedContentFilterPolicy.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -742,11 +742,11 @@ Accept wildcard characters: False
742742
```
743743

744744
### -LanguageBlockList
745-
The LanguageBlockList parameter specifies the email content languages that are marked as spam when the EnableLanguageBlockList parameter value is $true. A valid value is a supported ISO 639-1 two-letter language code:
745+
The LanguageBlockList parameter specifies the email content languages that are marked as spam when the EnableLanguageBlockList parameter value is $true. A valid value is a supported uppercase ISO 639-1 two-letter language code:
746746

747-
af, ar, az, be, bg, bn, br, bs, ca, cs, cy, da, de, el, en, eo, es, et, eu, fa, fi, fo, fr, fy, ga, gl, gu, ha, he, hi, hr, hu, hy, id, is, it, ja, ka, kk, kl, kn, ko, ku, ky, la, lb, lt, lv, mi, mk, ml, mn, mr, ms, mt, nb, nl, nn, pa, pl, ps, pt, rm, ro, ru, se, sk, sl, sq, sr, sv, sw, ta, te, th, tl, tr, uk, ur, uz, vi, wen, yi, zh-cn, zh-tw, and zu.
747+
AF, AR, AZ, BE, BG, BN, BR, BS, CA, CS, CY, DA, DE, EL, EN, EO, ES, ET, EU, FA, FI, FO, FR, FY, GA, GL, GU, HA, HE, HI, HR, HU, HY, ID, IS, IT, JA, KA, KK, KL, KN, KO, KU, KY, LA, LB, LT, LV, MI, MK, ML, MN, MR, MS, MT, NB, NL, NN, PA, PL, PS, PT, RM, RO, RU, SE, SK, SL, SQ, SR, SV, SW, TA, TE, TH, TL, TR, UK, UR, UZ, VI, WEN, YI, ZH-CN, ZH-TW, and ZU.
748748

749-
A reference for two-letter language codes is available at [ISO 639-2](https://www.loc.gov/standards/iso639-2/php/code_list.php). Note that not all possible language codes are available as input for this parameter.
749+
A reference for two-letter language codes is available at [ISO 639-2](https://www.loc.gov/standards/iso639-2/php/code_list.php). Not all possible language codes are available as input for this parameter.
750750

751751
To enter multiple values and overwrite any existing entries, use the following syntax: `"Value1","Value2",..."ValueN"`.
752752

0 commit comments

Comments
 (0)