locked
Deleted RRS feed

Answers

  • Here is a quick example of how to use a form.

    #form $form = New-Object Windows.Forms.Form $Form.StartPosition = "CenterScreen" $Form.Text = "Create a User" #title $action = { $script:answer = $this.Name Write-Host $answer -fore Green } #first Button: $btn = New-Object Windows.Forms.Button $form.Controls.Add($btn) $btn.Text = "Create a User" $btn.Name = 'User' $btn.Location = '10,10' $btn.Size = '100,20' $btn.DialogResult = 'Ok' $btn.Add_Click($action) #second Button: $btn = New-Object Windows.Forms.Button $form.Controls.Add($btn) $btn.Text = "Show Users" $btn.Name = 'Show' $btn.Location = '10, 40' $btn.Size = '100, 20' $btn.DialogResult = 'Ok' $btn.Add_Click($action) $form.ShowDialog()

    #



    \_(ツ)_/



    • Edited by jrv Saturday, September 24, 2016 8:11 PM
    • Proposed as answer by Hello_2018 Thursday, September 29, 2016 5:02 AM
    • Marked as answer by Hello_2018 Thursday, October 6, 2016 6:35 AM
    Saturday, September 24, 2016 8:10 PM

All replies

  • Yes, that is all possible.

    You'd need to know your way around PowerShell and the AD module to accomplish these tasks.

    There are many threads that you can find in this forum that will help you.

    I also suggest looking through the script repository for starting points:

    http://gallery.technet.microsoft.com/scriptcenter


    • Edited by Mike Laughlin Friday, September 23, 2016 12:38 PM
    • Proposed as answer by Hello_2018 Monday, September 26, 2016 9:31 AM
    Friday, September 23, 2016 12:37 PM
  • Deleted
    • Merged by Mike Laughlin Monday, September 26, 2016 1:36 PM Duplicate
    Saturday, September 24, 2016 11:13 AM
  • Sorry but we cannot write your code for you. 

    Go  here for scripts that will do what you ask: https://gallery.technet.microsoft.com/

    Here are a set of articles that may help: http://www.windowsnetworking.com/articles-tutorials/netgeneral/building-powershell-gui-part1.html


    \_(ツ)_/

    Saturday, September 24, 2016 1:47 PM
  • This blog post has a good example using a button on a form:

    https://technet.microsoft.com/en-us/library/ff730949.aspx

    Basically, you place your code in the Add_Click event and it will run when the user clicks the button. But this is an advanced topic and getting it all to work may not be easy.


    Richard Mueller - MVP Enterprise Mobility (Identity and Access)

    Saturday, September 24, 2016 4:22 PM
  • Deleted
    • Merged by Mike Laughlin Monday, September 26, 2016 1:39 PM Duplicate
    Saturday, September 24, 2016 4:32 PM
  • help new-aduser -full

    Read the examples.


    \_(ツ)_/

    Saturday, September 24, 2016 5:57 PM
  • Deleted
    Saturday, September 24, 2016 6:00 PM
  • What is "Create a User".  You need to write a script to create  user.

    \_(ツ)_/

    Saturday, September 24, 2016 6:02 PM
  • Deleted
    Saturday, September 24, 2016 6:03 PM
  • Just call it like you would any other script.

    \_(ツ)_/

    Saturday, September 24, 2016 6:05 PM
  • Deleted
    • Merged by Mike Laughlin Monday, September 26, 2016 1:16 PM Duplicate
    Saturday, September 24, 2016 7:00 PM
  • Deleted
    Saturday, September 24, 2016 7:49 PM
  • I answered your question three different ways.  Your question is too vague.  If you do not know how to use PowerShell then you will need to take time to learn the basics of running a PowerShell script.  We will not help you one line at a time.

    Start be reading the links that were posted for you.


    \_(ツ)_/

    Saturday, September 24, 2016 7:52 PM
  • Deleted
    Saturday, September 24, 2016 8:06 PM
  • Here is a quick example of how to use a form.

    #form $form = New-Object Windows.Forms.Form $Form.StartPosition = "CenterScreen" $Form.Text = "Create a User" #title $action = { $script:answer = $this.Name Write-Host $answer -fore Green } #first Button: $btn = New-Object Windows.Forms.Button $form.Controls.Add($btn) $btn.Text = "Create a User" $btn.Name = 'User' $btn.Location = '10,10' $btn.Size = '100,20' $btn.DialogResult = 'Ok' $btn.Add_Click($action) #second Button: $btn = New-Object Windows.Forms.Button $form.Controls.Add($btn) $btn.Text = "Show Users" $btn.Name = 'Show' $btn.Location = '10, 40' $btn.Size = '100, 20' $btn.DialogResult = 'Ok' $btn.Add_Click($action) $form.ShowDialog()

    #



    \_(ツ)_/



    • Edited by jrv Saturday, September 24, 2016 8:11 PM
    • Proposed as answer by Hello_2018 Thursday, September 29, 2016 5:02 AM
    • Marked as answer by Hello_2018 Thursday, October 6, 2016 6:35 AM
    Saturday, September 24, 2016 8:10 PM
  • Deleted
    Saturday, September 24, 2016 8:12 PM
  • But I want to give that user a Name and Password too.
    Just explain how I do that?

    mohamedhassan_99@hotmail.com

    Yes.  That is why we posted the links.  They will show you how.  We cannot provide individual training on how to use PowerShell.


    \_(ツ)_/

    Saturday, September 24, 2016 8:24 PM
  • Deleted
    • Merged by Mike Laughlin Monday, September 26, 2016 1:14 PM Duplicate
    Sunday, September 25, 2016 8:53 AM
  • Deleted
    • Merged by Mike Laughlin Monday, September 26, 2016 1:12 PM Duplicate
    Sunday, September 25, 2016 9:14 AM
  • Hi,

    >>and how can I connect then the script with the button?

    I suppose using the intelligent develop tool could be more easier, for instance: Visual Studio and etc.

    Just need to add some OCX then write some clicking events for these buttons and you'll get what you want.

    For instance:

    $AddButton_Click={
        New-ADUser -Name test -Path "ou=xxx,dc=xxx" -Description "xxx" -City -Company -ChangePasswordAtLogon -Country -ErrorAction SilentlyContinue
    }
    $Display_Button_Click = {
        Get-ADUser -Filter *
    }

    Best regards,

    Andy


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.

    Monday, September 26, 2016 7:24 AM