使用powershell查看M365动态组成员(世纪互联)

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>
 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值