Sign up for Office 365
Learn more about Office 365
Hi,
I'm using the commands below to see the calendar folder permissions of all users of my organization.
foreach($user in Get-Mailbox -RecipientTypeDetails UserMailBox) {
$cal = $user.alias
Get-MailboxFolderPermission -Identity $cal":\Calendário"
}
PS: The folder's name really is "Calendário". Brazil here.
It works but, I need two more things:
1 - I don't want to get the information on the screen. I want to export to a CSV file. Adding the "Export-CSV C:\File.csv" at the end of the commands don't work.
2- I need to know which user owns that calendars.
This is one example of the output I get:
RunspaceId : 818527fd-fa32-4d6f-b7a6-ae7ac6e32152 FolderName : Calendário User : Padrão AccessRights : {AvailabilityOnly} Identity : Padrão IsValid : True RunspaceId : 818527fd-fa32-4d6f-b7a6-ae7ac6e32152 FolderName : Calendário User : Anônimo AccessRights : {None} Identity : Anônimo IsValid : True RunspaceId : 818527fd-fa32-4d6f-b7a6-ae7ac6e32152 FolderName : Calendário User : Padrão AccessRights : {AvailabilityOnly} Identity : Padrão IsValid : True RunspaceId : 818527fd-fa32-4d6f-b7a6-ae7ac6e32152 FolderName : Calendário User : Anônimo AccessRights : {None} Identity : Anônimo IsValid : True RunspaceId : 818527fd-fa32-4d6f-b7a6-ae7ac6e32152 FolderName : Calendário User : Padrão AccessRights : {AvailabilityOnly} Identity : Padrão IsValid : True RunspaceId : 818527fd-fa32-4d6f-b7a6-ae7ac6e32152 FolderName : Calendário User : Anônimo AccessRights : {None} Identity : Anônimo IsValid : True RunspaceId : 818527fd-fa32-4d6f-b7a6-ae7ac6e32152 FolderName : Calendário User : Padrão AccessRights : {AvailabilityOnly} Identity : Padrão IsValid : True
I need this info to apply audit only to accounts that shares calendars.
PS: If anyone knows how to put that commands in only one command line, please tell me.
Thanks in advance.
Hi Vandrey, I understand that you want to export calendar information to a csv file via PowerShell.
Please try your cmdlet by adding -notype. For example: Export-CSV -Path ".\cloud.csv" –notype
Thanks, Bourne Zhang
0 out of 1 people found this post helpful.
Hi Bourne,
I know how to export using that command.
But that command doesn't work if I put it in the end of the script, after the "}".
Hello Vandrey,
Thanks for your post in the forum.
Looking at Bourne's post and the command, Please try running the PowerShell as below and report back.
Foreach($user in Get-Mailbox -RecipientTypeDetails UserMailBox) {
Best regards
Samuel
Hi Samuel,
I tried to run the command just like you told me:
----------------------------------------------------------------------------------------------------------------
PS C:\Windows\system32> foreach($user in Get-Mailbox -RecipientTypeDetails UserMailBox) {
>> $cal = $user.alias
>> Get-MailboxFolderPermission -Identity $cal":\Calendário"
>> Export-Csv -Path "c:\teste.csv" -notype
>> }
>>
And the output is this:
RunspaceId : e49ce3ac-de06-46f6-b711-69040176391a
FolderName : Calendário
User : Padrão
AccessRights : {AvailabilityOnly}
Identity : Padrão
IsValid : True
User : Anônimo
AccessRights : {None}
Identity : Anônimo
cmdlet Export-Csv na posição de comando 1 do pipeline
Forneça valores para os seguintes parâmetros:
InputObject:
The content of the csv file is this:
#TYPE System.String
"Length"
"0"
Any idea?
Thanks for the quick response. I have another suggestion please see below
Foreach($user in Get-Mailbox -RecipientTypeDetails UserMailBox) { $cal = $user.alias Get-MailboxFolderPermission -Identity $cal":\Calendário" |ft|out-file c:\teste.csv -append } Best regards
1 out of 1 people found this post helpful.
Samuel,
Thanks for the info.
But once again there is some problems.
This is on part of the output of that command:
_____________________________________________________________________
RunspaceId FolderName User AccessRights Identity IsValid
---------- ---------- ---- ------------ -------- -------
1da743a1-6... Calendário Padrão {Availabi... Padrão True
1da743a1-6... Calendário Anônimo {None} Anônimo True
Two problems in there:
1) I still don't know the name or user of the owner of the calendar
2) In this table format some info get lost. What aboy if I have four Maria's in my organization? I will not have their complete names to difference on of the others.
Hello Vandrey.
We are using the user.alias field the other option is to use the SMTP address and see if the report gives us the email address of the user.
Please try this variation
Foreach($user in Get-Mailbox -RecipientTypeDetails UserMailBox) { $cal = $user.smtp Get-MailboxFolderPermission -Identity $cal":\Calendário" |ft|out-file c:\teste.csv -append } Best regards
Now I got only this:
e2685fba-8... Calendário Padrão {None} Padrão True
Thank you for your post in the forum. I suggest you to try this:
Get-mailbox | Get-MailboxPermission | select-object FolderName,User,AccessRights,Identity, IsInherited,IsValid | export-csv -Path c:\teste.csv
Or
Get-MailboxFolderPermission -Identity xxxx | export-csv -Path c:\teste.csv
Should you have any further questions about how to do this, please feel free to let us know? We are here to help.
Best regards,Roger MSF
Hey Roger,
Not this time...
The result was a big csv with some info like this:
____________________________________________________________________________________________________
#TYPE Selected.System.Management.Automation.PSCustomObject
FolderName User AccessRights Identity IsInherited IsValid
NT AUTHORITY\SELF FullAccess, ExternalAccount, ReadPermission 01 Videoconferencia False True
LAMPRD80\Domain Admins FullAccess 01 Videoconferencia True True
That first command don't show me the folders name. And don't have nothing about the calendar folder in it.
The second one only works if I type the folder name (Ex.: user:\Calendar) and only works to one user at a time.
Thx anyway for trying.
Any1?
Thanks for your patience on this issue.
I have located and tested a script and I include it below. It will create a csv file that list each calendar owner and the permission. You can edit the csv file and use it to change the existing permissions buy importing the csv file after saving the changes.
$rptCollection = @() $mailboxes = get-mailbox -ResultSize Unlimited $mailboxes | foreach-object{ $alias = $_.alias + ":\Calendar" $displayName = $_.DisplayName write-host $alias $permissions = Get-MailboxFolderPermission $alias | Where-Object {$_.Identity.ToString() -eq "Default"} if($permissions -ne $null){ $stringPerms = "" foreach($perms in $permissions.AccessRights){$stringPerms = $stringPerms + $perms + " "} Add-Member -InputObject $permissions -MemberType NoteProperty -Name "Alias" -Value $alias -Force Add-Member -InputObject $permissions -MemberType NoteProperty -Name "StringAccessRights" -Value $stringPerms -Force $rptCollection += $permissions } } $rptCollection | export-csv -notypeInformation c:\teste.csv Once you have this, simply edit the CSV and update the Access Rights field with the rights you would like to give each user. Once completed, hit save. Now you are ready to import. Use the script below to re-import the CSV and update the permissions.
import-csv c:\teste.csv | foreach-object{ "Seting Rights on " + $_.alias Set-MailboxFolderPermission -id $_.alias -User $_.Identity -AccessRights $_.StringAccessRights }
Please let me know if this was helpful
Best regards,
Hey Samuel,
No problem. I thank you for the patience!
But was not this time...
I've tried the commands like you gave to me:
______________________________________________________________________________________________________________________
PS C:\Windows\system32> $rptCollection = @()
PS C:\Windows\system32> $mailboxes | ForEach-Object{
>> $alias = $_.alias + ":\Calendar"
>> $displayName = $_.DisplayName
>> write-host $alias
>> $permissions = Get-MailboxFolderPermission $alias | Where-Object {$._Identity.ToString() -eq "Default"}
>> if($permissions -ne $null){
>> $stringPerms = ""
>> foreach($perms in $permissions.AccessRights){$stringPerms = $stringPerms + $perms + " "}
>> Add-Member -InputObject $permissions -MemberType NoteProperty -Name "Alias" -Value $alias -Force
>> Add-Member -InputObject $permissions -MemberType NoteProperty -Name "StringAc
cessRights" -Value $stringPerms -Force
>> $rptCollection += $permissions
>> $rptCollection | Export-Csv -NoTypeInformation C:\Teste.csv
An expression was expected after '('
Line: 5 character: 88
+ $permissions = Get-MailboxFolderPermission $alias | Where-Object {$._Identity
.ToString( <<<< ) -eq "Default"}
+ CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordEx
ception
+ FullyQualifiedErrorId : ExpectedExpression
PS C:\Windows\system32>
I did something wrong?
Hello Vandrey,thanks for the feedback. I looked at your listing of what you did and I need to very thjat you copied and pasted the entire routine at the same time.In other words you dont run the script line by line but copy it all and paste in powershell eg:
--------Start below this line--------------$rptCollection = @() $mailboxes = get-mailbox -ResultSize Unlimited $mailboxes | foreach-object{ $alias = $_.alias + ":\Calendar" $displayName = $_.DisplayName write-host $alias $permissions = Get-MailboxFolderPermission $alias | Where-Object {$_.Identity.ToString() -eq "Default"} if($permissions -ne $null){ $stringPerms = "" foreach($perms in $permissions.AccessRights){$stringPerms = $stringPerms + $perms + " "} Add-Member -InputObject $permissions -MemberType NoteProperty -Name "Alias" -Value $alias -Force Add-Member -InputObject $permissions -MemberType NoteProperty -Name "StringAccessRights" -Value $stringPerms -Force $rptCollection += $permissions } } $rptCollection | export-csv -notypeInformation c:\teste.csv
----------------Copy everything in between and paste on PowerShell command line then hit enter twice-----------------
Please try this again and let me know what happens.
Sorry for that...
I like to use the commands line by line to see what it does. Didn't know that it was the problem.
But let's go.
Copied the script below to a .ps1 file:
___________________________________________________________________________________________________
$rptCollection = @()
$mailboxes = get-mailbox -ResultSize Unlimited
$mailboxes | foreach-object{
$alias = $_.alias + ":\Calendário"
$displayName = $_.DisplayName
write-host $alias
$permissions = Get-MailboxFolderPermission $alias | Where-Object {$_.Identity.ToString() -eq "Default"}
if($permissions -ne $null){
$stringPerms = ""
foreach($perms in $permissions.AccessRights){$stringPerms = $stringPerms + $perms + " "}
Add-Member -InputObject $permissions -MemberType NoteProperty -Name "Alias" -Value $alias -Force
Add-Member -InputObject $permissions -MemberType NoteProperty -Name "StringAccessRights" -Value $stringPerms -Force
$rptCollection += $permissions
$rptCollection | export-csv -notypeInformation c:\teste.csv
As you can see, the only change I've made is the word "calendar" for "calendário".
When I run the script it start showing to me all mailboxes that have the folder "Calendário" on it.
Like this:
user1.surname:\Calendário
user2.surname:\Calendário
user3.surname:\Calendário
user4.surname:\Calendário
user5.surname:\Calendário
user6.surname:\Calendário
user7.surname:\Calendário
Não foi possível executar a operação porque 'user8.surname:\Calendário' não foi en
contrado.
+ CategoryInfo : NotSpecified: (:) [Get-MailboxFolderPermission],
ManagementObjectNotFoundException
+ FullyQualifiedErrorId : 56C8E538,Microsoft.Exchange.Management.StoreTask
s.GetMailboxFolderPermission
user9.surname:\Calendário
user10.surname:\Calendário
user11.surname:\Calendário
At the end of the list (big list, copied only one part of it), it returned to the PS command prompt without showing any error message and the C:\teste.csv file was created but have 0 kb.