Simon Allaway
asked on
Powershell scripts that exports results to a CSV
Morning All experts
I need a scripts that can run against the entire exchange database that reports the full access rights of users which then exports to a csv file.
I also need the same for the send as permission. I have the scripts to run against a individual user but would really like to generate a report for the whole organisation.
Thanks everyone who looks at this question. I just hope its not to hard.
Regards
Simon
I need a scripts that can run against the entire exchange database that reports the full access rights of users which then exports to a csv file.
I also need the same for the send as permission. I have the scripts to run against a individual user but would really like to generate a report for the whole organisation.
Thanks everyone who looks at this question. I just hope its not to hard.
Regards
Simon
ASKER
So would it be something like this for send permission:
Get-Mailbox | Get-ADPermission | where {($_.ExtendedRights -like “*Send-As*”)} | FT –Wrap | Export-csv C:\permissions.csv
and this for full
Get-MailboxPermission –identity * | fl user, identity, accessrights| Export-csv C:\permissions.csv
??????
Thanks
Si
Get-Mailbox | Get-ADPermission | where {($_.ExtendedRights -like “*Send-As*”)} | FT –Wrap | Export-csv C:\permissions.csv
and this for full
Get-MailboxPermission –identity * | fl user, identity, accessrights| Export-csv C:\permissions.csv
??????
Thanks
Si
cybersi, you never apply a format-* cmdlet prior to exporting. The format-* cmdlets generate text, and there is no relation to the info they are applied to. Use them only for screen output.
If you want to filter the properties to export, use select-object instead, and for checking what will be in a CSV, pipe to convertto-csv:
Somehow we need to unroll the array, and decide what to display. Luckily, we don't need more than just the name of the privileges, and so:
The "Send As" part is similar. You should restrict to the properties necessary; it doesn't make sense to export the AD privileges (again, those are an array) and such.
If you want to filter the properties to export, use select-object instead, and for checking what will be in a CSV, pipe to convertto-csv:
Get-MailboxPermission * | select User, Identity, AccessRights | convertto-csv
and bang, we are lost. AccessRights is an array, and you will not see the values :(Somehow we need to unroll the array, and decide what to display. Luckily, we don't need more than just the name of the privileges, and so:
Get-MailboxPermission * | select User, Identity, @{n='AccessRights'; e={$_.AccessRights -join ","}} | convertto-csv
Replace ConvertTo-CSV with Export-CSV if you are satisfied.The "Send As" part is similar. You should restrict to the properties necessary; it doesn't make sense to export the AD privileges (again, those are an array) and such.
ASKER
Hi many thanks for the above. I will try the above when I get in the office. It just goes to show how powerful power shell is if u know what you are doing. I would be lying if I Said I understand the syntax but I guess hopefully the more I use it eventually things will just click. I know its kinda sad but I do enjoy learning things like this. Was the same with HTML.
ASKER
Morning Qlemo
Great it works only problem is it reports back that i need to use the "-ResultSize Unlimited" as only reports back the first 1000 entries.
with regard to the "send as" dor i just replace the 'access rights' with send as like this
Get-MailboxPermission * | select User, Identity, @{n='send as'; e={$_.sendd as -join ","}} | convertto-csv
?
Also it prompts for the path to the csv when usiing export-csv can I just add the path at the end of the string for example export-csv c:\output.csv
?
Thanks again
Simon
Great it works only problem is it reports back that i need to use the "-ResultSize Unlimited" as only reports back the first 1000 entries.
with regard to the "send as" dor i just replace the 'access rights' with send as like this
Get-MailboxPermission * | select User, Identity, @{n='send as'; e={$_.sendd as -join ","}} | convertto-csv
?
Also it prompts for the path to the csv when usiing export-csv can I just add the path at the end of the string for example export-csv c:\output.csv
?
Thanks again
Simon
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
http://blogs.msdn.com/b/deva/archive/2012/04/16/exchange-server-2007-2010-how-to-query-user-mailboxes-its-permissions-using-exchange-powershell.aspx