Guest User

RDP GUI

a guest
Sep 11th, 2014
41
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function OnApplicationLoad {
  2.     #Note: This function is not called in Projects
  3.     #Note: This function runs before the form is created
  4.     #Note: To get the script directory in the Packager use: Split-Path $hostinvocation.MyCommand.path
  5.     #Note: To get the console output in the Packager (Windows Mode) use: $ConsoleOutput (Type: System.Collections.ArrayList)
  6.     #Important: Form controls cannot be accessed in this function
  7.     #TODO: Add modules and custom code to validate the application load
  8.     return $true #return true for success or false for failure
  9. }
  10.  
  11.  
  12. function OnApplicationExit {
  13.     #Note: This function is not called in Projects
  14.     #Note: This function runs after the form is closed
  15.     #TODO: Add custom code to clean up and unload modules when the application exits
  16.  
  17.     $script:ExitCode = 0 #Set the exit code for the Packager
  18. }
  19.  
  20. $FormEvent_Load={
  21.     #TODO: Initialize Form Controls here
  22.    
  23. }
  24. $username = "domain\domainuser'
  25. $password = convertto-securestring  -asplaintext -force
  26. $cred = new-object -typename System.Management.Automation.PSCredential `
  27.             -argumentlist $username, $password
  28.  
  29. $buttonEnable_Click = {
  30.     #Enable RDP
  31.     Invoke-Command -ComputerName $textboxComputerName.Text -Credential $cred { Set-ItemProperty -Path 'HKLM:\System\CurrentControlSet\Control\Terminal Server' -name 'fDenyTSConnections' -Value 0 }
  32.    
  33. }
  34. $buttonDisable_Click= {
  35.     #Disable RDP
  36.     Invoke-Command -ComputerName $textboxComputerName.Text -Credential $cred { Set-ItemProperty -Path 'HKLM:\System\CurrentControlSet\Control\Terminal Server' -name 'fDenyTSConnections' -Value 1 }
  37.    
  38. }
  39.  
  40. $textboxComputerName_TextChanged={
  41.     #Allow Textbox input
  42. New-Object 'System.Windows.Forms.TextBox'
  43. }
  44.  
  45. $textboxStatus_TextChanged={
  46.     #Allow Textbox output
  47.     New-Object 'System.Windows.Forms.TextBox'
  48.    
  49.    
  50. }
Advertisement
Add Comment
Please, Sign In to add comment