# Simple Prompt for Computer Name

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="/files/qcpVqlaLuyeQNfj3OfwF" 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="/files/tzplxQSxVec1paaQ4JG4" alt=""><figcaption></figcaption></figure>

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


---

# Agent Instructions: Querying This Documentation

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

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

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

The question should be specific, self-contained, and written in natural language.
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.
