> For the complete documentation index, see [llms.txt](https://documentation.2pintsoftware.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://documentation.2pintsoftware.com/deployr/1.2/powershell-modules/simple-prompt-for-computer-name.md).

# Simple Prompt for Computer Name

This is a quick example on how to create a simple prompt for a computer name at the start of the task sequence.

Create the following **Run PowerShell script** step at the start of the task sequence before the **Apply OS** step (adjust the timeout value accordingly):&#x20;

<figure><img src="https://content.gitbook.com/content/ur9yOUrYi6pb5j4W4O2R/blobs/lISATVCSsC4Lc4PdsaxV/image.png" alt=""><figcaption></figcaption></figure>

```
function Show-InputPopup {
    <#
    .SYNOPSIS
        Displays a simple popup dialog with a question and text input field.
    
    .DESCRIPTION
        Creates a Windows Forms popup that asks a question and returns the user's text input.
    
    .PARAMETER Message
        The question or message to display in the popup.
    
    .PARAMETER Title
        The title of the popup window. Defaults to "Input Required".
    
    .PARAMETER DefaultValue
        Optional default value to pre-populate in the text box.
    
    .EXAMPLE
        $userName = Show-InputPopup -Message "What is your name?"
        Write-Host "Hello, $userName!"
    
    .EXAMPLE
        $version = Show-InputPopup -Message "Enter the version number:" -Title "Version Input" -DefaultValue "1.0.0"
    #>
    [CmdletBinding()]
    param(
        [Parameter(Mandatory)]
        [string]$Message,
        
        [Parameter()]
        [string]$Title = "Input Required",
        
        [Parameter()]
        [string]$DefaultValue = ""
    )
    
    Add-Type -AssemblyName System.Windows.Forms
    Add-Type -AssemblyName System.Drawing
    
    # Create the form
    $form = New-Object System.Windows.Forms.Form
    $form.Text = $Title
    $form.Size = New-Object System.Drawing.Size(400, 180)
    $form.StartPosition = 'CenterScreen'
    $form.FormBorderStyle = 'FixedDialog'
    $form.MaximizeBox = $false
    $form.MinimizeBox = $false
    $form.TopMost = $true
    
    # Create the label
    $label = New-Object System.Windows.Forms.Label
    $label.Location = New-Object System.Drawing.Point(10, 20)
    $label.Size = New-Object System.Drawing.Size(370, 40)
    $label.Text = $Message
    $form.Controls.Add($label)
    
    # Create the text box
    $textBox = New-Object System.Windows.Forms.TextBox
    $textBox.Location = New-Object System.Drawing.Point(10, 70)
    $textBox.Size = New-Object System.Drawing.Size(360, 20)
    $textBox.Text = $DefaultValue
    $form.Controls.Add($textBox)
    
    # Create OK button
    $okButton = New-Object System.Windows.Forms.Button
    $okButton.Location = New-Object System.Drawing.Point(210, 105)
    $okButton.Size = New-Object System.Drawing.Size(75, 25)
    $okButton.Text = 'OK'
    $okButton.DialogResult = [System.Windows.Forms.DialogResult]::OK
    $form.AcceptButton = $okButton
    $form.Controls.Add($okButton)
    
    # Create Cancel button
    $cancelButton = New-Object System.Windows.Forms.Button
    $cancelButton.Location = New-Object System.Drawing.Point(295, 105)
    $cancelButton.Size = New-Object System.Drawing.Size(75, 25)
    $cancelButton.Text = 'Cancel'
    $cancelButton.DialogResult = [System.Windows.Forms.DialogResult]::Cancel
    $form.CancelButton = $cancelButton
    $form.Controls.Add($cancelButton)
    
    # Set focus to text box
    $form.Add_Shown({ $textBox.Select() })
    
    # Show the form and return the result
    $result = $form.ShowDialog()
    
    if ($result -eq [System.Windows.Forms.DialogResult]::OK) {
        return $textBox.Text
    }
    else {
        return $null
    }
}


$Prompt = "Input computer name:"
$ComputerName = Show-InputPopup -Message $prompt -Title "Computer Name"

if ($ComputerName) {
    #Pull Vars from TS:
    try {
        Import-Module DeployR.Utility
    }
    catch {}
    if (Get-Module -name "DeployR.Utility"){
        ${TSEnv:ComputerName} = $ComputerName
        Write-Host "Setting computer name to: $tsenv:ComputerName"
    }
}

```

This will display the following during the running task sequence:

<figure><img src="https://content.gitbook.com/content/ur9yOUrYi6pb5j4W4O2R/blobs/KeTEYxJQ32VsktvfNdpB/image.png" alt=""><figcaption></figcaption></figure>

**NOTE**: This does not do any error checking on allowed computer names or lengths.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://documentation.2pintsoftware.com/deployr/1.2/powershell-modules/simple-prompt-for-computer-name.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
