MilesLogan
asked on
PowerShell - Creating GUI for a simple search
The script below works in PowerShell but I am trying to create a search box with powershell Studio .. anyone able to help out ? either with powershell Studio or any other tool .. This is the first attempt .
$UserName = Read-Host "Enter ID"
Get-Aduser $Username -Properties Name,homeDirectory,SamAcco untName,Ca nonicalNam e |Select Name,homeDirectory,SamAcco untName,Ca nonicalNam e
The Code below does not return anything ...
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.ArrayLi st)
#Important: Form controls cannot be accessed in this function
#TODO: Add snapins 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 snapins when the application exits
$script:ExitCode = 0 #Set the exit code for the Packager
}
$form1_Load={
#TODO: Initialize Form Controls here
}
$textbox1_TextChanged={
#TODO: Place custom script here
$UserName
}
$Search_Click={
#TODO: Place custom script here
Get-Aduser $Username -Properties Name,homeDirectory,SamAcco untName,Ca nonicalNam e |Select Name,homeDirectory,SamAcco untName,Ca nonicalNam e
}
$UserName = Read-Host "Enter ID"
Get-Aduser $Username -Properties Name,homeDirectory,SamAcco
The Code below does not return anything ...
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.
#Note: To get the console output in the Packager (Windows Mode) use: $ConsoleOutput (Type: System.Collections.ArrayLi
#Important: Form controls cannot be accessed in this function
#TODO: Add snapins 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 snapins when the application exits
$script:ExitCode = 0 #Set the exit code for the Packager
}
$form1_Load={
#TODO: Initialize Form Controls here
}
$textbox1_TextChanged={
#TODO: Place custom script here
$UserName
}
$Search_Click={
#TODO: Place custom script here
Get-Aduser $Username -Properties Name,homeDirectory,SamAcco
}
Is that all?? I don’t see any form or text box loaded..
ASKER
yeah .. I dont know where to go from here ..
I can help you with some sample code.. I will do it when I get some time.. :-)
There's a great tutorial to building forms here:
http://blogs.technet.com/b/stephap/archive/2012/04/23/building-forms-with-powershell-part-1-the-form.aspx
You should be able to get a good start from there.
Rob.
http://blogs.technet.com/b/stephap/archive/2012/04/23/building-forms-with-powershell-part-1-the-form.aspx
You should be able to get a good start from there.
Rob.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank you Subsun!
It worked but yeah not exactly sure how ..
It worked but yeah not exactly sure how ..
I have used PrimalForms to create the GUI interface.. to start with, you can refer the following article which is having some helpful information...
http://blogs.technet.com/b/heyscriptingguy/archive/2011/07/24/create-a-simple-graphical-interface-for-a-powershell-script.aspx
http://blogs.technet.com/b/heyscriptingguy/archive/2011/07/24/create-a-simple-graphical-interface-for-a-powershell-script.aspx