← All Articles

How to Read Program Arguments in PowerShell

Posted on

I don’t know much about PowerShell to be honest. It sounds to me like it is some kind of a windows version of bash/zsh. Nevertheless, IISResetMe wrote up a quick hello arguments script - and let me share it with you:

if($args.Count -lt 2){
  throw [System.ArgumentException]"Please supply 2 or more arguments!"
}

$args |ForEach-Object {
  Write-Host "Hello $_"
}
polyglotbitspowershellread-program-arguments