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.
This topic is 10 years and 1 week 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

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-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
jerrisheaton
Posts: 19
Last visit: Tue Mar 09, 2021 6:35 pm

Re: Pass form text in quotes to cmdlet

Post by jerrisheaton »

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?
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 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 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
This topic is 10 years and 1 week 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