Advertisement
Guest User

Untitled

a guest
Oct 27th, 2016
772
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.31 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="Accounts Control Panel" Height="614.706" Width="1155.803">
  10. <Grid Margin="0,0,2,-4">
  11. <Grid.Background>
  12. </Grid.Background>
  13. <Grid.RowDefinitions>
  14. <RowDefinition Height="121*"/>
  15. <RowDefinition Height="467*"/>
  16. </Grid.RowDefinitions>
  17. <Grid.ColumnDefinitions>
  18. <ColumnDefinition Width="65*"/>
  19. <ColumnDefinition Width="65*"/>
  20. <ColumnDefinition Width="73*"/>
  21. </Grid.ColumnDefinitions>
  22. <Button x:Name="DisableAcc" Content="Disable Account" HorizontalAlignment="Left" Height="45" Margin="60,30,0,0" VerticalAlignment="Top" Width="140" Grid.Row="1">
  23. <Button.Effect>
  24. <DropShadowEffect/>
  25. </Button.Effect>
  26. </Button>
  27. <Button x:Name="button_Copy" Content="Enable Account" HorizontalAlignment="Left" Height="45" Margin="60,98,0,0" VerticalAlignment="Top" Width="140" Grid.Row="1">
  28. <Button.Effect>
  29. <DropShadowEffect/>
  30. </Button.Effect>
  31. </Button>
  32. <Button x:Name="button_Copy1" Content="Set Account Expiry " HorizontalAlignment="Left" Height="45" Margin="60,239,0,0" VerticalAlignment="Top" Width="140" Grid.Row="1">
  33. <Button.Effect>
  34. <DropShadowEffect/>
  35. </Button.Effect>
  36. </Button>
  37. <Button x:Name="button_Copy2" Content="" HorizontalAlignment="Left" Height="45" VerticalAlignment="Top" Width="140" Grid.Column="2" Grid.Row="1" Margin="70,30,0,0">
  38. <Button.Effect>
  39. <DropShadowEffect/>
  40. </Button.Effect>
  41. </Button>
  42. <Button x:Name="button_Copy3" Content="" HorizontalAlignment="Left" Height="45" Margin="70,98,0,0" VerticalAlignment="Top" Width="140" Grid.Column="2" Grid.Row="1">
  43. <Button.Effect>
  44. <DropShadowEffect/>
  45. </Button.Effect>
  46. </Button>
  47. <Button x:Name="button_Copy4" Content="" HorizontalAlignment="Left" Height="45" Margin="70,168,0,0" VerticalAlignment="Top" Width="140" Grid.Column="2" Grid.Row="1">
  48. <Button.Effect>
  49. <DropShadowEffect/>
  50. </Button.Effect>
  51. </Button>
  52. <TextBox x:Name="textBox" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" HorizontalAlignment="Left" Height="45" Margin="60,76,0,0" Text="Account Tasks" VerticalAlignment="Top" Width="135" HorizontalScrollBarVisibility="Auto" Padding="0" TextAlignment="Center" TextWrapping="Wrap" RenderTransformOrigin="0.5,0.5" BorderThickness="2" Background="#FFD69A52" CaretBrush="#FFD69A52" BorderBrush="Black"/>
  53. <Button x:Name="button_Copy5" Content="Account Name Change" HorizontalAlignment="Left" Height="45" Margin="60,309,0,0" VerticalAlignment="Top" Width="140" Grid.Row="1">
  54. <Button.Effect>
  55. <DropShadowEffect/>
  56. </Button.Effect>
  57. </Button>
  58. <Button x:Name="button_Copy6" Content="Account Information" HorizontalAlignment="Left" Height="45" Margin="60,377,0,0" VerticalAlignment="Top" Width="140" Grid.Row="1">
  59. <Button.Effect>
  60. <DropShadowEffect/>
  61. </Button.Effect>
  62. </Button>
  63. <Button x:Name="button_Copy7" Content="Unblock Account" HorizontalAlignment="Left" Height="45" Margin="60,168,0,0" VerticalAlignment="Top" Width="140">
  64. <Button.Effect>
  65. <DropShadowEffect/>
  66. </Button.Effect>
  67. </Button>
  68. <TextBox x:Name="textBox_Copy" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" HorizontalAlignment="Left" Height="45" Margin="70,76,0,0" Text="Get Information" VerticalAlignment="Top" Width="135" HorizontalScrollBarVisibility="Auto" Padding="0" TextAlignment="Center" TextWrapping="Wrap" RenderTransformOrigin="0.5,0.5" Grid.Column="1" BorderThickness="2" SelectionBrush="#FF6695B9" BorderBrush="Black" CaretBrush="#FFD69A52" Background="#FFD69A52"/>
  69. <Button x:Name="button_Copy8" Content="Get Computer Information" HorizontalAlignment="Left" Height="45" Margin="70,30,0,0" VerticalAlignment="Top" Width="140" Grid.Row="1" Grid.Column="1">
  70. <Button.Effect>
  71. <DropShadowEffect/>
  72. </Button.Effect>
  73. </Button>
  74. <Button x:Name="button_Copy9" Content="Get Members of a Group" HorizontalAlignment="Left" Height="45" Margin="70,98,0,0" VerticalAlignment="Top" Width="140" Grid.Row="1" Grid.Column="1">
  75. <Button.Effect>
  76. <DropShadowEffect/>
  77. </Button.Effect>
  78. </Button>
  79. <Button x:Name="button_Copy10" Content="Get Mailbox GUID" HorizontalAlignment="Left" Height="45" Margin="70,168,0,0" VerticalAlignment="Top" Width="140" Grid.Row="1" Grid.Column="1">
  80. <Button.Effect>
  81. <DropShadowEffect/>
  82. </Button.Effect>
  83. </Button>
  84. <TextBox x:Name="textBox_Copy1" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" HorizontalAlignment="Left" Height="45" Margin="70,76,0,0" Text="Misc" VerticalAlignment="Top" Width="135" HorizontalScrollBarVisibility="Auto" Padding="0" TextAlignment="Center" TextWrapping="Wrap" RenderTransformOrigin="0.5,0.5" Grid.Column="2" BorderThickness="2" BorderBrush="Black" Background="#FFD69A52"/>
  85. <Button x:Name="button_Copy11" Content="Check Microsoft Licenses" HorizontalAlignment="Left" Height="45" Margin="70,239,0,0" VerticalAlignment="Top" Width="140" Grid.Row="1" Grid.Column="1">
  86. <Button.Effect>
  87. <DropShadowEffect/>
  88. </Button.Effect>
  89. </Button>
  90. <Button x:Name="button_Copy12" Content="" HorizontalAlignment="Left" Height="45" Margin="70,309,0,0" VerticalAlignment="Top" Width="140" Grid.Row="1" Grid.Column="1">
  91. <Button.Effect>
  92. <DropShadowEffect/>
  93. </Button.Effect>
  94. </Button>
  95. <Button x:Name="button_Copy13" Content="" HorizontalAlignment="Left" Height="45" Margin="70,377,0,0" VerticalAlignment="Top" Width="140" Grid.Row="1" Grid.Column="1">
  96. <Button.Effect>
  97. <DropShadowEffect/>
  98. </Button.Effect>
  99. </Button>
  100. </Grid>
  101. </Window>
  102. "@
  103. $inputXML = $inputXML -replace 'mc:Ignorable="d"','' -replace "x:N",'N' -replace '^<Win.*', '<Window'
  104.  
  105. [void][System.Reflection.Assembly]::LoadWithPartialName('presentationframework')
  106. [xml]$XAML = $inputXML
  107. #Read XAML
  108.  
  109. $reader=(New-Object System.Xml.XmlNodeReader $xaml)
  110. try{$Form=[Windows.Markup.XamlReader]::Load( $reader )}
  111. catch{Write-Host "Unable to load Windows.Markup.XamlReader. Double-check syntax and ensure .net is installed."}
  112.  
  113. $WPFDisableAcc.add_Click({Write-Host Clicked})
  114. #===========================================================================
  115. # Load XAML Objects In PowerShell
  116. #===========================================================================
  117.  
  118. $xaml.SelectNodes("//*[@Name]") | %{Set-Variable -Name "WPF$($_.Name)" -Value $Form.FindName($_.Name)}
  119.  
  120. Function Get-FormVariables{
  121. if ($global:ReadmeDisplay -ne $true){Write-host "If you need to reference this display again, run Get-FormVariables" -ForegroundColor Yellow;$global:ReadmeDisplay=$true}
  122. write-host "Found the following interactable elements from our form" -ForegroundColor Cyan
  123. get-variable WPF*
  124. }
  125.  
  126. Get-FormVariables
  127.  
  128. #===========================================================================
  129. # Actually make the objects work
  130. #===========================================================================
  131.  
  132. #Sample entry of how to add data to a field
  133.  
  134. #$vmpicklistView.items.Add([pscustomobject]@{'VMName'=($_).Name;Status=$_.Status;Other="Yes"})
  135.  
  136. #===========================================================================
  137. # Shows the form
  138. #===========================================================================
  139. write-host "To show the form, run the following" -ForegroundColor Cyan
  140. $Form.ShowDialog() | out-null
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement