Archive Items<\/th>\n<\/tr>\n<\/thead>\n<\/table>\n<\/div>","upvoteCount":4,"answerCount":7,"datePublished":"2018-10-18T19:18:45.000Z","author":{"@type":"Person","name":"chriskrafcky","url":"https://community.spiceworks.com/u/chriskrafcky"},"acceptedAnswer":{"@type":"Answer","text":"$Data = @()\nforeach($users in Get-Mailbox -ResultSize Unlimited){$users | Foreach-Object { \n$user = $_\n$stats = Get-MailboxStatistics $user.Name\n$Archive = Get-MailboxStatistics $user.Name -archive\n\n \n$data += New-Object -TypeName PSObject -Property @{ \n\nSamAccountName = $User.SamAccountName\nDisplayName = $User.DisplayName\nEmailAddress = $user.EmailAddresses\nRetentionPolicy = $user.RetentionPolicy\nDatabase = $user.database\nArchiveDB = $Archive.database\n\nPrimarySize = $stats.TotalItemSize\nArchiveSize = $archive.TotalItemSize\n\nPrimaryItems = $stats.ItemCount\nArchiveItems = $archive.ItemCount \n} \n}\n}\n$Data | Export-Csv c:\\info2.csv -NoTypeInformation\n<\/code><\/pre>","upvoteCount":1,"datePublished":"2018-10-22T06:06:11.000Z","url":"https://community.spiceworks.com/t/powershell-help/679385/7","author":{"@type":"Person","name":"jaycekakay","url":"https://community.spiceworks.com/u/jaycekakay"}},"suggestedAnswer":[{"@type":"Answer","text":"
Hello,<\/p>\n
I’m still working on my Powershell knowledge, and I was hoping to get some assistance. I need to get a report in csv format that has the following of all of our users.<\/p>\n
\n
\n\n\nSamAccountName<\/th>\n DisplayName<\/th>\n PrimarySmtpAddress<\/th>\n RetentionPolicy<\/th>\n AccountDisabled<\/th>\n Database<\/th>\n ArchiveDatabase<\/th>\n Primary Size(MB)<\/th>\n Primary Items<\/th>\n Archive Size(MB)<\/th>\n Archive Items<\/th>\n<\/tr>\n<\/thead>\n<\/table>\n<\/div>","upvoteCount":4,"datePublished":"2018-10-18T19:18:45.000Z","url":"https://community.spiceworks.com/t/powershell-help/679385/1","author":{"@type":"Person","name":"chriskrafcky","url":"https://community.spiceworks.com/u/chriskrafcky"}},{"@type":"Answer","text":"Get-ADUser -filter * -Properties SamAccountName,DisplayName,EmailAddress,Enabled | select SamAccountName,DisplayName,EmailAddress,Enabled | Export-Csv \\\\path\\tosaveto\\filename.csv -NoTypeInformation\n<\/code><\/pre>\nIf you want to find out what other properties you can add to the csv, run this command:<\/p>\n
Get-ADUser -Filter * -Properties * | Get-Membership\n<\/code><\/pre>","upvoteCount":2,"datePublished":"2018-10-18T21:21:22.000Z","url":"https://community.spiceworks.com/t/powershell-help/679385/2","author":{"@type":"Person","name":"ejreynolds","url":"https://community.spiceworks.com/u/ejreynolds"}},{"@type":"Answer","text":"Thanks for the reply. Will this work for Exchange Management Shell?<\/p>","upvoteCount":0,"datePublished":"2018-10-18T21:30:59.000Z","url":"https://community.spiceworks.com/t/powershell-help/679385/3","author":{"@type":"Person","name":"chriskrafcky","url":"https://community.spiceworks.com/u/chriskrafcky"}},{"@type":"Answer","text":"\n\n
<\/div>\n
Scooby Spice:<\/div>\n
\nThanks for the reply. Will this work for Exchange Management Shell?<\/p>\n<\/blockquote>\n<\/aside>\n
Yes as long as you Import-Module ActiveDirectory<\/p>","upvoteCount":1,"datePublished":"2018-10-18T21:48:35.000Z","url":"https://community.spiceworks.com/t/powershell-help/679385/4","author":{"@type":"Person","name":"onecogmind","url":"https://community.spiceworks.com/u/onecogmind"}},{"@type":"Answer","text":"
foreach($users in Get-Mailbox -ResultSize Unlimited){$users | Foreach-Object { \n$user = $_\n$stats = Get-MailboxStatistics $user.Name\n$Archive = Get-MailboxStatistics $user.Name -archive\n\n \nNew-Object -TypeName PSObject -Property @{ \n\nSamAccountName = $User.SamAccountName\nDisplayName = $User.DisplayName\nEmailAddress = $user.EmailAddresses\nRetentionPolicy = $user.RetentionPolicy\nDatabase = $user.database\nArchiveDB = $Archive.database\n\nPrimarySize = $stats.TotalItemSize\nArchiveSize = $archive.TotalItemSize\n\nPrimaryItems = $stats.ItemCount\nArchiveItems = $archive.ItemCount \n} \n}\n}\n<\/code><\/pre>","upvoteCount":1,"datePublished":"2018-10-19T01:18:08.000Z","url":"https://community.spiceworks.com/t/powershell-help/679385/5","author":{"@type":"Person","name":"jaycekakay","url":"https://community.spiceworks.com/u/jaycekakay"}},{"@type":"Answer","text":"Thanks for the help. How do I export this script to csv?<\/p>","upvoteCount":0,"datePublished":"2018-10-19T15:44:50.000Z","url":"https://community.spiceworks.com/t/powershell-help/679385/6","author":{"@type":"Person","name":"chriskrafcky","url":"https://community.spiceworks.com/u/chriskrafcky"}}]}}
Hello,
I’m still working on my Powershell knowledge, and I was hoping to get some assistance. I need to get a report in csv format that has the following of all of our users.
SamAccountName
DisplayName
PrimarySmtpAddress
RetentionPolicy
AccountDisabled
Database
ArchiveDatabase
Primary Size(MB)
Primary Items
Archive Size(MB)
Archive Items
4 Spice ups
ejreynolds
(caseyejreynolds)
October 18, 2018, 9:21pm
2
Get-ADUser -filter * -Properties SamAccountName,DisplayName,EmailAddress,Enabled | select SamAccountName,DisplayName,EmailAddress,Enabled | Export-Csv \\path\tosaveto\filename.csv -NoTypeInformation
If you want to find out what other properties you can add to the csv, run this command:
Get-ADUser -Filter * -Properties * | Get-Membership
2 Spice ups
Thanks for the reply. Will this work for Exchange Management Shell?
onecogmind
(onecogmind)
October 18, 2018, 9:48pm
4
Yes as long as you Import-Module ActiveDirectory
1 Spice up
jaycekakay
(jaycekakay)
October 19, 2018, 1:18am
5
foreach($users in Get-Mailbox -ResultSize Unlimited){$users | Foreach-Object {
$user = $_
$stats = Get-MailboxStatistics $user.Name
$Archive = Get-MailboxStatistics $user.Name -archive
New-Object -TypeName PSObject -Property @{
SamAccountName = $User.SamAccountName
DisplayName = $User.DisplayName
EmailAddress = $user.EmailAddresses
RetentionPolicy = $user.RetentionPolicy
Database = $user.database
ArchiveDB = $Archive.database
PrimarySize = $stats.TotalItemSize
ArchiveSize = $archive.TotalItemSize
PrimaryItems = $stats.ItemCount
ArchiveItems = $archive.ItemCount
}
}
}
1 Spice up
Thanks for the help. How do I export this script to csv?
jaycekakay
(jaycekakay)
October 22, 2018, 6:06am
7
$Data = @()
foreach($users in Get-Mailbox -ResultSize Unlimited){$users | Foreach-Object {
$user = $_
$stats = Get-MailboxStatistics $user.Name
$Archive = Get-MailboxStatistics $user.Name -archive
$data += New-Object -TypeName PSObject -Property @{
SamAccountName = $User.SamAccountName
DisplayName = $User.DisplayName
EmailAddress = $user.EmailAddresses
RetentionPolicy = $user.RetentionPolicy
Database = $user.database
ArchiveDB = $Archive.database
PrimarySize = $stats.TotalItemSize
ArchiveSize = $archive.TotalItemSize
PrimaryItems = $stats.ItemCount
ArchiveItems = $archive.ItemCount
}
}
}
$Data | Export-Csv c:\info2.csv -NoTypeInformation
1 Spice up