main()
method that creates and shows dialog. Get-FixedDisk
. This project’s purpose is to get the information about the non-removable or fixed disks on the target machine.Computer
parameter which accepts a string value. Also, by adding the Mandatory
parameter attribute, it ensures that the function does not run if the Computer
parameter is not specified at runtime.$DiskInfo
. I’ve also added a filter to get only the disks with DriveType=3
. This filter ensures that only the information about local fixed disks is displayed..
) and a space before the script path. If the script were in the C:PoshGUI-sample folder, you could dot source it like below.Get-FixedDisk
function is used to query the computer poshLabExc.Get-FixedDisk
. You were also able to test and confirm that the function is working.$xamlFile
and point it to the full path of your MainWindow.xaml file.$Null = $window.ShowDialog()
must always be the last line of code inside your script.btnQuery
button will be assigned an action. The other controls will only serve as input and output/display controls. This means that we only need to add a click event code to btnQuery
.btnQuery
, assign the code below to its corresponding variable name $var_btnQuery
. Copy the code below and insert it in between the Get-Variable var_*
and $Null = $window.ShowDialog()
code references in the script.