Share via

About Powershell script

Anonymous
2024-06-03T06:03:16.15+00:00

I want to create a Powershell script and my requirenment are as follows
I have some user having same company name attribute and users that dont have company name attribute

The user having same attribute can able to see eachother calender with detail information but I dont want them to view other users information whose company attribute dont matches with each other
And those who dont have company name attribute they cannot able to view anyone calender through outlook

I tried to search but could not found any Idea about the script so anyone could help me to create the script with above requirement

Windows for business | Windows Server | User experience | PowerShell
Microsoft Security | Microsoft Entra | Microsoft Entra ID
0 comments No comments

1 answer

Sort by: Most helpful
  1. Vasil Michev 127K Reputation points MVP Volunteer Moderator
    2024-06-03T16:14:11.1+00:00

    By default, all users within the same tenant can view each other's availability info. If you want to restrict that, the first thing you need to do is adjust the permission level for the Default principal on every mailbox. Something like this:

    $calendars = Get-Mailbox -RecipientTypeDetails UserMailbox | Get-MailboxFolderStatistics -FolderScope Calendar | ? {$_.FolderType -eq "Calendar"} | select @{n="Identity"; e={$_.Identity.ToString().Replace("\",":\")}}
    
    $calendars | % {Set-MailboxFolderPermission -Identity $_.Identity -User Default -AccessRights None}
    

    Then, you need to address the other requirement, based on the value of the Company attribute. The easiest way would be to create a group for each such value, and add the relevant users therein. I.e. all users with CompanyX will be added to group "CompanyX" and so on. Once this is done, you can add the relevant calendar permissions:

    $calendars = Get-DistributionGroupMember CompanyX | Get-MailboxFolderStatistics -FolderScope Calendar | ? {$_.FolderType -eq "Calendar"} | select @{n="Identity"; e={$_.Identity.ToString().Replace("\",":\")}}
    
    $calendars | % {Add-MailboxFolderPermission -Identity $_.Identity -User CompanyX -AccessRights LimitedDetails }
    

    Rinse and repeat for all other companies.

    Was this answer helpful?

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.