Hi all, I'm new to scripting and coding but I have something that is very simple but I am struggling to wrap my head around how to link it all together. I want to make a GUI for two Powershell scripts and depending on which radio button is selected a different script will run. This is the GUI This is the XAML code generated by Visual Studio 2015 <Window x:Name="Title" x:Class="WpfApplication1.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:local="clr-namespace:WpfApplication1" mc:Ignorable="d" Title="New Mailbox" Height="449.731" Width="420"> <Grid> <Image x:Name="image" HorizontalAlignment="Left" Height="100" Margin="14,10,0,0" VerticalAlignment="Top" Width="386" Source="C:\Users\Daniel Neocleous\Documents\Visual Studio 2015\Projects\WpfApplication1\WpfApplication1\Images\SibelcoLogo.png"/> <RadioButton x:Name="step1" Content="Step 1" HorizontalAlignment="Left" Margin="150,125,0,0" VerticalAlignment="Top"/> <RadioButton x:Name="step2" Content="Step 2" HorizontalAlignment="Left" Margin="217,125,0,0" VerticalAlignment="Top"/> <Button x:Name="button" Content="Create Mailbox" HorizontalAlignment="Left" Margin="150,201,0,0" VerticalAlignment="Top" Width="119" Height="35"/> <GroupBox x:Name="groupBox" Header="Output" HorizontalAlignment="Left" Height="169" Margin="10,243,0,0" VerticalAlignment="Top" Width="394"> <TextBox x:Name="Outpu" HorizontalAlignment="Left" Height="147" Margin="0,0,-1.143,-0.714" TextWrapping="Wrap" VerticalAlignment="Top" Width="384"/> </GroupBox> <Label x:Name="label" Content="Email address" HorizontalAlignment="Left" Margin="73,153,0,0" VerticalAlignment="Top" Height="26"/> <TextBlock x:Name="textBlock" HorizontalAlignment="Left" Margin="156,163,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Height="16"/> <TextBox x:Name="emailentry" HorizontalAlignment="Left" Height="23" Margin="161,157,0,0" TextWrapping="Wrap" Text="Users email address" VerticalAlignment="Top" Width="191"/> </Grid> </Window> This is the 'Step 1' PS script $credentials = get-credential $Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri http://URL -Credential $credentials –AllowRedirection Import-PSSession $Session set-ADServerSettings -ViewEntireForest $true Enable-RemoteMailbox -Identity test@test.com -RemoteRoutingAddress test@test.com.onmicrosoft.com Enable-RemoteMailbox -Identity test@test.com -Archive Step 2 PS script $msolcred = get-credential connect-msolservice -credential $msolcred Set-MsolUser -UserPrincipalName test@test.com -UsageLocation GB $LicOpt = New-MsolLicenseOptions -AccountSkuId company:STANDARDPACK -DisabledPlans MCOSTANDARD Set-MsolUserLicense -UserPrincipalName test@test.com -AddLicenses company:STANDARDPACK -LicenseOptions $LicOpt Remove-PSSession $Session From the text entry box I need to pass the email string to the PS script as this is the only variable in the script but I don't know how to do this. Thanks for the help guys.
I personally wouldn't look at gui frontends to scripts until you understand how powershell works a bit more. Now to pass the parameter you want to look up param it's how powershell tells you to pass arguments and should be what you need
Don't bother messing with trying to add a GUI to a PowerShell script, just add a simple menu instead: https://gallery.technet.microsoft.com/scriptcenter/Create-colorful-PowerShell-8689c5b2