[Solved]Unwanted Text in Output

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 6 years and 7 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
cmarble
Posts: 2
Last visit: Wed Sep 26, 2018 12:42 pm

[Solved]Unwanted Text in Output

Post by cmarble »

Hi everyone,

So I'm new to GUI and I'm trying to convert my working powershell script that's entirely text based to a more userfriendly GUI interface for my colleagues who hate navigating by text.+

In an attempt to push out output of my script, I keep getting:
Microsoft.Exchange.Management.StoreTasks.MailboxFolderPermission Microsoft.Exchange.Management.StoreTasks.MailboxFolderPermission Microsoft.Exchange.Management.StoreTasks.MailboxFolderPermission

It seems anything "local" gets added to the textbox just fine, but anything from the office365 tenant gets spit back and unusuable things.

I also have it call up a grid-view as a work around for the interim because I'm sure I can get all the scripts to work as intended, but the titlebar says "System.Windows.Forms.Textbox, Text: <myemail address>" when the desired title is "Calendar Permissions for <my email address>"

It's pulling my email address from a textbox. My code is as follows:

Code: Select all

function check_calendar
{
	$name = $CalendarEmail.Text
	$cal = Get-MailboxFolderPermission -identity "${$name}:\calendar" | Select-Object User, AccessRights | Out-GridView -Title "Calendar Permissions for $CalendarEmail"
	$output.Text = 'Grabbing calendars. A window will pop up once this is finished.'
	
	#Added to see if it works (yet)
	$output.Text = Get-MailboxFolderPermission -identity "${$name}:\calendar" 

	$cal
}

$buttonCheckPermissions_Click = {
	check_calendar
	
}
Any help or a step in the right direction would be greatly appreciated.
Last edited by cmarble on Mon Aug 14, 2017 5:23 pm, edited 1 time in total.
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Unwanted Text in Output

Post by jvierra »

Try it this way:

Code: Select all

function check_calendar {
	$name = $CalendarEmail.Text
	Get-MailboxFolderPermission -identity "$name`:\calendar" | 
		Select-Object User, AccessRights | 
		Out-GridView -Title "Calendar Permissions for $name"
	$output.Text = 'Grabbing calendars. A window will pop up once this is finished.'
	
	#Added to see if it works (yet)
	$output.Text = Get-MailboxFolderPermission -identity "$name`:\calendar" | Out-String
}

jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Unwanted Text in Output

Post by jvierra »

This way might be easier to understand:

Code: Select all

function check_calendar {
	$folder = '{0}:\calendar' -f $CalendarEmail.Text
	Get-MailboxFolderPermission -identity $folder | 
		Select-Object User, AccessRights |
	        Out-GridView -Title "Calendar Permissions for $folder"
	$output.Text = 'Grabbing calendars. A window will pop up once this is finished.'
	
	#Added to see if it works (yet)
	$output.Text = Get-MailboxFolderPermission -identity $folder | Out-String
}
User avatar
Alexander Riedel
Posts: 8478
Last visit: Tue Mar 26, 2024 8:52 am
Answers: 19
Been upvoted: 37 times

Re: Unwanted Text in Output

Post by Alexander Riedel »

Put this in your script near the top:

$progressPreference = 'silentlyContinue'
Alexander Riedel
SAPIEN Technologies, Inc.
User avatar
cmarble
Posts: 2
Last visit: Wed Sep 26, 2018 12:42 pm

Re: Unwanted Text in Output

Post by cmarble »

Alright, now we're cooking with fire. Thanks for the input and tips. Only one issue and that it doesn't care what's in the proper field, it's pasting my calendar over and over again. Maybe misnaming the field somewhere. Great start though, thank you. THis is what I was looking for.
This topic is 6 years and 7 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