title: Powershell Try Catch and retry?
body: <p>I have this script</p>
  
  <pre><code>#Change hostname
  [void][System.Reflection.Assembly]::LoadWithPartialName('Microsoft.VisualBasic') 
  Write-Host "Change hostname " -NoNewLine
  $ComputerName = [Microsoft.VisualBasic.Interaction]::InputBox('Insert the desired computername:', 'Change hostname') 
  Write-Host "- DONE" -ForegroundColor DarkGreen -BackgroundColor green -NoNewline
  Write-Host " hostname = $ComputerName "
  Rename-Computer -NewName $ComputerName
  </code></pre>
  
  <p>when the computer name gets spaces, it fails cause a hostname cant have spaces.
  Can i block the form to have any spaces or does anyone knows how to get back to the inputbox when a error has been created for a re-try</p>