Advertisement
Guest User

Untitled

a guest
Oct 25th, 2016
808
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 11.56 KB | None | 0 0
  1. $inputXML= @"
  2. <Window x:Class="Powershell_Control_Panel.MainWindow"
  3. xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  4. xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  5. xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
  6. xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
  7. xmlns:local="clr-namespace:Powershell_Control_Panel"
  8. mc:Ignorable="d"
  9. Title="Wiggle Accounts Control Panel" Height="768" Width="1366">
  10. <Grid Margin="0,0,2,-4" Background="#FF608977">
  11. <Grid.RowDefinitions>
  12. <RowDefinition Height="121*"/>
  13. <RowDefinition Height="467*"/>
  14. </Grid.RowDefinitions>
  15. <Grid.ColumnDefinitions>
  16. <ColumnDefinition/>
  17. </Grid.ColumnDefinitions>
  18. <Button x:Name="button" Content="Disable Account" HorizontalAlignment="Left" Height="45" Margin="148,30,0,0" VerticalAlignment="Top" Width="176" Grid.Row="1" FontFamily="Nirmala UI" FontSize="14" Background="#FFA7AC77" BorderBrush="#FF0A0101">
  19. <Button.Effect>
  20. <DropShadowEffect/>
  21. </Button.Effect>
  22. </Button>
  23. <Button x:Name="button_Copy" Content="Enable Account" HorizontalAlignment="Left" Height="45" Margin="148,98,0,0" VerticalAlignment="Top" Width="176" Grid.Row="1" FontFamily="Nirmala UI" FontSize="14" Background="#FFA7AC77" BorderBrush="Black">
  24. <Button.Effect>
  25. <DropShadowEffect/>
  26. </Button.Effect>
  27. </Button>
  28. <Button x:Name="button_Copy1" Content="Set Account Expiry " HorizontalAlignment="Left" Height="45" Margin="148,239,0,0" VerticalAlignment="Top" Width="176" Grid.Row="1" FontFamily="Nirmala UI" FontSize="14" Background="#FFA7AC77" BorderBrush="Black">
  29. <Button.Effect>
  30. <DropShadowEffect/>
  31. </Button.Effect>
  32. </Button>
  33. <Button x:Name="button_Copy2" Content="" HorizontalAlignment="Left" Height="45" VerticalAlignment="Top" Width="176" Grid.Row="1" Margin="1067,30,0,0" FontFamily="Nirmala UI" FontSize="14" Background="#FFA7AC77" BorderBrush="Black">
  34. <Button.Effect>
  35. <DropShadowEffect/>
  36. </Button.Effect>
  37. </Button>
  38. <Button x:Name="button_Copy3" Content="" HorizontalAlignment="Left" Height="45" Margin="1067,98,0,0" VerticalAlignment="Top" Width="176" Grid.Row="1" FontFamily="Nirmala UI" FontSize="14" Background="#FFA7AC77" BorderBrush="Black">
  39. <Button.Effect>
  40. <DropShadowEffect/>
  41. </Button.Effect>
  42. </Button>
  43. <Button x:Name="button_Copy4" Content="" HorizontalAlignment="Left" Height="45" Margin="1067,168,0,0" VerticalAlignment="Top" Width="176" Grid.Row="1" FontFamily="Nirmala UI" FontSize="14" Background="#FFA7AC77" BorderBrush="Black">
  44. <Button.Effect>
  45. <DropShadowEffect/>
  46. </Button.Effect>
  47. </Button>
  48. <Button x:Name="button_Copy5" Content="Account Name Change" HorizontalAlignment="Left" Height="45" Margin="148,309,0,0" VerticalAlignment="Top" Width="176" Grid.Row="1" FontFamily="Nirmala UI" FontSize="14" Background="#FFA7AC77" BorderBrush="Black">
  49. <Button.Effect>
  50. <DropShadowEffect/>
  51. </Button.Effect>
  52. </Button>
  53. <Button x:Name="button_Copy6" Content="Account Information" HorizontalAlignment="Left" Height="45" Margin="148,377,0,0" VerticalAlignment="Top" Width="176" Grid.Row="1" FontFamily="Nirmala UI" FontSize="14" Background="#FFA7AC77" BorderBrush="Black">
  54. <Button.Effect>
  55. <DropShadowEffect/>
  56. </Button.Effect>
  57. </Button>
  58. <Button x:Name="button_Copy7" Content="Unblock Account" HorizontalAlignment="Left" Height="45" Margin="148,168,0,0" VerticalAlignment="Top" Width="176" Grid.Row="1" FontFamily="Nirmala UI" FontSize="14" BorderBrush="Black" Background="#FFA7AC77">
  59. <Button.Effect>
  60. <DropShadowEffect/>
  61. </Button.Effect>
  62. </Button>
  63. <Button x:Name="button_Copy8" Content="Get Computer Information" HorizontalAlignment="Left" Height="45" Margin="620,30,0,0" VerticalAlignment="Top" Width="176" Grid.Row="1" FontFamily="Nirmala UI" FontSize="14" Background="#FFA7AC77" BorderBrush="Black">
  64. <Button.Effect>
  65. <DropShadowEffect/>
  66. </Button.Effect>
  67. </Button>
  68. <Button x:Name="button_Copy9" Content="Get Members of a Group" HorizontalAlignment="Left" Height="45" Margin="620,98,0,0" VerticalAlignment="Top" Width="176" Grid.Row="1" FontFamily="Nirmala UI" FontSize="14" Background="#FFA7AC77" BorderBrush="Black">
  69. <Button.Effect>
  70. <DropShadowEffect/>
  71. </Button.Effect>
  72. </Button>
  73. <Button x:Name="button_Copy10" Content="Get Mailbox GUID" HorizontalAlignment="Left" Height="45" Margin="620,168,0,0" VerticalAlignment="Top" Width="176" Grid.Row="1" FontFamily="Nirmala UI" FontSize="14" Background="#FFA7AC77" BorderBrush="Black">
  74. <Button.Effect>
  75. <DropShadowEffect/>
  76. </Button.Effect>
  77. </Button>
  78. <Button x:Name="button_Copy11" Content="Check Microsoft Licenses" HorizontalAlignment="Left" Height="45" Margin="620,239,0,0" VerticalAlignment="Top" Width="176" Grid.Row="1" FontFamily="Nirmala UI" FontSize="14" Background="#FFA7AC77" BorderBrush="Black">
  79. <Button.Effect>
  80. <DropShadowEffect/>
  81. </Button.Effect>
  82. </Button>
  83. <Button x:Name="button_Copy12" Content="" HorizontalAlignment="Left" Height="45" Margin="620,309,0,0" VerticalAlignment="Top" Width="176" Grid.Row="1" FontFamily="Nirmala UI" FontSize="14" Background="#FFA7AC77" BorderBrush="Black">
  84. <Button.Effect>
  85. <DropShadowEffect/>
  86. </Button.Effect>
  87. </Button>
  88. <Button x:Name="button_Copy13" Content="" HorizontalAlignment="Left" Height="45" Margin="620,377,0,0" VerticalAlignment="Top" Width="176" Grid.Row="1" FontFamily="Nirmala UI" FontSize="14" Background="#FFA7AC77" BorderBrush="Black">
  89. <Button.Effect>
  90. <DropShadowEffect/>
  91. </Button.Effect>
  92. </Button>
  93. <Border BorderBrush="Black" BorderThickness="1" HorizontalAlignment="Left" Height="152" VerticalAlignment="Top" Width="450">
  94. <Border BorderBrush="Black" BorderThickness="1" HorizontalAlignment="Left" Height="132" Margin="9,9,0,0" VerticalAlignment="Top" Width="430"/>
  95. </Border>
  96. <Border BorderBrush="Black" BorderThickness="1" HorizontalAlignment="Left" Height="152" VerticalAlignment="Top" Width="450">
  97. <Border.Background>
  98. <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
  99. <GradientStop Color="Black" Offset="0"/>
  100. <GradientStop Color="#FF88B673" Offset="0.56"/>
  101. <GradientStop Color="#FF8F8F8F" Offset="0.757"/>
  102. </LinearGradientBrush>
  103. </Border.Background>
  104. <Border BorderBrush="Black" BorderThickness="1" HorizontalAlignment="Left" Height="132" Margin="9,9,0,0" VerticalAlignment="Top" Width="430" Background="#FF608977">
  105. <TextBox x:Name="textBox1" TextWrapping="Wrap" Text="Account Scripts" FontWeight="Bold" Margin="130,45,130,50" FontSize="22" BorderThickness="0">
  106. <TextBox.Background>
  107. <ImageBrush/>
  108. </TextBox.Background>
  109. </TextBox>
  110. </Border>
  111. </Border>
  112. <Border BorderBrush="Black" BorderThickness="1" HorizontalAlignment="Left" Height="152" VerticalAlignment="Top" Width="450" Margin="453,0,0,0">
  113. <Border.Background>
  114. <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
  115. <GradientStop Color="Black" Offset="0"/>
  116. <GradientStop Color="#FF88B673" Offset="0.56"/>
  117. <GradientStop Color="#FF8F8F8F" Offset="0.757"/>
  118. </LinearGradientBrush>
  119. </Border.Background>
  120. <Border BorderBrush="Black" BorderThickness="1" HorizontalAlignment="Left" Height="132" Margin="9,9,0,0" VerticalAlignment="Top" Width="430" Background="#FF608977">
  121. <TextBox x:Name="textBox2" TextWrapping="Wrap" Text="Get-Info Scripts" FontWeight="Bold" Margin="130,45,130,50" FontSize="21" BorderThickness="0">
  122. <TextBox.Background>
  123. <ImageBrush/>
  124. </TextBox.Background>
  125. </TextBox>
  126. </Border>
  127. </Border>
  128. <Border BorderBrush="Black" BorderThickness="1" HorizontalAlignment="Left" Height="152" VerticalAlignment="Top" Width="450" Margin="906,0,0,0">
  129. <Border.Background>
  130. <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
  131. <GradientStop Color="Black" Offset="0"/>
  132. <GradientStop Color="#FF88B673" Offset="0.56"/>
  133. <GradientStop Color="#FF8F8F8F" Offset="0.757"/>
  134. </LinearGradientBrush>
  135. </Border.Background>
  136. <Border BorderBrush="Black" BorderThickness="1" HorizontalAlignment="Left" Height="132" Margin="9,9,0,0" VerticalAlignment="Top" Width="430" Background="#FF608977">
  137. <TextBox x:Name="textBox3" TextWrapping="Wrap" Text="Misc" FontWeight="Bold" Margin="189,45,174,50" FontSize="22" BorderThickness="0">
  138. <TextBox.Background>
  139. <ImageBrush/>
  140. </TextBox.Background>
  141. </TextBox>
  142. </Border>
  143. </Border>
  144. <Button x:Name="button" Content="Close" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="1022,530,5,10" Grid.Row="1" Width="329" RenderTransformOrigin="0.5,0.5" Background="#FF958A8A" Height="49" BorderBrush="Black"/>
  145. </Grid>
  146. </Window>
  147.  
  148. "@
  149.  
  150. $inputXML = $inputXML -replace 'mc:Ignorable="d"','' -replace "x:N",'N' -replace '^<Win.*', '<Window'
  151.  
  152. [void][System.Reflection.Assembly]::LoadWithPartialName('presentationframework')
  153. [xml]$XAML = $inputXML
  154. #Read XAML
  155.  
  156. $reader=(New-Object System.Xml.XmlNodeReader $xaml)
  157. try{$Form=[Windows.Markup.XamlReader]::Load( $reader )}
  158. catch{Write-Host "Unable to load Windows.Markup.XamlReader. Double-check syntax and ensure .net is installed."}
  159.  
  160. #===========================================================================
  161. # Load XAML Objects In PowerShell
  162. #===========================================================================
  163.  
  164. $xaml.SelectNodes("//*[@Name]") | %{Set-Variable -Name "WPF$($_.Name)" -Value $Form.FindName($_.Name)}
  165.  
  166. Function Get-FormVariables{
  167. if ($global:ReadmeDisplay -ne $true){Write-host "If you need to reference this display again, run Get-FormVariables" -ForegroundColor Yellow;$global:ReadmeDisplay=$true}
  168. write-host "Found the following interactable elements from our form" -ForegroundColor Cyan
  169. get-variable WPF*
  170. }
  171.  
  172. Get-FormVariables
  173.  
  174. #===========================================================================
  175. # Actually make the objects work
  176. #===========================================================================
  177.  
  178. #Sample entry of how to add data to a field
  179.  
  180. #$vmpicklistView.items.Add([pscustomobject]@{'VMName'=($_).Name;Status=$_.Status;Other="Yes"})
  181.  
  182. #===========================================================================
  183. # Shows the form
  184. #===========================================================================
  185. write-host "To show the form, run the following" -ForegroundColor Cyan
  186. $Form.ShowDialog() | out-null
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement