Skip to content

Commit 4d7c36f

Browse files
committed
Merge branch 'main' into DMARC-chrisda
2 parents de57943 + 12e2a4a commit 4d7c36f

23 files changed

+1195
-26
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/Connect-IPPSSession.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ Connect-IPPSSession -UserPrincipalName [email protected]
5757

5858
This example connects to Security & Compliance PowerShell using the specified account and modern authentication, with or without MFA. In v3.2.0 or later of the module, we're connecting in REST API mode, so Basic authentication in WinRM isn't required on the local computer.
5959

60-
6160
### Example 2
6261
```powershell
6362
Connect-IPPSSession -UserPrincipalName [email protected] -UseRPSSession
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
---
2+
external help file: Microsoft.Exchange.TransportMailflow-Help.xml
3+
online version: https://learn.microsoft.com/powershell/module/exchange/get-teamsprotectionpolicy
4+
applicable: Exchange Online
5+
title: Get-TeamsProtectionPolicy
6+
schema: 2.0.0
7+
author: chrisda
8+
ms.author: chrisda
9+
ms.reviewer:
10+
---
11+
12+
# Get-TeamsProtectionPolicy
13+
14+
## SYNOPSIS
15+
This cmdlet is available only in the cloud-based service.
16+
17+
Use the Get-TeamsProtectionPolicy cmdlet to view Microsoft Teams protection policies.
18+
19+
For information about the parameter sets in the Syntax section below, see [Exchange cmdlet syntax](https://learn.microsoft.com/powershell/exchange/exchange-cmdlet-syntax).
20+
21+
## SYNTAX
22+
23+
```
24+
Get-TeamsProtectionPolicy [[-Identity] <TeamsProtectionPolicyIdParameter>]
25+
[-Organization <OrganizationIdParameter>]
26+
[<CommonParameters>]
27+
```
28+
29+
## DESCRIPTION
30+
You need to be assigned permissions before you can run this cmdlet. Although this topic lists all parameters for the cmdlet, you may not have access to some parameters if they're not included in the permissions assigned to you. To find the permissions required to run any cmdlet or parameter in your organization, see [Find the permissions required to run any Exchange cmdlet](https://learn.microsoft.com/powershell/exchange/find-exchange-cmdlet-permissions).
31+
32+
## EXAMPLES
33+
34+
### Example 1
35+
```powershell
36+
Get-TeamsProtectionPolicy
37+
```
38+
39+
This example shows detailed information about the Teams protection policy in the organization.
40+
41+
## PARAMETERS
42+
43+
### -Identity
44+
The Identity parameter specifies the Teams protection policy that you want to view. There's only one Teams protection policy in an organization named Teams Protection Policy.
45+
46+
```yaml
47+
Type: TeamsProtectionPolicyIdParameter
48+
Parameter Sets: (All)
49+
Aliases:
50+
Applicable: Exchange Online
51+
52+
Required: False
53+
Position: 1
54+
Default value: None
55+
Accept pipeline input: True (ByPropertyName, ByValue)
56+
Accept wildcard characters: False
57+
```
58+
59+
### -Organization
60+
This parameter is reserved for internal Microsoft use.
61+
62+
```yaml
63+
Type: OrganizationIdParameter
64+
Parameter Sets: (All)
65+
Aliases:
66+
Applicable: Exchange Online
67+
68+
Required: False
69+
Position: Named
70+
Default value: None
71+
Accept pipeline input: False
72+
Accept wildcard characters: False
73+
```
74+
75+
### CommonParameters
76+
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](https://go.microsoft.com/fwlink/p/?LinkID=113216).
77+
78+
## INPUTS
79+
80+
## OUTPUTS
81+
82+
## NOTES
83+
84+
## RELATED LINKS
Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
---
2+
external help file: Microsoft.Exchange.TransportMailflow-Help.xml
3+
online version: https://learn.microsoft.com/powershell/module/exchange/get-teamsprotectionpolicyrule
4+
applicable: Exchange Online
5+
title: Get-TeamsProtectionPolicyRule
6+
schema: 2.0.0
7+
author: chrisda
8+
ms.author: chrisda
9+
ms.reviewer:
10+
---
11+
12+
# Get-TeamsProtectionPolicyRule
13+
14+
## SYNOPSIS
15+
This cmdlet is available only in the cloud-based service.
16+
17+
Use the Get-TeamsProtectionPolicyRule cmdlet to view Microsoft Teams protection policy rules.
18+
19+
For information about the parameter sets in the Syntax section below, see [Exchange cmdlet syntax](https://learn.microsoft.com/powershell/exchange/exchange-cmdlet-syntax).
20+
21+
## SYNTAX
22+
23+
```
24+
Get-TeamsProtectionPolicyRule [[-Identity] <RuleIdParameter>]
25+
[-Organization <OrganizationIdParameter>]
26+
[-State <RuleState>]
27+
[<CommonParameters>]
28+
```
29+
30+
## DESCRIPTION
31+
You need to be assigned permissions before you can run this cmdlet. Although this topic lists all parameters for the cmdlet, you may not have access to some parameters if they're not included in the permissions assigned to you. To find the permissions required to run any cmdlet or parameter in your organization, see [Find the permissions required to run any Exchange cmdlet](https://learn.microsoft.com/powershell/exchange/find-exchange-cmdlet-permissions).
32+
33+
## EXAMPLES
34+
35+
### Example 1
36+
```powershell
37+
Get-TeamsProtectionPolicyRule
38+
```
39+
40+
This example shows detailed information about the Teams protection policy in the organization.
41+
42+
## PARAMETERS
43+
44+
### -Identity
45+
The Identity parameter specifies the Teams protection policy rule that you want to view. There's only one Teams protection policy rule in an organization named Teams Protection Policy Rule.
46+
47+
```yaml
48+
Type: RuleIdParameter
49+
Parameter Sets: (All)
50+
Aliases:
51+
Applicable: Exchange Online
52+
53+
Required: False
54+
Position: 1
55+
Default value: None
56+
Accept pipeline input: True (ByPropertyName, ByValue)
57+
Accept wildcard characters: False
58+
```
59+
60+
### -Organization
61+
This parameter is reserved for internal Microsoft use.
62+
63+
```yaml
64+
Type: OrganizationIdParameter
65+
Parameter Sets: (All)
66+
Aliases:
67+
Applicable: Exchange Online
68+
69+
Required: False
70+
Position: Named
71+
Default value: None
72+
Accept pipeline input: False
73+
Accept wildcard characters: False
74+
```
75+
76+
### -State
77+
The State parameter filters the results by the State value of the rule. Valid values are:
78+
79+
- Enabled
80+
- Disabled
81+
82+
```yaml
83+
Type: RuleState
84+
Parameter Sets: (All)
85+
Aliases:
86+
Applicable: Exchange Online
87+
88+
Required: False
89+
Position: Named
90+
Default value: None
91+
Accept pipeline input: False
92+
Accept wildcard characters: False
93+
```
94+
95+
### CommonParameters
96+
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](https://go.microsoft.com/fwlink/p/?LinkID=113216).
97+
98+
## INPUTS
99+
100+
## OUTPUTS
101+
102+
## NOTES
103+
104+
## RELATED LINKS

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

0 commit comments

Comments
 (0)