Hello all,<\/p>\n
I have used spiceworks and the powershell gallery to advance my powershell skills and it has helped a lot. Now I have an issue. I am having an issue getting data from a csv file full of mailboxes. The goal is to gather the display name and mailbox size in GB, but I am getting the below error. Below is the script I am running and the error I get from running the script. Can someone help me understand what I am doing wrong? Also tbh I do not understand this error. Forgive my ignorance.<\/p>\n
Script :<\/p>\n
$File = Import-Csv “C:\\TotalMailboxes.csv”<\/p>\n
Get-MailboxStatistics -identity $File | FL DisplayName, DataBase, ServerName, @{label=”Total Size (KB)”;expression={$_.TotalItemSize.Value.ToGB()}<\/p>\n
Error :<\/p>\n
Cannot process argument transformation on parameter ‘Identity’. Cannot convert the “System.Collections.ArrayList” value of type “System.Collections.ArrayList” to type “Microsoft.Exchange.Configuration.Tasks.GeneralMailboxorMailUserIdParameter”.<\/p>\n
CategoryInfo : InvalidData: ( [Get-MailboxStatistics], ParameterBindin…mationException<\/p>\n<\/li>\n
FullyQualifiedErrorId : ParameterArgumentTransformationError,Get-MailboxStatistics<\/p>\n<\/li>\n
PSComputerName : [email protected]<\/a><\/p>\n<\/li>\n<\/ul>","upvoteCount":6,"answerCount":8,"datePublished":"2020-01-17T16:41:14.000Z","author":{"@type":"Person","name":"spicygeorgia-ufgb5","url":"https://community.spiceworks.com/u/spicygeorgia-ufgb5"},"acceptedAnswer":{"@type":"Answer","text":" You’re trying to convert an array in the CSV into a single property. You need to loop through it with something like this:<\/p>\n This makes the assumption that your parameter is named “identity” other wise you would need to adjust $_.identity to whatever the column heading is named.<\/p>","upvoteCount":2,"datePublished":"2020-01-17T18:40:18.000Z","url":"https://community.spiceworks.com/t/exchange-powershell-mailbox-statistics/747143/3","author":{"@type":"Person","name":"timhetzel","url":"https://community.spiceworks.com/u/timhetzel"}},"suggestedAnswer":[{"@type":"Answer","text":" Hello all,<\/p>\n I have used spiceworks and the powershell gallery to advance my powershell skills and it has helped a lot. Now I have an issue. I am having an issue getting data from a csv file full of mailboxes. The goal is to gather the display name and mailbox size in GB, but I am getting the below error. Below is the script I am running and the error I get from running the script. Can someone help me understand what I am doing wrong? Also tbh I do not understand this error. Forgive my ignorance.<\/p>\n Script :<\/p>\n $File = Import-Csv “C:\\TotalMailboxes.csv”<\/p>\n Get-MailboxStatistics -identity $File | FL DisplayName, DataBase, ServerName, @{label=”Total Size (KB)”;expression={$_.TotalItemSize.Value.ToGB()}<\/p>\n Error :<\/p>\n Cannot process argument transformation on parameter ‘Identity’. Cannot convert the “System.Collections.ArrayList” value of type “System.Collections.ArrayList” to type “Microsoft.Exchange.Configuration.Tasks.GeneralMailboxorMailUserIdParameter”.<\/p>\n CategoryInfo : InvalidData: ( FullyQualifiedErrorId : ParameterArgumentTransformationError,Get-MailboxStatistics<\/p>\n<\/li>\n PSComputerName : [email protected]<\/a><\/p>\n<\/li>\n<\/ul>","upvoteCount":6,"datePublished":"2020-01-17T16:41:14.000Z","url":"https://community.spiceworks.com/t/exchange-powershell-mailbox-statistics/747143/1","author":{"@type":"Person","name":"spicygeorgia-ufgb5","url":"https://community.spiceworks.com/u/spicygeorgia-ufgb5"}},{"@type":"Answer","text":" try to use a foreach instead direct pipe<\/p>\n Essentially the error means that you’re trying to use an array when it is expecting a name and it can’t ‘transform’ one data type to another. Other data types it can, like integer/strings, but not an array of strings into a string. Make sense?<\/p>\n Like the others have said, step through the array with a foreach command, then you’ll be able to provide the argument type that it is looking for<\/p>","upvoteCount":0,"datePublished":"2020-01-17T20:51:14.000Z","url":"https://community.spiceworks.com/t/exchange-powershell-mailbox-statistics/747143/4","author":{"@type":"Person","name":"matthart5","url":"https://community.spiceworks.com/u/matthart5"}},{"@type":"Answer","text":" why are you pulling the info from a csv for the mailboxes, and not just pulling the mailboxes from the server? If you mis-spell anything in the CSV, or have mailbox names that are outdated, you’ll end up with more errors.<\/p>\n Try the report I’m attaching. (rename to .ps1 to use)<\/p>\n It has a lot of options that I have commented out currently, but it will give you a better look at mailbox info breakdowns when you cant figure out why someone’s mailbox is in the GB in size, but they have less than 1000 messages in an inbox.<\/p>\n MBX_Report-SizeAll2013.txt<\/a> (3.65 KB)<\/p>","upvoteCount":0,"datePublished":"2020-01-17T23:29:46.000Z","url":"https://community.spiceworks.com/t/exchange-powershell-mailbox-statistics/747143/5","author":{"@type":"Person","name":"CrashFF","url":"https://community.spiceworks.com/u/CrashFF"}},{"@type":"Answer","text":" According to the script error “ Cannot process argument transformation on parameter ‘Identity’<\/strong> ”, I tried to modify the value in the parameter “Identity<\/strong>” in the following script and the script helped me get the display name and mailbox size in GB, you could add or modify the entry in the CSV file and the parameter “Identity<\/strong>”, in addition, before you run the script, please confirm that there are no extra objects(Just like “Blank<\/strong>”) in the entries:<\/p>\n Sorry for the delayed reply for I have been away for the weekend. @timhetzel<\/a> That worked sir. Thank you very much. I had to change -Identity $.Identity to -Identity $<\/em>.PrimarySMTPAddress as that is what I have as the header of the CSV.<\/p>\n @matthart5<\/a> Thanks for explaining that. That does make since to me now.<\/p>\n @ianadams2<\/a> The reason for the CSV is because these mailboxes are coming from multiple servers and databases within the environment so having a CSV of all the mailboxes is much more helpful.<\/p>\n Thank you also @alexw<\/a> & @ivan-wang<\/a> <\/p>","upvoteCount":0,"datePublished":"2020-01-20T12:06:07.000Z","url":"https://community.spiceworks.com/t/exchange-powershell-mailbox-statistics/747143/7","author":{"@type":"Person","name":"spicygeorgia-ufgb5","url":"https://community.spiceworks.com/u/spicygeorgia-ufgb5"}},{"@type":"Answer","text":" You are running this command Get-MailboxStatistics -identity<\/em><\/p>\n and THEN filtering what information is displayed. You aren’t specifying any servers or databases in that command, so where they are located is irrelevant, and there isn’t really a need for the csv file, unless<\/em> you only want results from specific mailboxes,<\/em> and not your whole exchange environment*. IN which case I still recommend get everything, and then just filter it down in excel afterwards.*<\/p>\n Look at the script I put up as a TXT file, you’ll see it has commented options for server name and database, and a whole bunch of other stuff, and gives you a nice formatted output that goes into excel with zero problems.<\/p>","upvoteCount":0,"datePublished":"2020-01-21T16:27:59.000Z","url":"https://community.spiceworks.com/t/exchange-powershell-mailbox-statistics/747143/8","author":{"@type":"Person","name":"CrashFF","url":"https://community.spiceworks.com/u/CrashFF"}}]}}
$File = Import-Csv \"C:\\TotalMailboxes.csv\"\n\n$file | foreach {Get-MailboxStatistics -identity $_.identity | select DisplayName, DataBase, ServerName, @{label=”Total Size (KB)”;expression={$_.TotalItemSize.Value.ToGB()}}\n\n<\/code><\/pre>\n
\n
[Get-MailboxStatistics], ParameterBindin…mationException<\/p>\n<\/li>\n
$File = Import-Csv \"C:\\TotalMailboxes.csv\"\nforeach($mbx in $file){\n Get-MailboxStatistics -identity $mbx | \n FL DisplayName, DataBase, ServerName, @{label=”Total Size (KB)”;expression={$_.TotalItemSize.Value.ToGB()}\n}\n<\/code><\/pre>","upvoteCount":2,"datePublished":"2020-01-17T18:37:08.000Z","url":"https://community.spiceworks.com/t/exchange-powershell-mailbox-statistics/747143/2","author":{"@type":"Person","name":"Neally","url":"https://community.spiceworks.com/u/Neally"}},{"@type":"Answer","text":"
\n<b>Import-CSV\n“C:\\Mailbox.csv” | foreach{</b>\n\n<b>Get-MailboxStatistics\n-Identity $_.DisplayName | FL DisplayName,Database,ServerName,@{label=”Total\nSize (KB)”;expression={$_.TotalItemSize.Value.ToGB()}}</b>\n\n**}**\n<\/code><\/pre>\n
<\/p>","upvoteCount":0,"datePublished":"2020-01-20T08:47:09.000Z","url":"https://community.spiceworks.com/t/exchange-powershell-mailbox-statistics/747143/6","author":{"@type":"Person","name":"ivan-wang","url":"https://community.spiceworks.com/u/ivan-wang"}},{"@type":"Answer","text":"