• Help with a PowerShell command

    Home » Forums » Admin IT Lounge » Admin IT Lounge – Miscellaneous » Help with a PowerShell command

    Author
    Topic
    #504933

    Hi all. I’m trying to figure out a Powershell command I can use to get me the following information in a csv file. I’m not really proficient in powershell so this is extremely difficult. I’m just trying to find something that some has already used that I can give a try. I’ve tried this – https://gallery.technet.microsoft.com/scriptcenter/Generate-Mailbox-Size-and-3f408172 – and this – https://gallery.technet.microsoft.com/exchange/Exchange-Mailbox-Report-c805970e – but haven’t figured out how to edit them to do what I want or give me what I need. Any ideas? Again, all I need is what you see below for my entire organization. We have an Exchange 2007 server.




    [TABLE=”class: cke_show_border, width: 2057″]
    [TR]
    [TD=”width: 354″]DisplayName[/TD]
    [TD=”width: 90″]Company[/TD]
    [TD=”width: 319″]PrimarySmtpAddress[/TD]
    [TD=”width: 116″]Alias[/TD]
    [TD=”class: xl63, width: 124″]TotalItemSize(MB)[/TD]
    [TD=”width: 310″]Full Access Rights[/TD]
    [TD=”width: 744″]SendOnBehalf

    [/TD]
    [/TR]
    [/TABLE]

    Viewing 2 reply threads
    Author
    Replies
    • #1556370

      There is nothing below.

      Joe

      --Joe

    • #1556375

      Huh, weird. Here’s what’s missing:

      DisplayName Company PrimarySmtpAddress Alias TotalItemSize(MB) Full Access Rights SendOnBehalf

    • #1556919

      Here’s a modified (and simplified) version of the scripts you linked to. I’ve included SendAs permissions as well as SendOnBehalfOf. The permissions are given as a list of users separated by spaces. The field delimiter is a semicolon and there are likely to be commas in the TotalItemSize column.

      [HTML]#Specify the csv file name and location
      $outFile = “E:info.csv”

      # Prepare output collection
      $return = @()

      # Loop through Exchange Server Mailboxes
      $Mailboxes = Get-Mailbox -ResultSize Unlimited -IgnoreDefaultScope -ErrorAction SilentlyContinue
      ForEach ($Mailbox in $Mailboxes)
      {

      $userStatistics = Get-MailboxStatistics $Mailbox.Identity

      $totalItemSize = if ($userStatistics.TotalItemSize.Value) {$userStatistics.TotalItemSize.Value.ToKB()}

      $Obj = New-Object PSObject
      $Obj | Add-Member NoteProperty -Name “DisplayName” -Value $Mailbox.DisplayName
      $Obj | Add-Member NoteProperty -Name “PrimarySmtpAddress” -Value $Mailbox.PrimarySmtpAddress
      $Obj | Add-Member NoteProperty -Name “Alias” -Value $Mailbox.Alias
      $Obj | Add-Member NoteProperty -Name “TotalItemSize(KB)” -Value (“{0:n0}” -f $totalItemSize)

      $permissions=get-mailboxpermission $Mailbox.Identity
      #get the permissions
      $fullacces=””
      $sendas=””
      foreach ($p in $permissions)
      {
      if ($p.AccessRights -like “*FullAccess*”) {$fullaccess += ” ” + $p.User.RawIdentity}
      if ($p.AccessRights -like “*SendAs*”) {$sendas += ” ” + $p.User.RawIdentity}
      }
      $Obj | Add-Member NoteProperty -Name “FullAccess” -Value $fullaccess
      $Obj | Add-Member NoteProperty -Name “SendAs” -Value $sendas
      #get SendOnBehalfOf
      $sendonbehalf=””
      foreach($p in $Mailbox.GrantSendonBehalfTo)
      {
      $sendonbehalf += ” ” + $p.Parent + “/” + $p.Name
      }
      $Obj | Add-Member NoteProperty -Name “SendOnBehalfOf” -Value $sendonbehalf

      $return += $Obj
      }

      # Export output to csv
      $return | Export-Csv -Path $outFile -Delimiter “;” -Force -noTypeInformation -Encoding UTF8 [/HTML]

      The time it takes to execute depends on the number of mailboxes you have. You may want to look at some at a time by restricting teh number returned in teh line starting $Mailboxes=

    Viewing 2 reply threads
    Reply To: Help with a PowerShell command

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: