Windows PowerShell
版权所有(C) Microsoft Corporation。保留所有权利。
安装最新的 PowerShell,了解新功能和改进!https://aka.ms/PSWindows
PS C:\Windows\system32> Set-ExecutionPolicy RemoteSigned
执行策略更改
执行策略可帮助你防止执行不信任的脚本。更改执行策略可能会产生安全风险,如 https:/go.microsoft.com/fwlink/?LinkID=135170
中的 about_Execution_Policies 帮助主题所述。是否要更改执行策略?
[Y] 是(Y) [A] 全是(A) [N] 否(N) [L] 全否(L) [S] 暂停(S) [?] 帮助 (默认值为“N”): A
PS C:\Windows\system32> $O365Cred = Get-Credential
位于命令管道位置 1 的 cmdlet Get-Credential
请为以下参数提供值:
Credential
PS C:\Windows\system32> Connect-ExchangeOnline -UserPrincipalName admin@pocyiche.partner.onmschina.cn -AzureADAuthorizationEndpointUri https://login.chinacloudapi.cn/common/oauth2/v2.0/token -ConnectionUri https://partner.outlook.cn/PowerShell
----------------------------------------------------------------------------------------
This V3 EXO PowerShell module contains new REST API backed Exchange Online cmdlets which doesn't require WinRM for Client-Server communication. You can now run these cmdlets after turning off WinRM Basic Auth in your client machine thus making it more secure.
Unlike the EXO* prefixed cmdlets, the cmdlets in this module support full functional parity with the RPS (V1) cmdlets.
V3 cmdlets in the downloaded module are resilient to transient failures, handling retries and throttling errors inherently.
REST backed EOP and SCC cmdlets are also available in the V3 module. Similar to EXO, the cmdlets can be run without WinRM basic auth enabled.
For more information check https://aka.ms/exov3-module
----------------------------------------------------------------------------------------
PS C:\Windows\system32> Get-DistributionGroup -ResultSize unlimited
Name DisplayName GroupType PrimarySmtpAddress
---- ----------- --------- ------------------
111 1.30 Universal 111@pocyiche.partner.onmschina.cn
HR HR Universal, SecurityEnabled HR@pocyiche.partner.onmschina.cn
IT IT Universal, SecurityEnabled IT@pocyiche.partner.onmschina.cn
RD RD Universal, SecurityEnabled RD@pocyiche.partner.onmschina.cn
sales Sales Universal, SecurityEnabled sales@pocyiche.partner.onmschina.cn
PS C:\Windows\system32>
PS C:\Windows\system32> Get-DynamicDistributionGroup -ResultSize unlimited
Name ManagedBy
---- ---------
9.1 user03
PS C:\Windows\system32> $Tech =Get-DynamicDistributionGroup "ALL"
Write-ErrorMessage : Ex6F9304|Microsoft.Exchange.Configuration.Tasks.ManagementObjectNotFoundException|由于在'BJSPR01A0
1DC001.CHNPR01A001.prod.partner.outlook.cn'上找不到对象'ALL',因此无法执行该操作。
所在位置 C:\Users\lixy01\AppData\Local\Temp\tmpEXO_o2rajy4s.oxv\tmpEXO_o2rajy4s.oxv.psm1:1178 字符: 13
+ Write-ErrorMessage $ErrorObject
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Get-DynamicDistributionGroup], ManagementObjectNotFoundException
+ FullyQualifiedErrorId : [Server=BJSPR01MB0692,RequestId=75147d13-2046-9906-8362-1a251c403af9,TimeStamp=Fri, 01 S
ep 2023 04:13:56 GMT],Write-ErrorMessage
PS C:\Windows\system32> $Tech =Get-DynamicDistributionGroup "9.1"
PS C:\Windows\system32> Get-Recipient -ResultSize unlimited -RecipientPreviewFilter $Tech.RecipientFilter
Name RecipientType
---- -------------
user04 UserMailbox
user03 UserMailbox
user06 UserMailbox
user05 UserMailbox
admin UserMailbox
test UserMailbox
huier UserMailbox
PS C:\Windows\system32> history
Id CommandLine
-- -----------
1 Set-ExecutionPolicy RemoteSigned
2 $O365Cred = Get-Credential
3 Connect-ExchangeOnline -UserPrincipalName admin@pocyiche.partner.onmschina.cn -AzureADAuthorizationEndpointUri https://login.chinacloudapi.cn/common/oauth2/v2.0/token -ConnectionUri https://partner.outlook.cn/PowerShell
4 Get-DistributionGroup -ResultSize unlimited
5 Get-DynamicDistributionGroup -ResultSize unlimited
6 $Tech =Get-DynamicDistributionGroup "ALL"
7 $Tech =Get-DynamicDistributionGroup "9.1"
8 Get-Recipient -ResultSize unlimited -RecipientPreviewFilter $Tech.RecipientFilter
PS C:\Windows\system32>