Getting OU of users into CSV created by script

Hi.
I've found this script that let's us analyze mailbox Growth over time.
http://gallery.technet.microsoft.com/scriptcenter/Generate-report-of-user-e4e9afca  (script shown below)
But I need to add the OU of the user to the script as we are hosting different Companies on the Exchange server I'll be using it on. Therefore it' necessary to be able to sort by using the OU the users are located in.
I've found out that Get-MailboxStatisics cannot do this for me and therefore that a custom object has to be used. But to be honest I'm a total noob at scripting so I'll be very gratefull if anyone can help me out here and tell me how I should customize
the script below
<#
The sample scripts are not supported under any Microsoft standard support
program or service. The sample scripts are provided AS IS without warranty 
of any kind. Microsoft further disclaims all implied warranties including, 
without limitation, any implied warranties of merchantability or of fitness for
a particular purpose. The entire risk arising out of the use or performance of 
the sample scripts and documentation remains with you. In no event shall
Microsoft, its authors, or anyone else involved in the creation, production, or
delivery of the scripts be liable for any damages whatsoever (including,
without limitation, damages for loss of business profits, business interruption,
loss of business information, or other pecuniary loss) arising out of the use
of or inability to use the sample scripts or documentation, even if Microsoft
has been advised of the possibility of such damages.
#>
#requires -Version 2
param
 [Switch]$ExportMailboxSize,
 [Switch]$CompareMailboxSize,
 [String]$LogPath="C:\log",
 [String[]]$Identity,
 [DateTime]$StartDate,
 [DateTime]$EndDate
#region Export today's Mailbox Size
if ($ExportMailboxSize)
 $Counter=0
 $UserMailboxStatistics=@()
 if(-not ( Test-Path -Path $LogPath))
  New-Item -ItemType  directory -Path $LogPath
 #Get mailbox identity
 if (-not ($Identity))
  $UserMailboxs=Get-Mailbox -Filter 'RecipientTypeDetails -eq "UserMailbox"' -ResultSize unlimited
 else
  $UserMailboxs=$Identity|Get-Mailbox -Filter 'RecipientTypeDetails -eq "UserMailbox"' -ResultSize unlimited
 #Get SamAccountName,DisplayName and MailboxTotalItemSize for specific users or all users with mailbox.
 foreach ($UserMailbox in $UserMailboxs)
  $Counter++
  Write-Progress -Activity "Export MailboxStatistic" -Status "Exporting" -CurrentOperation $UserMailbox.DisplayName -PercentComplete ($counter/($UserMailboxs.Count)*100)
  $UserMailboxStatistic = New-Object PSObject
  $UserMailboxSizeB = (Get-MailboxStatistics -Identity $UserMailbox).TotalItemSize.Value.tobytes()
  $UserMailboxSizeMB = "{0:#.##}" -f ($UserMailboxSizeB/1mb)
  $UserMailboxStatistic | Add-Member -MemberType NoteProperty -Name "SamAccountName" -Value $UserMailbox.SamAccountName
  $UserMailboxStatistic | Add-Member -MemberType NoteProperty -Name "DisplayName" -Value $UserMailbox.DisplayName
  $UserMailboxStatistic | Add-Member -MemberType NoteProperty -Name "UserMailboxSizeMB" -Value $UserMailboxSizeMB
  $UserMailboxStatistics+=$UserMailboxStatistic
 #Output to a CSV file with date format "yyyy-MM-dd" as default name  ,in default path "C:\log". Path can be set by $logpath param.
 $UserMailboxStatistics|Export-Csv -Encoding default -NoTypeInformation -Path "$LogPath\$(get-date -Format "yyyy-MM-dd").csv"
