Simple Form to grant access to exchange online mailbox

Ask questions about creating Graphical User Interfaces (GUI) in PowerShell and using WinForms controls.
Forum rules
Do not post any licensing information in this forum.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
This topic is 9 years and 10 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked
User avatar
island_guy
Posts: 14
Last visit: Thu Feb 02, 2017 6:12 am

Simple Form to grant access to exchange online mailbox

Post by island_guy »

Building a simple form to grant "Reviewer" access to another exchange online mailbox.

$buttonSetReaderAccess_Click={
#TODO: Place custom script here
$modaccount = $textbox1.Text
$grantaccess =$textbox2.Text

add-mailboxfolderpermission $modaccount:\Calendar -user $grantaccess -accessrights Reviewer

When I click the button it comes back with:

The specified mailbox "\Calendar" doesn't exist.
ERROR: + CategoryInfo : NotSpecified: (0:Int32) [Add-MailboxFolderPermission], ManagementObjectNotFoundException
ERROR: + FullyQualifiedErrorId : 7860A59C,Microsoft.Exchange.Management.StoreTasks.AddMailboxFolderPermission


The power shell cmdlet I am trying to submit is:

Add-Mailboxfolderpermission john.doe@acme.com:\Calendar -user jane.doe@acme.com -AccessRights Reviewer

Any help or direction would be wonderful.
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Simple Form to grant access to exchange online mailbox

Post by jvierra »

Try this:
PowerShell Code
Double-click the code block to select all.
$buttonSetReaderAccess_Click={
        $modaccount = '{0}:\Calendar' -f $textbox1.Text
        $grantaccess =$textbox2.Text
        add-mailboxfolderpermission $modaccount -user $grantaccess -accessrights Reviewer
       ''''
}
User avatar
island_guy
Posts: 14
Last visit: Thu Feb 02, 2017 6:12 am

Re: Simple Form to grant access to exchange online mailbox

Post by island_guy »

Thank you!

That did work, could you help me understand the -f switch?
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Simple Form to grant access to exchange online mailbox

Post by jvierra »

It calls the formatter for strings.

'hello {0 }world' -f 'cruel'

[string]::Format('Hello {0} World','so, so cruel')
This topic is 9 years and 10 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked