Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function OnApplicationLoad {
- #Note: This function is not called in Projects
- #Note: This function runs before the form is created
- #Note: To get the script directory in the Packager use: Split-Path $hostinvocation.MyCommand.path
- #Note: To get the console output in the Packager (Windows Mode) use: $ConsoleOutput (Type: System.Collections.ArrayList)
- #Important: Form controls cannot be accessed in this function
- #TODO: Add modules and custom code to validate the application load
- return $true #return true for success or false for failure
- }
- function OnApplicationExit {
- #Note: This function is not called in Projects
- #Note: This function runs after the form is closed
- #TODO: Add custom code to clean up and unload modules when the application exits
- $script:ExitCode = 0 #Set the exit code for the Packager
- }
- $FormEvent_Load={
- #TODO: Initialize Form Controls here
- }
- $username = "domain\domainuser'
- $password = convertto-securestring -asplaintext -force
- $cred = new-object -typename System.Management.Automation.PSCredential `
- -argumentlist $username, $password
- $buttonEnable_Click = {
- #Enable RDP
- Invoke-Command -ComputerName $textboxComputerName.Text -Credential $cred { Set-ItemProperty -Path 'HKLM:\System\CurrentControlSet\Control\Terminal Server' -name 'fDenyTSConnections' -Value 0 }
- }
- $buttonDisable_Click= {
- #Disable RDP
- Invoke-Command -ComputerName $textboxComputerName.Text -Credential $cred { Set-ItemProperty -Path 'HKLM:\System\CurrentControlSet\Control\Terminal Server' -name 'fDenyTSConnections' -Value 1 }
- }
- $textboxComputerName_TextChanged={
- #Allow Textbox input
- New-Object 'System.Windows.Forms.TextBox'
- }
- $textboxStatus_TextChanged={
- #Allow Textbox output
- New-Object 'System.Windows.Forms.TextBox'
- }
Advertisement
Add Comment
Please, Sign In to add comment