Pass form text in quotes to cmdlet

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.
User avatar
Posts: 14
Joined: Wed Aug 14, 2013 11:07 am

Pass form text in quotes to cmdlet

Post by island_guy »

I might be looking at this wrong but here is what I want to do.

In powershell:

Get-MailboxPermission -Identity -User "domain\first middel last"
| Format-Wide -Property "AccessRights" -Column 2 | Out-String

It request me to pass the user name in quotes "domain\first middle last"

I built a very simply hello world form that request the account and a user name to check access for. Then output that to a text box on the form. It seems I having problems with the user name needing to be in quotes.

#TODO: Place custom script here

$textboxresults = Get-MailboxPermission -Identity $EmailAccount.Text -User $adaccount.text | Format-Wide -Property "AccessRights" -Column 2 | Out-String


Thanks for the help.

User avatar
Posts: 19
Joined: Tue Jul 24, 2012 7:46 am

Re: Pass form text in quotes to cmdlet

Post by jerris »

I'm not understanding what exactly you're trying to do. Are you basically prompting for an email account and then returning the permissions (like who has full mailbox access) to that email account?

Posts: 14677
Joined: Tue May 22, 2007 9:57 am
Answers: 6
Has voted: 1 time
Been upvoted: 5 times

Re: Pass form text in quotes to cmdlet

Post by jvierra »

Quotes are unnecessary.

You are being asked for either an identity. The email address is one form of identity.

Get-MailboxPermission -Identity
Get-MailboxPermission -Identity user-name
Get-MailboxPermission user-name

Look up the definition of Identity.

-User is the user for whom you want permissions checked on that mailbox.

You will get back a collection of objects.

Get-MailboxPermission mailbox -User user_to_check |
Select Access |
Format-List |