Skip to content

Commit 3c9569e

Browse files
committed
New Invoke-Command Workarounds article
1 parent aa6efa1 commit 3c9569e

File tree

3 files changed

+15
-8
lines changed

3 files changed

+15
-8
lines changed

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

Lines changed: 4 additions & 2 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.

exchange/docs-conceptual/invoke-command-workarounds-rest-api.md

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
---
2-
title: Workarounds
2+
title: Workarounds for Invoke-Command scenarios in REST API connections
33
ms.author: chrisda
44
author: chrisda
55
manager: dansimp
6-
ms.date:
6+
ms.date: 7/5/2023
77
ms.audience: Admin
88
audience: Admin
99
ms.topic: article
@@ -17,16 +17,19 @@ search.appverid: MET150
1717
description: "Learn about the alternatives to Invoke-Command commands in REST API connections using the EXO V3 module."
1818
---
1919

20-
# Workarounds
20+
# Workarounds for Invoke-Command scenarios in REST API connections
2121

22-
In multiple remote PowerShell connections to Exchange Online in the same window, you use the [Invoke-Command](/powershell/module/microsoft.powershell.core/invoke-command) cmdlet to run scripts or commands in specific remote PowerShell sessions. 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 PowerShell.
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.
2323

2424
This article offers REST API alternatives for scenarios that that use **Invoke-Command** commands.
2525

2626
## Scenario 1: Run Exchange Online cmdlets
2727

2828
This example finds the identity of any other user (`$Us = $User.Identity`).
2929

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+
3033
- **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:
3134

3235
```powershell
@@ -110,15 +113,15 @@ This example shows how to create two PowerShell sessions in the same window and
110113
5. Now you can run commands in either session. For example:
111114
112115
```powershell
113-
$CommandStr1 = "Get-$($ConnectionInfo1.ModulePrefix)Mailbox -ResultSize 1"
116+
$CommandStr1 = "Get-$($ConnectionInfo1.ModulePrefix)Mailbox -ResultSize 10"
114117
115118
Invoke-Expression $CommandStr1
116119
```
117120
118121
Or
119122
120123
```powershell
121-
$CommandStr2 = "Get-$($ConnectionInfo2.ModulePrefix)Mailbox -ResultSize 1"
124+
$CommandStr2 = "Get-$($ConnectionInfo2.ModulePrefix)Mailbox -ResultSize 10"
122125
123126
Invoke-Expression $CommandStr2
124127
```

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

0 commit comments

Comments
 (0)