I am in the same boat, kinda.
Whenever I select one of the items in a combobox, it does the code twice.
So as you can see,
I want to select the VolumeLabel of the drive
Have it determine if it's FAT32, if not place a check in the box and update the Is NOT FAT32 Label
Then search the flash drive for certain directories and files
If pass, labels turn green and no check boxes
If fail, labels turn red and check boxes are added
Then I'd add to the createflashdrive_Click {
if $checkboxISNOTFAT32.Checked = $true
{ do this}
If $checkboxNETWORKDRIVERS.Checked = $true
{do this}
etc...
Yes I'm aware that my code is in the $comboboxFLASHDRIVELABEL_Click but it's 4am on the East Coast and I have to get up in 5 hours and I"ve been working on this all day.
I've tried get-wmiobject as well as System.IO.DriveInfo and they both appear to get the drive info I need, just need to change VolumeName and VolumeLabel. Any guidance is appreciated.
Combobox example
Forum rules
Do not post any licensing information in this forum.
Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
Do not post any licensing information in this forum.
Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
Re: Combobox example
- Attachments
-
- FlashDriveCreator.psf
- (232.99 KiB) Downloaded 172 times
-
- Capture.PNG (13.43 KiB) Viewed 3261 times
Re: Combobox example
When the index changes the code fires. THis happens at least twice before the combobox is displayed. You need to account for these extra events.
If you use the "SelectedIndexChanged" event which is the default for combobox the code will behave better.
If you use the "SelectedIndexChanged" event which is the default for combobox the code will behave better.
Re: Combobox example
i was using the selectedindexchanged event but wasnt getting my results but I figured it out
This appears to be working so far.
Code: Select all
$comboboxFLASHDRIVELABEL.SelectedItem | ForEach-Object {
if ((Test-Path -Path (Join-Path -Path ($_.Name) -ChildPath "Network Drivers") -PathType Container))
{
$labelALLMODELNETWORKDRIVEPRESENT.Text = 'Folder is present'
$labelALLMODELNETWORKDRIVEPRESENT.ForeColor = 'Green'
}
else
{
$labelALLMODELNETWORKDRIVEPRESENT.Text = 'Folder does not exist'
$labelALLMODELNETWORKDRIVEPRESENT.ForeColor = 'Red'
$checkboxNETWORKDRIVERS.Checked = $true
}
}
Re: Combobox example
Thanks for the info so far.
Can you expand on it a little please? If i have a drop down list of domains, D1, d2, d3
The user selects d1 and hits the button. For this example the button will do a get-aduser * but i need to know to get the selected item to feed into get-aduser so it will run get-aduser * on d1?
Thanks
Can you expand on it a little please? If i have a drop down list of domains, D1, d2, d3
The user selects d1 and hits the button. For this example the button will do a get-aduser * but i need to know to get the selected item to feed into get-aduser so it will run get-aduser * on d1?
Thanks
Re: Combobox example
I know how ad-user works. I dont think you understand what i am trying to do.
Let me try again....
- Combo box has 3 different domains to choose from
- for this example the button runs get-aduser *
If the person using the form selects d1 from the dropdown list, hits the button then the get-aduser runs on d1
If the person using the form selects d2 from the dropdown list, hits the button then the get-aduser runs on d2
If the person using the form selects d3 from the dropdown list, hits the button then the get-aduser runs on d3
Let me try again....
- Combo box has 3 different domains to choose from
- for this example the button runs get-aduser *
If the person using the form selects d1 from the dropdown list, hits the button then the get-aduser runs on d1
If the person using the form selects d2 from the dropdown list, hits the button then the get-aduser runs on d2
If the person using the form selects d3 from the dropdown list, hits the button then the get-aduser runs on d3
Re: Combobox example
The following will explain how to use Get-AdUser and how to option it. You cannot use Get-AdUser *. It will not work.
https://technet.microsoft.com/en-us/lib ... 17241.aspx
There are a number of options which you may need to adjust for your installation. The page explains all of the options and has examples. Try it at command prompt until you understand how to use the command. After that it will be easy to move into a form.
https://technet.microsoft.com/en-us/lib ... 17241.aspx
There are a number of options which you may need to adjust for your installation. The page explains all of the options and has examples. Try it at command prompt until you understand how to use the command. After that it will be easy to move into a form.
Re: Combobox example
Oh wow! Ok, i know how get-aduser works and yes get-aduser * does not work. I was simply trying to explain that the button would get all users off that domain that was selected in the form.
Re: Combobox example
Still not szure what you are asking.ianstraw wrote:Oh wow! Ok, i know how get-aduser works and yes get-aduser * does not work. I was simply trying to explain that the button would get all users off that domain that was selected in the form.
To get the combobox just reference $combobox1.selecteditem. If itt has the domain name (FQDN, NB name, IP) it will work.
- dan.potter
- Posts: 709
- Last visit: Wed Nov 14, 2018 11:39 am