Being an SCCM Administrator, I use PowerShell daily. I'm no expert at it, but know enough to piece things together and make things work. I purchased a license for PowerShell Studio a while back, but haven't used it until I thought it would be the perfect solution to build USB media for SCCM purposes. The only thing is that even after 3-4 hours working on it, I have a few questions, please. Below is an explanation of what I'm trying to do as well as all information about the project followed by the questions...

Explanation of ProjectIf interested at all...
With our SCCM environment, we create two types of USB media - "Bootable" (~500mb) which is used to boot systems to be imaged over the network and "Standalone" which images systems using source data on the actual USB stick (~21gb.) The reason I want to put it in a GUI is that people are selecting the wrong distribution point to build it from causing ~20gb of data to start transferring over the WAN instead of local LAN. Yikes!

Plan for GUI
I have already created PowerShell scripts which when run will build the media automatically. My plan was to have 3 questions with radio buttons to choose answer followed by two buttons - one to create media and the other to exit the app. The plan was to have selection of radio buttons set certain variables then when they click "Create Media," it combines everything together.

OSDGUI.png (26.13 KiB) Viewed 702 times

Source Strings & Variables
Below are two execution strings which once variables are set from the radio buttons from the location and drive groups, will build the media. Samples of the variables are below them...

Issues / Questions1. How to configure radio button select to determine which string to execute?
If this project only offered to create on type of media, this would be simple as only one string is needed and all I'd have to do is create radio buttons to fill in variables. However, depending on what is selected in the first radio group, one of two different strings will be executed. That's why my included script is incomplete.What's the best way to do this?

2. Possible to (somewhat easily) be able to have options loaded as needed when started?
I'd much prefer having the script automatically select the location and thought the easiest way would be when run to have it ping 3 hostnames. Only one of the 3 (if any) would have a response time of under 10ms and if so it would be selected. If none have that time or below, a message will appear and you won't be able to create media. As for the USB media, I'm trying to find scripting which will examine drives, determine which have USB media attached, and if only one set it as the variable. Is this doable for someone at my level?

3. Importing the Module from File
These strings require that the SCCM module be imported and you be on the site's drive before they will work. Due to this, I added an "import-module filename.psd1" and "cd ABC:" lines under the "$OnLoadFormEvent" section. Is this correct? Surely there's a better way. I have it loading the .psd1 file from a share but didn't know if there was a way to import the profile into the project or similar.

Think that's about it - as if it wasn't enough. If you took the time to read this, I really appreciate it. I'll happily take whatever suggestions anyone may have. I had to swap out some hostnames since it wouldn't let me post with them. Thank you!!!

[quote="bzowkyIssues / Questions1. How to configure radio button select to determine which string to execute?
If this project only offered to create on type of media, this would be simple as only one string is needed and all I'd have to do is create radio buttons to fill in variables. However, depending on what is selected in the first radio group, one of two different strings will be executed. That's why my included script is incomplete.What's the best way to do this?

2. Possible to (somewhat easily) be able to have options loaded as needed when started?
I'd much prefer having the script automatically select the location and thought the easiest way would be when run to have it ping 3 hostnames. Only one of the 3 (if any) would have a response time of under 10ms and if so it would be selected. If none have that time or below, a message will appear and you won't be able to create media. As for the USB media, I'm trying to find scripting which will examine drives, determine which have USB media attached, and if only one set it as the variable. Is this doable for someone at my level?

3. Importing the Module from File
These strings require that the SCCM module be imported and you be on the site's drive before they will work. Due to this, I added an "import-module filename.psd1" and "cd ABC:" lines under the "$OnLoadFormEvent" section. Is this correct? Surely there's a better way. I have it loading the .psd1 file from a share but didn't know if there was a way to import the profile into the project or similar.

[/quote]

Quite a lengthy post. Let me begin by noting that complete project review is beyond the scope of all technical forums. I quickly read you discussion and extracted the questions which we can try to address.

1. Radio buttons have events like all other controls. The event is where you would execute code. Radio buttons are grouped within the parent container and can be extracted in a way that allows you to detect the selected button and its associated text.

2. YOU cab save values in many types of files and reload them at startup. Search for blog posts describing the various methods for initializing a script.

3. Modules stored in the $env:PsModulePath will auto load. Any module can be loaded by direct full path reference.

I recommend starting by reading and referring to the Sapien blog posts on GUI design and control usage.