Skip to content
Tech Shizz Logo

An Engineers Blog

  • TechShizz
  • blog

Office 365 | Add / Remove / Check Calendar Permissions

Posted on February 23, 2021 By rich No Comments on Office 365 | Add / Remove / Check Calendar Permissions

 This script is designed to be used with the script password encryption for Office 365. See here https://www.techshizz.com/post/powershell-script-password-ecryption-for-multi-site-administration for more info. 

Import-Module MSOnline
$rootpath = (get-item '.' ).parent.FullName
$clientname = Get-Content "$rootpathclient.txt" -Raw
$user = Get-Content "$rootpathUserID.txt"
$PasswordFile = "$rootpathPassword.txt"
$KeyFile = "C:ICUAES.key"
$key = Get-Content $KeyFile
$UserCredential = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $User, (Get-Content $PasswordFile | ConvertTo-SecureString -Key $key)
$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell-liveid/ -Credential $UserCredential -Authentication Basic -AllowRedirection
Write-Host "Connecting to Exchange Online for $clientname"
Import-PSSession $Session
function Menu{
[email protected]"
1 Add Calendar Permissions
2 Remove Calendar Permissions
3 Check Calendar Permissions
S Search for an email address
Q Quit
Select a task by number or Q to quit
"@
Write-Host "Calendar Permissions" -ForegroundColor Cyan
$r = Read-Host $menu
Switch ($r) {
"1" {
        $emailaddress = Read-Host "Enter the email of the mailbox to provide Calendar access to"
        $accesslevel = Read-Host "Type the level of access you want to add:
        Author
        Contributor
        Editor
        None
        NonEditingAuthor
        Owner
        PublishingEditor
        PublishingAuthor
        Reviewer
        AvailabilityOnly
        LimitedDetails"
        $deligate = Read-Host "Enter the email address of the deligate"
        Add-MailboxFolderPermission –Identity $emailaddress":Calendar" –User $deligate –AccessRights $accesslevel
        Write-Host "Adding Mailbox Calendar Permissions..."
        Menu
}
"2" {
    $emailaddress = Read-Host "Enter the email of the mailbox who currently has access that you want to remove"
    $deligate = Read-Host "Enter the email address of the mailbox to which the user has access to"
    Write-Host "Removing Mailbox Calendar Access..."
    Remove-MailboxFolderPermission –Identity $emailaddress":Calendar" –User $deligate
    Menu
}
"3" {
    $emailaddress = Read-Host "Enter the email address that you want to check permissions for"
    Write-Host "Loading..."
    Get-MailboxFolderPermission -Identity $emailaddress":Calendar" | Format-Table
    Menu
    }
"S" {
    $search = Read-Host "Enter Name to Search"
    Write-Host "Searching..."
    Get-Mailbox | Where-Object { $_.Name -Like "*$search*" } | Select-Object DisplayName,PrimarySmtpAddress | Format-Table
    Menu
}
"Q" {
    Write-Host "Removing any PS Sessions..." -ForegroundColor Green
    Get-PSSession | Remove-PSSession
    Exit
}
default {
    Write-Host "Choose a valid option... Fool!" -ForegroundColor Yellow
}
} #end switch 
}
Menu
Share

Post navigation

❮ Previous Post: Using PowerShell to Add Drivers / Packages / Install Roles and Features in a .wim file
Next Post: Windows Store is missing in Windows 10 ❯

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Generic selectors
Exact matches only
Search in title
Search in content
Post Type Selectors

Subscribe to our newsletter!

Recent Posts

  • How to implement a lightning-fast ransomware playbook
  • How to achieve defence in depth in your business
  • How to implement a SecOps team phishing response plan
  • How to block an Office 365 Sign-in correctly
  • Microsoft finally patched serious Exchange 0-day over a month old!

Recent Comments

    Archives

    • November 2022
    • July 2021
    • March 2021
    • February 2021

    Categories

    • Cyber Security
    • Uncategorized

    Meta

    • Log in
    • Entries feed
    • Comments feed
    • WordPress.org

    Copyright © 2023 .

    Theme: Oceanly News Dark by ScriptsTown