Created
December 31, 2018 22:03
-
-
Save NathanTheGr8/da68f3e7b7645100e5da844ab347d0e3 to your computer and use it in GitHub Desktop.
Example Powershell WPF Form
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Load Assembly and Library | |
Add-Type -AssemblyName PresentationFramework | |
#XAML form designed using Vistual Studio | |
#[xml]$Form = Get-Content -Path "$PSScriptRoot\USMTGUI.xaml" | |
[xml]$Form = @" | |
<Window | |
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | |
Title="Migration Assistant by Nick Rodriguez" Height="550" Width="1000" MinWidth="1000" MinHeight="550"> | |
<Grid> | |
<TabControl HorizontalAlignment="Left" Margin="10,10,0,10" Width="480"> | |
<TabItem Header="Old Computer"> | |
<Grid Background="#FFE5E5E5"> | |
<GroupBox Header="Computer Info" HorizontalAlignment="Left" Height="110" Margin="10,0,0,0" VerticalAlignment="Top" Width="454" BorderBrush="Black"> | |
<Grid> | |
<Label Content="Old Computer" HorizontalAlignment="Left" Margin="10,24,0,0" VerticalAlignment="Top"/> | |
<Label Content="New Computer" HorizontalAlignment="Left" Margin="10,50,0,0" VerticalAlignment="Top"/> | |
<Label Content="Computer Name" HorizontalAlignment="Left" Margin="100,0,0,0" VerticalAlignment="Top"/> | |
<Label Content="IP Address" HorizontalAlignment="Left" Margin="225,0,0,0" VerticalAlignment="Top"/> | |
<TextBox HorizontalAlignment="Left" Height="23" Margin="100,26,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="120" Text="ANEXAMPLENAME"/> | |
<TextBox HorizontalAlignment="Left" Height="23" Margin="100,55,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="120"/> | |
<TextBox HorizontalAlignment="Left" Height="23" Margin="225,26,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="98" Text="192.168.234.244"/> | |
<TextBox HorizontalAlignment="Left" Height="23" Margin="225,55,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="98"/> | |
<Button Content="Test Connection" HorizontalAlignment="Left" Margin="328,26,0,0" VerticalAlignment="Top" Width="104" Height="23"/> | |
<CheckBox Content="Connected" HorizontalAlignment="Left" Margin="328,55,0,0" VerticalAlignment="Top" Width="104" Height="21"/> | |
</Grid> | |
</GroupBox> | |
<GroupBox Header="Data to Include" HorizontalAlignment="Left" Height="162" Margin="10,115,0,0" VerticalAlignment="Top" Width="218" BorderBrush="Black"> | |
<Grid> | |
<CheckBox Content="AppData" HorizontalAlignment="Left" VerticalAlignment="Top" Width="104" Height="21" Margin="10,10,0,0"/> | |
<CheckBox Content="Local AppData" HorizontalAlignment="Left" VerticalAlignment="Top" Width="104" Height="21" Margin="10,31,0,0"/> | |
<CheckBox Content="Printers" HorizontalAlignment="Left" VerticalAlignment="Top" Width="104" Height="21" Margin="10,52,0,0"/> | |
<CheckBox Content="Recycle Bin" HorizontalAlignment="Left" VerticalAlignment="Top" Width="104" Height="21" Margin="10,73,0,0"/> | |
<CheckBox Content="My Documents" HorizontalAlignment="Left" VerticalAlignment="Top" Width="104" Height="21" Margin="10,94,0,0"/> | |
<CheckBox Content="Wallpapers" HorizontalAlignment="Left" VerticalAlignment="Top" Width="104" Height="21" Margin="10,115,0,0"/> | |
<CheckBox Content="Downloads" HorizontalAlignment="Left" VerticalAlignment="Top" Width="92" Height="21" Margin="114,10,0,0"/> | |
<CheckBox Content="Favorites" HorizontalAlignment="Left" VerticalAlignment="Top" Width="92" Height="21" Margin="114,31,0,0"/> | |
<CheckBox Content="My Music" HorizontalAlignment="Left" VerticalAlignment="Top" Width="92" Height="21" Margin="114,52,0,0"/> | |
<CheckBox Content="My Pictures" HorizontalAlignment="Left" VerticalAlignment="Top" Width="92" Height="21" Margin="114,73,0,0"/> | |
<CheckBox Content="My video" HorizontalAlignment="Left" VerticalAlignment="Top" Width="92" Height="21" Margin="114,94,0,0"/> | |
<CheckBox Content="Desktop" HorizontalAlignment="Left" VerticalAlignment="Top" Width="92" Height="21" Margin="114,115,0,0"/> | |
</Grid> | |
</GroupBox> | |
<GroupBox Header="Save State Destination" HorizontalAlignment="Left" Height="100" Margin="246,115,0,0" VerticalAlignment="Top" Width="218" BorderBrush="Black"> | |
<Grid> | |
<CheckBox Content="Save On New Computer" HorizontalAlignment="Center" VerticalAlignment="Top" Width="186" Height="21" Margin="10,32,0,0"/> | |
<TextBox HorizontalAlignment="Left" Height="23" Margin="10,4,0,0" TextWrapping="Wrap" Text="c:\Temp\MigrationStore" VerticalAlignment="Top" Width="186"/> | |
<Button Content="Change" HorizontalAlignment="Left" Margin="15,53,0,0" VerticalAlignment="Top" Width="75"/> | |
<Button Content="Reset" HorizontalAlignment="Left" Margin="121,53,0,0" VerticalAlignment="Top" Width="75"/> | |
</Grid> | |
</GroupBox> | |
<GroupBox Header="Profile Selection" HorizontalAlignment="Left" Height="105" Margin="246,220,0,0" VerticalAlignment="Top" Width="218" BorderBrush="Black"> | |
<Grid> | |
<Button Content="Button" HorizontalAlignment="Left" Margin="10,9,0,0" VerticalAlignment="Top" Width="186"/> | |
<CheckBox Content="Migrate all profiles logged into
within this amount of days:" HorizontalAlignment="Left" VerticalAlignment="Top" Width="186" Height="35" Margin="10,34,0,0"/> | |
<TextBox HorizontalAlignment="Left" Height="23" Margin="177,46,0,0" TextWrapping="Wrap" Text="90" VerticalAlignment="Top" Width="19"/> | |
</Grid> | |
</GroupBox> | |
<GroupBox Header="Extra Directories to Include" HorizontalAlignment="Left" Margin="10,282,0,10" Width="218" BorderBrush="Black"> | |
<Grid> | |
<DataGrid HorizontalAlignment="Left" Width="206"/> | |
<Button Content="-" HorizontalAlignment="Center" Margin="0,132,180,0" Width="26" FontSize="16"/> | |
<Button Content="+" HorizontalAlignment="Center" Margin="26,132,156,0" Width="24" FontSize="16"/> | |
</Grid> | |
</GroupBox> | |
<Button Content="Custom XML(s)" HorizontalAlignment="Left" Margin="246,330,0,0" VerticalAlignment="Top" Width="218"/> | |
<CheckBox Content="CheckBox" HorizontalAlignment="Center" Margin="246,355,0,0" VerticalAlignment="Top" Width="218"/> | |
<CheckBox Content="CheckBox" HorizontalAlignment="Center" Margin="246,375,0,0" VerticalAlignment="Top" Width="218"/> | |
<Button Content="Migrate" HorizontalAlignment="Left" Margin="246,395,0,10" Width="218" FontWeight="Bold" FontSize="18"/> | |
</Grid> | |
</TabItem> | |
<TabItem Header="New Computer"> | |
<Grid Background="#FFE5E5E5"/> | |
</TabItem> | |
<TabItem Header="Email Settings"> | |
<Grid Background="#FFE5E5E5"/> | |
</TabItem> | |
<TabItem Header="Scripts"> | |
<Grid Background="#FFE5E5E5"/> | |
</TabItem> | |
</TabControl> | |
<RichTextBox Margin="495,33,10,10" FontFamily="Consolas" Background="Black" Foreground="White"> | |
<FlowDocument> | |
<Paragraph> | |
<Run Text="RichTextBox"/> | |
</Paragraph> | |
</FlowDocument> | |
</RichTextBox> | |
</Grid> | |
</Window> | |
"@ | |
#Create a form | |
$XMLReader = (New-Object System.Xml.XmlNodeReader $Form) | |
$XMLForm = [Windows.Markup.XamlReader]::Load($XMLReader) | |
#Show XMLform | |
$XMLForm.ShowDialog() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment