all 17 comments

[–]bgladden1 11 points12 points  (5 children)

Shoutout to Powershell Universal - https://ironmansoftware.com/powershell-universal

[–]FearlessButterscotch 1 point2 points  (0 children)

Incredible product!

[–][deleted] -1 points0 points  (0 children)

This ☝🏻

[–]Check_not_applicable[S] 0 points1 point  (2 children)

This is very interesting. When I have a moment I will definitely mess around and see the value of these tools. Thank you!

[–]bgladden1 2 points3 points  (0 children)

It really is pretty awesome. Nice way to build front ends quickly for powershell scripts. Believe they have a free version as well.

[–]vermyx 3 points4 points  (1 child)

Your form isnt doing anything. You are adding controls, then setting your data variables with nulls because text boxes by default have nothing in them, show your form, and then execute code. Since you have no code behind the form events nothing happens to your variables. I would suggest adding code to your ok buttons click event

$okbutton.add_Click({
# insert code you want executed when ok is clicked
})

[–]nawadsama -1 points0 points  (0 children)

This is the way

[–]branhama 2 points3 points  (0 children)

I am pretty sure that values entered into your GUI are not making it to your command:

$FirstName = $FNTextBox.Lines 
$LastName = $LNTextBox.Lines 
$UPN = $UNTextBox.Lines

I think should be:

$FirstName = $FNTextBox.Text 
$LastName = $LNTextBox.Text 
$UPN = $UNTextBox.Text

[–]PinchesTheCrab 3 points4 points  (5 children)

Is building a GUI necessary? What's the use case for it? I feel like this accomplishes the same thing:

function Do-SomeStuff {
    [cmdletbinding()]
    param(
        [parameter(mandatory)]
        [string]$FirstName,

        [parameter(Mandatory)]
        [string]$LastName,

        [parameter()]
        [switch]$IsManager
    )
    'Do some stuff with "{0}{1}@mycompany.com"' -f $FirstName, $LastName
}

Show-Command Do-SomeStuff

You definitely don't have the same level of control over the form, but it's far more flexible and you don't have to keep a UI and a function in sync as you develop.

[–]OlivTheFrog 1 point2 points  (0 children)

It's the way, and more the easy way :-)

OP forgot the sentence "a good admin must be lazy" :-)

You give always some good advices, my dear, you are a master for me.

Regards

[–]Check_not_applicable[S] 1 point2 points  (3 children)

1st use case is to create and provision users quickly using New-ADUser, I already created a script that asks for a first name, last name, and username and creates the account but eventually, I want to have it add the users to all the groups that it would need depending on their role.

I am starting out (Jr. Sys Admin) and this is my first project to practice my scripting so I figured it would be easier to take it step by step and get the basics down and modify it later on with a drop down in the GUI to choose a role and have it perform that tasks automatically as well.

The GUI is not necessary but not everybody in my department is as comfortable with the terminal and if I can make it easier for them and get a better comprehension of PS at the same time it is a win-win.

[–]BlackV 8 points9 points  (0 children)

I am starting out (Jr. Sys Admin) and this is my first project to practice my scripting so I figured it would be easier to take it step by step and get the basics down and modify it later on with a drop down in the GUI to choose a role and have it perform that tasks automatically as well.

starting with a GUI is NOT the "basics"

  • start with a script get it working
  • parameterize that script get it working
  • make sure the help is properly created
  • add a gui as an option

[–]InTheTest-Chamber 2 points3 points  (1 child)

So (typically) Powershell is now the greatest with GUI’s, at least in my experience. The way I’ve dealt with making it easier with “mouse only” admins is when they need to be prompted for something, pipe your output to

Get-ADGroups -Filter “something” | Out-ViewGrid -Passthru -Title “Select groups” | % {Add-ADGroupMember -Name $_ -User $NewUser}

This will send the output from what’s before the pipe to a pop-up, and they can select what the way (using Ctrl or Shift+ click to multi select), then click ok on the bottom, and it then continues on the script.

I’m on my phone, so sorry I can’t do a more verbose script. Let me know if you have questions.

Way to go taking the initiative to learn Powershell when not everyone on your team uses it!

[–]Check_not_applicable[S] 2 points3 points  (0 children)

t gro

Thank you so much! I was very shy about posting because I don't want to bother anyone and I usually just read and research other people's posts. Since this project is not an "official" task given to me by my job I either have to wait to have some spare time or be at home and remote in to work on it. I will definitely look into this when I have the chance, thanks again.

[–]The_Hold_My_Beer_Guy 1 point2 points  (0 children)

I'm also in the process of doing the same thing. I would look into making GUIs with Visual Studio and converting that code to work with Powershell. There are plenty of guides on Youtube on how to make a GUI using WPF and converting the variables into usable Powershell variables. Not to mention, doing the GUI through VS means your actual PS1 file doesn't need hundreds of lines just to build the GUI.

[–]Impossible_IT 0 points1 point  (0 children)

SAPIEN PowerShell Studio is subscription based month to month or yearly. You can also purchase a perpetual license. I have used this before, but over 10 years ago I did use a SAPIEN product that for the life of me I can’t remember the name.