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

Pass form text in quotes to cmdlet

Post by island_guy » Tue Mar 18, 2014 6:48 pm

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

In powershell:

Get-MailboxPermission -Identity user-name@domain.com -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.


$GetAccess_Click={
#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
jerris
Posts: 19
Joined: Tue Jul 24, 2012 7:46 am
Contact:

Re: Pass form text in quotes to cmdlet

Post by jerris » Wed Mar 19, 2014 10:55 am

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?

User avatar
jvierra
Posts: 13600
Joined: Tue May 22, 2007 9:57 am
Contact:

Re: Pass form text in quotes to cmdlet

Post by jvierra » Wed Mar 19, 2014 4:36 pm

Quotes are unnecessary.

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

Get-MailboxPermission -Identity user-name@domain.com
Get-MailboxPermission -Identity user-name
Get-MailboxPermission user-name@domain.com
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 |
Out-String

Locked