Prompt text box and store input in variable

Welcome Forums General PowerShell Q&A Prompt text box and store input in variable

This topic contains 2 replies, has 2 voices, and was last updated by

 
Participant
3 years, 2 months ago.

  • Author
    Posts
  • #31796

    Participant
    Points: 18
    Rank: Member

    I currently have a script to approve requests for applications in SCCM. Instead of having the text "Request approved" below, I would like the "approve" action to prompt a text box where the user can put in some text, select OK, and store it in a variable that will go in the same place that "Request approved" previously was. FYI – $button1 is the "Approve" button.

    function Set-ApprovalRequest {
        param (
        [string]$Action
        )
    $User = $comboBox1.SelectedItem
    If ($Action -eq "Approve") {
         $ApplAppr = Get-WmiObject -Class SMS_UserApplicationRequest -Namespace root/SMS/site_$($SiteCode) -ComputerName $SiteServer | Where-Object -FilterScript {$_.User -eq $User} | Where-Object -FilterScript {$_.Application -eq $ApplName}
         $ApplAppr.Approve('Request approved')
         }
    }
    
    $button1_OnClick= {
            $Action = "Approve"
            Set-ApprovalRequest $Action
    }
  • #31851

    Participant
    Points: 18
    Rank: Member

    Any ideas?

  • #31853

    Participant
    Points: 0
    Rank: Member

    well, it looks like you are using windows forms, why not just add a textbox in the form for the user to fill in?

The topic ‘Prompt text box and store input in variable’ is closed to new replies.