title: is it possible to get input from the powershell script which is called as process?
body: <p>We have one PowerShell script file(.ps1) which ask user to provide input from PowerShell console and pass as an argument to another PowerShell script file(.ps1), this script file also ask for input from the user. for getting input we are using &quot;<em><strong>Read-Host</strong></em>&quot;</p>
  <p>Below is the code snippet, while executing below code it is not asking input from the test2 script and process is stuck/pause.</p>
  <p>can some help me how to achieve this use case ?</p>
  <p>Code
  <strong>Test1.ps1</strong></p>
  <pre><code>[System.String] $ScriptPath = Split-Path -Parent $MyInvocation.MyCommand.Path
  
       $new_ip = Read-Host -Prompt &quot;Enter IP&quot;
      if([string]::IsNullOrWhiteSpace($new_ip))
      {
       $pinfo = New-Object System.Diagnostics.ProcessStartInfo
       $pinfo.FileName = &quot;PowerShell.exe&quot;
       $pinfo.RedirectStandardError = $true
       $pinfo.RedirectStandardOutput = $true
       $pinfo.UseShellExecute = $false
       $pinfo.WindowStyle = 'Hidden'
       $pinfo.CreateNoWindow = $True
       $pinfo.Arguments = &quot;-file `&quot;$ScriptPath\Test2.ps1`&quot; -ServerIP `&quot;$new_ip`&quot;&quot;
       $p = New-Object System.Diagnostics.Process
       $p.StartInfo = $pinfo
       $p.Start() | Out-Null
       $stderr = $p.StandardError.ReadToEnd()
       $stdout = $p.StandardOutput.ReadToEnd()
       $p.WaitForExit()
      
          
          if (![string]::IsNullOrEmpty($stderr))
           {
              Write-Warning &quot;stderr: $stderr&quot;
           }
           if($p.ExitCode -ne 0)
           {
              $isValidIP = $false
              Write-Warning &quot; failed, Check above message&quot;
            }
            else
            {
               Write-Host $stdout
               $isValidIP = $true
               Write-Host &quot;Configured successfully&quot;
            }
      }
      
      
      **Test2.ps1**
      
      Param([String]$ServerIP = $null
          )
      
      Write-Host &quot;Server IP:&quot;$ServerIP
      
      $SqlServerIP = (Read-Host -prompt &quot;Enter Sql Server IP address (Default : localhost) &quot;)
      Write-Host &quot;Server IP:&quot;$SqlServerIP 
  </code></pre>