Input selection using powershell -
i relatively new powershell .how can provide user selection scenario in powershell ?. able write script getting parameters user having them type instead of letting them select given options . below scenario
env: 1) staging 2) prod selection: select action perform: 1) foo 2) bar selection: schedule or leave blank schedule (yyyy-mm-dd hh:mm:ss): note (leave blank skip): plan of action: >> sending action to: >> scheduling action of: >> schedule date: >> notes: ok proceed? (y|n):
any in pointing me in right direction appreciated. time
this should started.
function do-stuff { param($environment,$action,$schedule,$note) <# logic #> } $splat = @{ environment=''; action=''; schedule=''; note=''; } write-host "env:`r`n`t1) staging`r`n`t2) prod`r`nselection:" $splat.environment = read-host write-host "select action perform:`r`n`t1) foo`r`n`t2) bar`r`nselection:" $splat.action = read-host write-host "schedule or leave blank schedule (yyyy-mm-dd hh:mm:ss):" $splat.schedule = read-host write-host "note (leave blank skip):" $splat.note = read-host write-host @" plan of action: >> sending action to: $($splat.environment) >> scheduling action of: $($splat.action) >> schedule date: $($splat.schedule) >> notes: $($splat.note) ok proceed? (y|n):"@ $agree = read-host if ($agree.toupper() -eq 'y') { do-stuff @splat }
Comments
Post a Comment