#endregion
#region Compare Mailbox Size
if ($CompareMailboxSize)
 $TempCSVs=@()
 $report=@{}
 $index=-1
 #Check if path is correct
 if(-not ( Test-Path -Path $LogPath))
  Write-Error -Message "'$LogPath' doesn't exist, please make sure the path is correct"
  return
 [array]$CSVFiles=Get-ChildItem $LogPath -Exclude "Compare*"|Sort-Object -Property "CreationTime"
 #Summary all CSV files during the period,given by user 
 if ($StartDate -and $EndDate)
  foreach ($CSVFile in $CSVFiles)
   if ($CSVFile.CreationTime.date -ge $StartDate.date -and $CSVFile.CreationTime.date -le $EndDate.date)
    $TempCSVs+=$CSVFile
 else
  Write-Error -Message "StartDate or EndDate is not correct or not given. Please make sure the format is correct."
  return
 #Check wether CSV files exist during the period
 if (-not $TempCSVs)
  Write-Error "log file created from '$StartDate' to '$EndDate' doesn't exist in '$LogPath'. Please check."
  return
 else
  #Import these CSV files 
  foreach($TempCSV in $TempCSVs)
   $TempDate=$TempCSV.basename
   $counter=0
   $index++
   $UserMailboxStatistics=Import-Csv -Path $TempCSV.fullname
   #add user's mailbox status to report
   foreach ($UserMailboxStatistic in $UserMailboxStatistics)
    if (-not $report.ContainsKey($UserMailboxStatistic.SamAccountName))
     $TempUserMailboxStatistic=New-Object psobject
     $TempUserMailboxStatistic|Add-Member -MemberType NoteProperty -Name "SamAccountName" -Value $UserMailboxStatistic.SamAccountName
     $TempUserMailboxStatistic|Add-Member -MemberType NoteProperty -Name "DisplayName" -Value $UserMailboxStatistic.DisplayName
     $TempUserMailboxStatistic|Add-Member -MemberType NoteProperty -Name "Remark" -Value "Online"
     for ($i=0;$i -lt $TempCSVs.count;$i++)
      $TempUserMailboxStatistic|Add-Member -MemberType NoteProperty -Name "$($TempCSVs[$i].basename)" -Value "N/A"
     $report.Add($UserMailboxStatistic.SamAccountName,$TempUserMailboxStatistic)
    #write progress
    $Counter++
    Write-Progress -Activity "Compare MailboxSize on $TempDate" -Status "Comparing"`
    -CurrentOperation $TempUserMailboxStatistic.DisplayName -PercentComplete ($counter / ($UserMailboxStatistics.Count) * 100)
    $report[$UserMailboxStatistic.SamAccountName].$TempDate=$UserMailboxStatistic.UserMailboxSizeMB
   #check wether users' mailboxes were removed or added.
   $report.values|%{`
   if ($_.$TempDate -eq "N/A" -and $_.Remark -notlike "Remove*")`
    {$_.Remark="Removed on $TempDate"};`
   if ($_.$TempDate -ne "N/A" -and $index -ne 0 -and $_.$($TempCSVs[$index-1].basename) -eq "N/A")`
    {$_.Remark="Added on $TempDate"}}
 #Export report to CSV file
 $report.Values|Export-Csv -Encoding default -NoTypeInformation -Path "$LogPath\Compare$(get-date $StartDate -Format "yyyy-MM-dd")TO$(get-date $EndDate -Format "yyyy-MM-dd").csv"
#endregion
if (-not $ExportMailboxSize -and -not $CompareMailboxSize)
Write-Warning -Message "You did not choose any task. Please choose one."

StoreThomas,
At the top of this script, you will see a section where the user mailboxes are collected then each is checked.  Line 45 starts this section.  Just under that, you can see that a custom psObject is created (line 50) and defined (the next 5
lines) and added to an overall list of mailbox statistics (line 56).  You can add an Add-Member line before line 56 that says the following:
$UserMailboxStatistic | Add-Member -MemberType NoteProperty -Name "OrgUnit" -Value $UserMailbox.OrganizationalUnit
That should add your OU to the list of exported fields, and you can use Excel to open and filter that list.

Similar Messages

  • Get only user into a group

    can i get only the users into a group?
    I use the search_s function but it returns to me the users and also the groups.
    this is my function:
    my_attrs(1) := 'uniquemember';
    filter :='cn='||nameGroup;
    my_session := DBMS_LDAP.init(ldap_host,ldap_port);
    retval := DBMS_LDAP.simple_bind_s(my_session,ldap_user, ldap_passwd);
    retval := DBMS_LDAP.search_s( my_session,
    ldap_base,
    DBMS_LDAP.SCOPE_SUBTREE,
    filter ,
    my_attrs,
    0,
    my_message);
    my_entry := DBMS_LDAP.first_entry(my_session, my_message);
    ecc..
    the output is:
    cn=gatano_188,cn=users,dc=s,dc=com
    cn=gatano_187,cn=users,dc=society ,dc=com
    cn=gatano_799,cn=users,dc=society ,dc=com
    cn=gatanogruppo_5,cn=groups,dc=society ,dc=com
    I would want only the users.
    how can I filter the users?
    thanks

    Thanks for the reponse. I appreciate that very much. Please do provide a link of any document explaining this mogration procedure or any other relevent document that can help us achieve it.
    Thanks one again.
    kymlaik

  • Export batch data into CSV file using SQL SP

    Hi,
    I have created WCF-Custom receive adapter to poll Sql SP (WITH xmlnamespaces(DEFAULT 'Namespace' and For XML PATH(''), Type) . Get the result properly in batch while polling and but getting error while converting into CSV by using map.
    Please can anyone give me some idea to export SQL data into CSV file using SP.

    How are you doing this.
    You would have got XML representation for the XML batch received from SQL
    You should have a flat-file schema representing the CSV file which you want to send.
    Map the received XML representation of data from SQL to flat-file schema
    have custom pipeline with flat-file assembler on the assembler stage of the send pipeline.
    In the send port use the map which convert received XML from SQL to flat file schema and use the above custom flat-file disassembler send port
    If this answers your question please mark it accordingly. If this post is helpful, please vote as helpful by clicking the upward arrow mark next to my reply.

  • Confused on FIM Service MA. It does not seem to be pulling my AD users into the correct place for the Portal

    I ran a full AD import which gave me about 20K of adds.
    Per the FIM Book I have I set a connector filter to filer out the admin and built in sync accounts
    After running that MA I got 2 adds.
    How do I get my AD users into the portal if FIM service does not import them. Is it a synch? I don't want to synch anything from the FIM DB back into AD, so I am being cautious 

    Hi,
    import just fills the connector space of fim sync.
    connector space is like some kind of cache of the connected data source which FIM lets calculate delta which need then to be synced to the MV
    so after import you need to have a sync rule in place for ad (or MA import attribute flows).
    if objects needs to be created in MV you must project them by either projection criteria or by enable ceate object from external data source in sync rule.
    Objects are in MV then, an will can be exported to fim service ma regarding to the export attribute flows of the fim service ma.
    -Peter
    Peter Stapf - ExpertCircle GmbH - My blog:
    JustIDM.wordpress.com

  • Once I get a pdf file into EXCEL

    How do we convert the data into columnar spreadsheet form?

    YES
    From: David Kastendick [email protected]
    Sent: Thursday, October 04, 2012 1:07 PM
    To: roncarter
    Subject: Once I get a pdf file into EXCEL
    Re: Once I get a pdf file into EXCEL
    created by David Kastendick <http://forums.adobe.com/people/dave_m_k> in *Adobe
    ExportPDF* - View the full
    discussion<http://forums.adobe.com/message/4749880#4749880

  • How to get sql query data and write into csv file?

    I am writing to seek help, in how can I create bat. script which can execute the following logic:
    connection to the database
    run sql query
    create CSV file
    output query data, into CSV file
    save the CSV file
    osql
    -S 84.18.111.111
    -U adw
    -P rem
    -i "c:\query.sql"
    send ""
    sed -e 's/,\s\+/,/g' MCI_04Dec2014.csv > localNoSpaces.csv
    -o "c:\MCI_04Dec2014.csv"
    This what i have so far, and I am little struggling with the logic after creating CSV file. I am unable to get the above script to work, please advice further, where I may be going wrong. 
    Can you create if statement logic within window's script, to check for null parameters or data feeds?
    Any hints would be most appreciated. 

    Thank you for your reply. 
    Apology for posting the code irrelevant to the forum, as I am still novice scripting user.  
    My goal is to create window's script which can compute the above logic and send the final output file (csv), to FTP folder. 
    Can this logic be implemented via bat. script, if so, is there a example or tutorial i could follow, in order to achieve my task. 
    Any help would be much appreciated. 

  • Importing users into WGM from csv file issues/crash

    Hi,
    i've been importing user information from csv files into WGM via the +server >  import+ function .
    It worked the first few times but now when i try the import progress bar pops up and promptly disappears without any thing importing.
    i've tried restarts, new admin account, reinstalled  WGM.
    I've also trashed some pref but i don't really know which ones i should be losing.
    The servers an OD master.
    any help would be appreciated.
    as a last resort what do i need to backup/save if i were to format/reinstall osx server? keeping my settings etc.....
    thanks
    paul

    What I did was:
    Exported the user list, to create an XML file in the correct format.
    Using this format, I created a spreadsheet in Excel (sorry Apple), and in the final column I created a field that concatenated the information I wanted in the ':' deliminated format of the previously export XML.
    Then just copy and past via pico into a pure text file and imported that.
    You have to be careful with comments in Passenger, using special characters (';!@#$%^ and others can cause the WGM to fail and crash.

  • Need powershell commands to get email addresses from public folder created in EAC to CSV

    Need powershell commands to get email addresses from public folder created in EAC to CSV
    1. Created Public folders via EAC - not mail enabled - just to hold contacts.
    2. Assigned owners and showed to add new contacts - then add to favorites and finally to display as address book.
    Now I need a powershell command to get those email contacts in those public folders.
    I need to view them because when we send emails to those groups (via select all) in the public folders, it is creating an NDR for 3 users saying - "..blah blah -OFFICE FAX or HOME FAX) - yet they are getting the emails.
    I suspect that their contact details are corrupt somehow and want to see what contacts are actually listed in the public folders. I already checked to see if the source of the contacts was the public folder or "my contacts" and they are not.'
    I have tried multiple get recipient commands and get public folder commands with no results in the CSV

    The only way to get that data is either via the Outlook com object or using EWS. None of the commands in the Exchange shell look inside of a folder, the most you can get with those is email addresses for mail-enabled Public folders. Here is a link that can
    get you started with how to connect to public folders via EWS, then its just enumerating the folders and looping through the items in the folders for the details of the items. 
    http://gsexdev.blogspot.com/2013/08/public-folder-ews-how-to-rollup-part-1.html
    DJ Grijalva | MCITP: EMA 2007/2010 SPA 2010 | www.persistentcerebro.com

  • My iTunes downloads were made using my old gmail address.  I had to quit using this email address as it got hacked.  I created a new gmail account.  How can I get my iTunes downloads into the new gmail account?

    My iTunes downloads were made using my old gmail address.  I had to quit using this address  as it got hacked.  How do I get my iTunes downloads into my new iTunes account that was created with a new gmail address?  In my old iTunes account (with the old gmail address,  I can't 'update' my email address or even 'add an alternate address' as I had already created this gmail account and inputting the new address into iTunes gives me the 'pop-up' that 'this account is already in use.'   Advice please!

    Good luck. It took me weeks to fix this when I had to do it. Your old ID branches out in lots of places. You may have to delete app and get them again, at least that is what Apple told me. Plus, all of your settings on your iPad that required any ID, will have to be changed. My old ID kept showing up in different places for weeks. Changing it on Apple.com is just the beginning.

  • Creating view to get instances to user in wich he has taken part

    hellow.
    I have a question. I should to create custom view inside Oracle BPM. This view should get only instances in wich current user has taken part, for a example, some user "test" has assigned in the instance to make some task. Part "Test" has done this task and he whant to look this instance after his task. But participant is not a initiator of the instance...
    This view is similar to another view, where participant create the instance and this participant - initiator. In this case, we should only add a condition in our view like "initiator is current user"....
    But what should I do in my case, when participat is not initiator of the instance but he whants to look tasks in the instance where he have taken part.
    Thank you very much.

    I have seen this requirement come up quite often but unfortunately it is not easily supported out of the box. The limitation is that you can only filter a view based on a project variable, and user defined project variables can only be primitive types. Because of this you cannot for example keep a list of participants as a project variable. The best you can get is a comma separated list of participant ids in a string, but this is still limited to 255 characters. The next limitation is that you can only compare the current user to a Participant project variable, so the initiator or current user, not against a string. The only way we have found to get the current user in to the filter against a string was to do some workspace customizations that were not all that straight forward.

  • Task Does not get triggered when User is created through API

    Hi,
    Each new user in our OIM environment is supposed to have a iPlanet account. I have configured the access policy for the same and it works.There is also a process task which needs to be triggered once the user is successfully created in the DS. Following is my issue:
    1.When the new user is created through the admin console, the user is provisioned successfully to DS as well because of the access policy and the task also gets triggered successfully.
    2. There is an approval workflow for another resource, at the end of which a user needs to be created through APIs in OIM. The user gets created successfully in OIM and also get provisionined to DS just like in the above use case. However, the task fails in this case. I see that the task is being triggered from the user's resource profile, but the status is rejected.
    Can someone please tell me why is this happening. I initially though there was some issue with my adapter for the task, but in case 1 it works just fine.
    Following is the exception I get as soon as the iPlanet connector finishes creating the user in DS:
    java.lang.ClassCastException: java.lang.String
    at com.thortech.xl.adapterGlue.ScheduleItemEvents.adpSETFIELDSONUSERCREATE.implementation(adpSETFIELDSONUSERCREATE.java:51)
    at com.thortech.xl.client.events.tcBaseEvent.run(Unknown Source)
    Thanks,
    Supreetha

    Hi,
    Have you checked the process data that you are passing to this adapter and check the mapping of process data to the adapter variable. Try to log the value which you get from process data. I got this error when I was trying to use the literal value from process data as "true" for a boolean value. This is a bug. This value is not actually a boolean value. It threw me error too sometimes back. Either you pass the boolean value from adaptor factory as a literal value or change the type boolean both in your code and the adapter.
    OIM works strangely. ;) All the best,
    Manila

  • CLR to get the SQL Server Data into .CSV File

    Hi,
    I transformed 10 columns 1000 rows from the source table to 1 column 1000 rows in the destination table by making the comma separated columns ( Just like ..
    Insert into DestinationTable
    SELECT col1+','+col2 ....
    FROM SourceTable
    Then I want to take this column into CSV file.
    I dont have the rights to command shell.
    I heard that we may use CLR procedure for this. Can someone throw light?

    using System;
    using System.IOM
    using System.Data;
    using System.Data.SqlClient;
    using System.Data.SqlTypes;
    using Microsoft.SqlServer.Server;
    public class ExportFileClass {
    [Microsoft.SqlServer.Server.SqlProcedure]
    public static void export_file()
    using (SqlConnection connection = new SqlConnection(
    "context connection=true"))
    connection.Open();
    // Operation to open file goes here.
    SqlCommand command = new SqlCommand("SELECT col FROM YourTable");
    // Consume result set and write rows.
    Build this from the command line:
    sn -k keypair.snk
    csc /target:library /keyfile:keypair.snk exportfile.cs
    Then run in SQL Server (assuming that the files are in C:\temp on the SQL
    Server machine:
    [sql]
    USE master
    go
    -- To be able to create an external-access assembly, we need to load
    -- the key, the assembly is signed with. The key needs a password, but we
    -- don't need to know the password.
    DECLARE @sql nvarchar(MAX),
            @password char(40)
    SELECT @password = convert(char(36), newid()) + 'Ab4?'
    SELECT @sql = 'CREATE ASYMMETRIC KEY slog_loopback FROM FILE = ' +
                  '''C:\temp\keypair.snk'' ' +
                  'ENCRYPTION BY PASSWORD = ''' + @password + ''''
    PRINT @sql
    EXEC(@sql)
    -- And then a login to carry the permission.
    CREATE LOGIN exportfile$asymkey FROM ASYMMETRIC KEY ExportFile
    GRANT EXTERNAL ACCESS ASSEMBLY TO exportfile$asymkey
    go
    -- Now we can go back to our regular database and create the assembly.
    USE youddatabase
    go
    CREATE ASSEMBLY ExportFile FROM 'C:\temp\exportfile.dll'
    WITH PERMISSION_SET = EXTERNAL_ACCESS
    go
    CREATE PROCEDURE ExportFile AS
    EXTERNAL NAME ExportFile.ExportFileClass.export_file
    [sql]
    It is likely that you will have to do ask your DBA to do things in the
    master database.
    Erland Sommarskog, SQL Server MVP, [email protected]

  • New users are getting "cntl_error" whenever login into the portal

    Dear Experts,
    New users are getting "cntl_error" whenever login into the portal. They are accessing .par application. I have read so many threads, but unable to find exact solution.
    I have tried in my browser with the user login, then no error. But the user login there end then its giving "cntl_error" error.
    Problem with Internet Explore Browser? Any additional setting required for users browser?
    Could you please help me, how to resolve this error.
    Thanks in Advance.
    Regards,
    Vijay.

    Hi Vijay,
    Check this thread - "CNTL_ERROR" raised,error key: RFC_ERROR_SYSTEM_FAILURE- Show Team Calendar , this might help you on what you are looking for.
    Regards,
    Sen

  • When I launch After Effects I get a warning saying: Could not create the file'/Users/mayname/Library/Adobe/After effects/13.0/dummy'.

    When I launch After Effects I get a warning saying: Could not create the file'/Users/mayname/Library/Adobe/After effects/13.0/dummy'.

    See this:
    fixing permissions problem that impedes start of Adobe applications

  • I updated my iMac to lion and now when i leave my desktop and it goes into stand by it like a picture is taken of the screen and when i want to log in the mouse point removes pixels so i can get to the user login screen this never happened ith snow leopar

    i upgraded my iMac to lion and now when i leave my desktop and it goes into stand by mode, its like a picture is taken of the actice desktop and when i want to log in the mouse point removes pixels so i can get to the user login screen this never happened ith snow leopard. does anyone else experience this and is there a fix?

    I have an iMac 8, 1 that I upgraded Leopard to Snow Leopard.  It was totally updated with the latest from Apple when I bought and tried installing Lion.  The upgrade failed, shot my OS and I couldn't boot.  Had the constant spinner on a grey screen..  did a format of the drive, hdd repair and everything came back clean... got back to Snow Leopard and all the updates on it again and then retried the Lion thing... same bs... dead duck.  Crashed my system one too many times.  I can't see where a few small changes, mostly app related can be classified as an OS upgrade and is not compatible with my iMac.  I have the stuff running on my Mac Pro but have yet to notice anything impressive.  I've always used F3 and really didn't require Mission Control.  Just open you app folder for launch pad... duh?  I use the hot corners anyhow.  As far as Safari is concerned... as a power user, Apple missed the boat on that for me.. full screen etc.. Wow.  I don't like the new Mail either..
    As you can see/read, I'm less than impressed with this release from Apple but I own so many of their products that I will have to put up with it for now... somehow the MS logo should apply to this release Steve.

Maybe you are looking for

  • Family sharing purchased app fails to download (repeatedly)

    I'm having trouble with iTunes app purchases with family sharing. Child #1 purchased an app (a few weeks ago)--not a free app. Parent (sponsoring user) purchased another app (a couple of years ago)--not a free app. Both apps support family sharing, a

  • Can anyone help with some free real estate software for our School in the UK to practice with

    Hi Guys We are setting our class a task to set up their own Estate agency (real Estate) and need some basic web software for them to use to develp their own shop. can anyone help us with a IWEB template that they can copy their own photos over and re

  • TS4223 How do I add another ipod to my account

    I have an itunes account in under my name. I have purchased ipods for my sons and have them all registered under my account. They all sync my list of purchased itunes, but the newest ipod I bought is not syncing my itunes list. What is problem? I und

  • Calculating Lead time.... Help......

    We have two field in qals QALS: Lot created     (ENSTEHDAT)             Time                (ENTSTEZEIT) Similarly we have two field in QAVE QAVE: UD Code Date             Time            (VEZEITERF) I need to calculate the lead time i.e. Lead time =

  • Trackpad cursor clicks somewhere other than where I'm clicking

    I have a macbook pro OS X 10.7.  About 10% of my trackpad "clicks" end up activating something other than what I'm clicking on.  For example, I go to click a link on a webpage, and as I'm depressing the trackpad, the cursor jumps to my iPhoto applica