• 导出Office365中的组及成员


    Set-ExecutionPolicy unrestricted

    $cred = Get-Credential 

    $session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri "https://outlook.office365.com/powershell-liveid/" -Credential $cred -Authentication Basic -AllowRedirection

    Import-PSSession $session

    get-distributiongroup -resultsize unlimited |ft name, managedby

    $Groups = Get-DistributionGroup

    $Groups | ForEach-Object {$group = $_.Name

    $members = ''

    Get-DistributionGroupMember $group | ForEach-Object {

             If($members) {

                   $members=$members + ";" + $_.Name

               } Else {

                   $members=$_.Name

              }

       }

    导出组一

    $Groups | ForEach-Object {

    $group = $_.Name

    $members = ''

    Get-DistributionGroupMember $group | ForEach-Object {

             If($members) {

                   $members=$members + ";" + $_.Name

                } Else {

                   $members=$_.Name

                }

       }

    New-Object -TypeName PSObject -Property @{

           GroupName = $group

           Members = $members

          }

    } | Export-CSV "D:Distribution-Group-Members.csv" -NoTypeInformation -Encoding UTF8

     

    导出组二

    $file_name = "D:Groups.csv"

    add-content -value ("Distribution List"+","+"Display Name"+","+"Group Type"+","+"Time"+","+"Message Approval"+","+"Member") -path $file_name

    $DL=get-DistributionGroup 

    foreach ($_ in $DL)

    {

                    $name = $_.DisplayName

                    $ID =  $_.PrimarySmtpAddress

                    $Type =  $_.RecipientType

                    $modified = $_.WhenChanged

                    $DLmember=get-DistributionGroupMember -identity $_.identity

                    foreach($_ in $DLmember)

                    {

                                    $members = $_.PrimarySmtpAddress    

    add-content -value ($ID +","+$name +","+$Type +","+$modified +","+$members) -path $file_name}

                    }

    }

  • 相关阅读:
    响应头中的 ETag 值是如何生成的
    http请求状态码
    RPC 和 REST 有什么优劣
    comet 长轮询与 node 实现
    HTTPS 加密
    iterm2 快捷键
    static in C/C++
    03-树3 Tree Traversals Again
    2016.03.19随笔
    03-树2 List Leaves
  • 原文地址:https://www.cnblogs.com/gill/p/6680236.html
Copyright © 2020-2023  润新知