Tinus EngOps Wiki

Logo

OpsaC - Operating as PowerShell code

Links

Home

IT-Wiki

PowerShell Blog

PowerShell Index

PowerShell Search

Additional Websites

View my GitHub Profile

View my GitHub Gists

View my Codeberg Page

View my Photo Website

Yes or No Abfrage

published: July 1, 2016 author: Tinu tags: Regex categories: PowerShell


Mit einer Regex-Auswertung auf Yes oder No abfragen:

$ret = Read-Host 'Would you create a file? [Y] Yes, [N] No'
if($ret -match '^y')
{
    Write-Output "Yes ($($ret))"
}
elseif($ret -match '^n')
{
    Write-Output "No ($($ret))"
}

← Previous Post ◇ [ Top ] ◇ Copyright © 2024 by tinuwalther ◇ [ Blog ] ◇ Next Post →