Skip to content

Instantly share code, notes, and snippets.

@Pepeterson

Pepeterson/Error@Foxtrot Secret

Last active Aug 29, 2016
Embed
What would you like to do?
#ERASE ALL THIS AND PUT XAML BELOW between the @" "@
$inputXML = @"
<Window x:Name="DCSC_Toolkit" x:Class="DCSC_Toolkit.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:DCSC_Toolkit"
mc:Ignorable="d"
Title="DCSC Toolkit" Height="350" Width="525">
<Grid Margin="0,0,45,0">
<TabControl x:Name="tabControl" Margin="10">
<TabItem x:Name="AD_PC_SCAN" Header="AD-PC Scan">
<Grid Background="#FFE5E5E5">
<TextBlock x:Name="textBlock" HorizontalAlignment="Left" Margin="108.892,93.38,0,0" TextWrapping="Wrap" Text="Facility :" VerticalAlignment="Top" Height="17.899" Width="46.582"/>
<Button x:Name="BEGIN_PC_SCAN" Content="SCAN" HorizontalAlignment="Right" VerticalAlignment="Bottom" Width="75" Margin="0,0,10,10"/>
<TextBlock x:Name="textBlock1" HorizontalAlignment="Left" Margin="108.892,123.673,0,128.407" TextWrapping="Wrap" Text="Output Location :" d:LayoutOverrides="Height"/>
<TextBox x:Name="PC_SITE" Height="23" Margin="0,88.279,108.23,0" TextWrapping="Wrap" VerticalAlignment="Top" HorizontalAlignment="Right" Width="120"/>
<TextBox x:Name="PC_OUTPUT" Margin="0,116.633,108.23,128.407" TextWrapping="Wrap" HorizontalAlignment="Right" Width="120"/>
<TextBlock x:Name="PC_SCAN_INFO" HorizontalAlignment="Left" Margin="108.892,10,0,0" TextWrapping="Wrap" Text="This tool is for scanning the AD list of computers in a logistics facility. It will create a spreadsheet with listed details of the PCs that are connected. You can modify the site you would like to scan or the output file location." VerticalAlignment="Top" Height="73.279" Width="368.108"/>
<Image x:Name="Home_Depot_Copy" HorizontalAlignment="Left" Height="82.968" Margin="6.219,0.707,0,0" VerticalAlignment="Top" Width="87.407" Source="Home Depot1.png"/>
</Grid>
</TabItem>
<TabItem x:Name="AD_USER_SCAN" Header="AD-User Scan">
<Grid Background="#FFE5E5E5">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="208*"/>
<ColumnDefinition Width="279*"/>
</Grid.ColumnDefinitions>
<TextBlock x:Name="textBlock_Copy" HorizontalAlignment="Left" Margin="109,93,0,0" TextWrapping="Wrap" Text="Facility :" VerticalAlignment="Top" Height="18" Width="47"/>
<TextBlock x:Name="textBlock1_Copy" HorizontalAlignment="Left" Margin="109,124,0,128" TextWrapping="Wrap" Text="Output Location :"/>
<TextBox x:Name="USER_SITE" Height="23" Margin="0,88,108,0" TextWrapping="Wrap" VerticalAlignment="Top" HorizontalAlignment="Right" Width="120" Grid.Column="1"/>
<TextBox x:Name="USER_OUTPUT" Margin="0,117,108,128" TextWrapping="Wrap" HorizontalAlignment="Right" Width="120" Grid.Column="1"/>
<TextBlock x:Name="USER_SCAN_INFO" HorizontalAlignment="Left" Margin="109,10,0,0" TextWrapping="Wrap" Text="This tool is for scanning the AD list of users in a logistics facility. It will create a spreadsheet with listed details of the users that are active. You can modify the site you would like to scan or the output file location." VerticalAlignment="Top" Height="74" Width="369" Grid.ColumnSpan="2"/>
<Image x:Name="Home_Depot_Copy1" HorizontalAlignment="Left" Height="83" Margin="6,1,0,0" VerticalAlignment="Top" Width="88" Source="Home Depot1.png"/>
<Button x:Name="BEGIN_USER_SCAN" Content="SCAN" HorizontalAlignment="Right" VerticalAlignment="Bottom" Width="75" Margin="0,0,10,10" Grid.Column="1"/>
</Grid>
</TabItem>
<TabItem x:Name="SUBNET_SCANNER" Header="Subnet-Scanner">
<Grid Background="#FFE5E5E5">
<TextBlock x:Name="textBlock3" HorizontalAlignment="Right" Margin="0,0,80.02,82.063" TextWrapping="Wrap" Text="Start" VerticalAlignment="Bottom"/>
<TextBlock x:Name="textBlock4" HorizontalAlignment="Right" Margin="0,0,80.02,60.064" TextWrapping="Wrap" Text="End" VerticalAlignment="Bottom"/>
<TextBox x:Name="SUBNET_START" HorizontalAlignment="Right" Height="15.96" Margin="0,0,107.547,80.746" TextWrapping="Wrap" Text="1" VerticalAlignment="Bottom" Width="42.28" FontSize="8"/>
<TextBox x:Name="SUBNET_END" HorizontalAlignment="Right" Margin="0,0,107.547,58.747" TextWrapping="Wrap" Text="255" Width="42.28" FontSize="8" Height="15.96" VerticalAlignment="Bottom"/>
<TextBlock x:Name="textBlock5" HorizontalAlignment="Left" Margin="137,0,0,80.747" TextWrapping="Wrap" Text="First Three:" VerticalAlignment="Bottom"/>
<TextBox x:Name="SUBNET_1" HorizontalAlignment="Left" Height="15.96" Margin="197.333,0,0,80.746" TextWrapping="Wrap" Text="172" VerticalAlignment="Bottom" Width="42.28" FontSize="8"/>
<TextBox x:Name="SUBNET_2" HorizontalAlignment="Right" Height="15.96" Margin="0,0,200.107,80.746" TextWrapping="Wrap" Text="30" VerticalAlignment="Bottom" Width="42.28" FontSize="8"/>
<TextBox x:Name="SUBNET_3" HorizontalAlignment="Right" Height="15.96" Margin="0,0,152.827,80.746" TextWrapping="Wrap" Text="88" VerticalAlignment="Bottom" Width="42.28" FontSize="8"/>
<TextBlock x:Name="textBlock6" Margin="240.013,0,0,82.063" TextWrapping="Wrap" Text="." VerticalAlignment="Bottom" HorizontalAlignment="Left"/>
<TextBlock x:Name="textBlock7" HorizontalAlignment="Right" Margin="0,0,197.107,82.063" TextWrapping="Wrap" Text="." VerticalAlignment="Bottom"/>
<TextBlock x:Name="textBlock8" HorizontalAlignment="Right" Margin="0,0,149.827,82.063" TextWrapping="Wrap" Text="." VerticalAlignment="Bottom"/>
<TextBlock x:Name="SUBNET_SCAN_INFO" Margin="140,10,10,0" TextWrapping="Wrap" Text="This tool is used to scan a specific subnet for PC's and output their basic information to file. If you do not know your default subnet, run a CMD window and type ipconfig. This will give you your IPv4 which you will take the first three values from. The range you scan is set by the start and the end input." VerticalAlignment="Top"/>
<Image x:Name="Home_Depot_Copy2" HorizontalAlignment="Left" Height="82.968" Margin="6.219,0.707,0,0" VerticalAlignment="Top" Width="87.407" Source="Home Depot1.png"/>
<Button x:Name="BEGIN_SUBNET_SCAN" Content="SCAN" HorizontalAlignment="Right" VerticalAlignment="Bottom" Width="75" Margin="0,0,10,10"/>
</Grid>
</TabItem>
<TabItem x:Name="USER_BACKUP" Header="User Backup">
<Grid Background="#FFE5E5E5">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="226*"/>
<ColumnDefinition Width="261*"/>
</Grid.ColumnDefinitions>
<Image x:Name="Home_Depot" HorizontalAlignment="Left" Height="82.968" Margin="6.219,0.707,0,0" VerticalAlignment="Top" Width="87.407" Source="Home Depot1.png"/>
<TextBlock x:Name="UPB" HorizontalAlignment="Left" Margin="104.114,0.707,0,0" TextWrapping="Wrap" Text="User Profile Backup" VerticalAlignment="Top" Height="29.868" Width="336.516" FontSize="21.333" FontFamily="Stencil Std" Grid.ColumnSpan="2"/>
<Button x:Name="Start_Button" Content="BACKUP" HorizontalAlignment="Left" Margin="121.89,248.781,0,0" VerticalAlignment="Top" Width="65.555" Height="18.219" FontSize="10.667" Grid.Column="1"/>
<TextBlock x:Name="Ldap" HorizontalAlignment="Left" Margin="16.708,101.098,0,0" TextWrapping="Wrap" Text="LDAP:" Width="76.918" FontSize="21.333" FontFamily="Stencil Std" Height="28.208" VerticalAlignment="Top"/>
<TextBlock x:Name="Cname" Margin="16.708,150.878,24.323,0" TextWrapping="Wrap" Text="Computer Name:" VerticalAlignment="Top" FontSize="21.333" FontFamily="Stencil Std" Height="20.974"/>
<TextBlock x:Name="textBlock04" HorizontalAlignment="Right" Margin="0,190.792,75.092,0" TextWrapping="Wrap" VerticalAlignment="Top"/>
<TextBlock x:Name="Backup_Status" Margin="11.708,190.792,80.092,0" TextWrapping="Wrap" Text="Backup Status:" VerticalAlignment="Top" FontSize="16" FontFamily="Stencil Std"/>
<Button x:Name="RESTORE" Content="RESTORE" HorizontalAlignment="Left" Margin="192.445,248.781,0,0" VerticalAlignment="Top" Width="65.555" Height="18.219" FontSize="10.667" Grid.Column="1"/>
<TextBox x:Name="Process" HorizontalAlignment="Left" Height="26.549" Margin="104.114,41.361,0,0" TextWrapping="Wrap" Text="Waiting for user......" VerticalAlignment="Top" Width="336.516" FontSize="16" FontFamily="Stencil Std" TextChanged="Process_TextChanged" Grid.ColumnSpan="2"/>
<Button x:Name="Request_Delete" Content="Email" HorizontalAlignment="Left" Margin="148.743,72.059,0,0" VerticalAlignment="Top" Width="65.554" Height="18.219" FontSize="10.667" Grid.Column="1"/>
<TextBlock x:Name="Admin_Request" HorizontalAlignment="Left" Margin="-110.856,76.208,0,0" TextWrapping="Wrap" Text="Email your admin to delete your old backup: " VerticalAlignment="Top" FontSize="10.667" FontFamily="Stencil Std" Grid.Column="1"/>
<Button x:Name="ReplaceBU" Content="UPDATE" HorizontalAlignment="Left" Margin="-17.331,248.781,0,0" VerticalAlignment="Top" Width="65.555" Height="18.219" FontSize="10.667" Grid.Column="1" d:LayoutOverrides="HorizontalAlignment"/>
<TextBlock x:Name="User_Choice" HorizontalAlignment="Left" Margin="9.715,214.752,0,0" TextWrapping="Wrap" Text="You can backup, restore or update your previous backup." VerticalAlignment="Top" FontFamily="Stencil" FontSize="14.667" Grid.ColumnSpan="2"/>
<TextBox x:Name="textBox5" Grid.Column="1" Margin="25.944,101.098,115.056,0" TextWrapping="Wrap" Text="Input" Height="23" VerticalAlignment="Top"/>
<TextBox x:Name="textBox5_Copy" Grid.Column="1" Margin="25.944,0,115.056,96.188" TextWrapping="Wrap" Text="Input" Height="23" VerticalAlignment="Bottom"/>
<Button x:Name="button7" Content="Button" Grid.Column="1" HorizontalAlignment="Right" Margin="0,129.306,13.667,116.774" Width="75" d:LayoutOverrides="Height"/>
</Grid>
</TabItem>
<TabItem x:Name="REMOTE_TOOLS" Header="Remote/Tools">
<Grid Background="#FFE5E5E5">
<TextBox x:Name="TOOLS_PC_NAME" Height="23" Margin="10,73.279,0,0" TextWrapping="Wrap" Text="Computer Name" VerticalAlignment="Top" HorizontalAlignment="Left" Width="120"/>
<Button x:Name="IPCONFIG" Content="IP Config" HorizontalAlignment="Left" VerticalAlignment="Top" Width="75" Margin="10,101.279,0,0"/>
<Button x:Name="GPUPDATE" Content="GP Update" HorizontalAlignment="Left" Margin="10,128.239,0,117.841" Width="75" d:LayoutOverrides="Height"/>
<Button x:Name="SHARED_SHORTCUT" Content="P:\ Shortcut" HorizontalAlignment="Left" Margin="10,0,0,90.88" Width="75" VerticalAlignment="Bottom"/>
<Button x:Name="FILE_EXPLORE" Content="File Explorer" Margin="10,0,0,63.92" VerticalAlignment="Bottom" HorizontalAlignment="Left" Width="75"/>
<Button x:Name="USER_LIST" Content="User List" HorizontalAlignment="Left" Margin="10,0,0,36.96" Width="75" VerticalAlignment="Bottom"/>
<Button x:Name="PC_INFO" Content="PC Info" HorizontalAlignment="Left" Margin="10,0,0,10" VerticalAlignment="Bottom" Width="75"/>
<TextBox x:Name="TOOLS_OUTPUT" Margin="153,10,10,10" TextWrapping="Wrap" Text="Output.......................&#xD;&#xA;i.e. P:\ shortcut placed on \\(computer)\C:\users\public\desktop&#xD;&#xA;&#xD;&#xA;Error (Computer) connection failed......&#xD;&#xA;"/>
<Image x:Name="Home_Depot_Copy3" HorizontalAlignment="Left" Height="67.572" Margin="6.219,0.707,0,0" VerticalAlignment="Top" Width="69.407" Source="Home Depot1.png"/>
</Grid>
</TabItem>
</TabControl>
</Grid>
</Window>
"@
$inputXML = $inputXML -replace 'mc:Ignorable="d"','' -replace "x:N",'N' -replace '^<Win.*', '<Window'
[void][System.Reflection.Assembly]::LoadWithPartialName('presentationframework')
[xml]$XAML = $inputXML
#Read XAML
$reader=(New-Object System.Xml.XmlNodeReader $xaml)
try{$Form=[Windows.Markup.XamlReader]::Load( $reader )}
catch [System.Management.Automation.MethodInvocationException] {
Write-Warning "We ran into a problem with the XAML code. Check the syntax for this control..."
write-host $error[0].Exception.Message -ForegroundColor Red
if ($error[0].Exception.Message -like "*button*"){
write-warning "Ensure your &lt;button in the `$inputXML does NOT have a Click=ButtonClick property. PS can't handle this`n`n`n`n"}
}
catch{#if it broke some other way <span class="wp-smiley wp-emoji wp-emoji-bigsmile" title=":D">:D</span>
Write-Host "Unable to load Windows.Markup.XamlReader. Double-check syntax and ensure .net is installed."
}
#===========================================================================
# Store Form Objects In PowerShell
#===========================================================================
$xaml.SelectNodes("//*[@Name]") | %{Set-Variable -Name "WPF$($_.Name)" -Value $Form.FindName($_.Name)}
Function Get-FormVariables{
if ($global:ReadmeDisplay -ne $true){Write-host "If you need to reference this display again, run Get-FormVariables" -ForegroundColor Yellow;$global:ReadmeDisplay=$true}
write-host "Found the following interactable elements from our form" -ForegroundColor Cyan
get-variable WPF*
}
Get-FormVariables
#===========================================================================
# Use this space to add code to the various form elements in your GUI
#===========================================================================
#Reference
#Adding items to a dropdown/combo box
#$vmpicklistView.items.Add([pscustomobject]@{'VMName'=($_).Name;Status=$_.Status;Other="Yes"})
#Setting the text of a text box to the current PC name
#$WPFtextBox.Text = $env:COMPUTERNAME
#Adding code to a button, so that when clicked, it pings a system
# $WPFbutton.Add_Click({ Test-connection -count 1 -ComputerName $WPFtextBox.Text
# })
#===========================================================================
# Shows the form
#===========================================================================
write-host "To show the form, run the following" -ForegroundColor Cyan
$Form.ShowDialog() | out-null
@Pepeterson

This comment has been minimized.

Copy link
Owner Author

@Pepeterson Pepeterson commented Aug 29, 2016

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment