User Confirmation in Powershell

Built-in cmdlets usually offer the -Confirm parameter whenever you need user confirmation. When writing your own scripts, you might want to ask the eventual user of the script for confirmation yourself. This handy little function (store it in your profile!) allows you to ask for confirmation whenever, where-ever. (Try not to bug your users too much.)

# Description: Ask a user to answer a question with either yes or no.

# Example use: 
# If (Ask-YesOrNo)
# 	{ 
#	# User has confirmed
#	...
#	}
#	Else
#	{
#	# User did not confirm
#	...
#	}

Function Ask-YesOrNo
	{
	param([string]$title="Confirm",[string]$message="Are you sure?")
	$choiceYes = New-Object System.Management.Automation.Host.ChoiceDescription "&Yes", "Answer Yes."
	$choiceNo = New-Object System.Management.Automation.Host.ChoiceDescription "&No", "Answer No."
	$options = [System.Management.Automation.Host.ChoiceDescription[]]($choiceYes, $choiceNo)
	$result = $host.ui.PromptForChoice($title, $message, $options, 1)
		switch ($result)
    	{
			0 
			{
			Return $true
			}
	     
			1 
			{
			Return $false
			}
		}
	}
new stadium is real gameMine was attention disorder. However, Favre could not function on the injured ankle that proved to be the difference.. Cells were washed as before with a final wash in 1X PBS alone. Miranda Kerr (top right) is making money from her natural skincare range, while Elle Macpherson (second top right), Gisele Bundchen (center) and Heidi Klum (second left) have raked in the cash from lingerie lines. “The NFL Commissioner has been saying that they take allegations of violence against women seriously and they indicate that they are turning over a new leaf, but here, even though a rape allegation should have been reported to http://www.foakleysaaaa.com them it was not and what are they doing about that?”. 21st Century Fox is a global media corporation and one of two companies created through the split of Fake ray bans Rupert Murdoch’s News Corporation in 2013. I think that’s our moment.”Now, there’s a difference being physical and being reckless. An astute businesswoman too, having founded her own theme park, Dollywood, a radio station, restaurants, and record and TV companies. The two media outlets were initially working in concert but ESPN pulled its branding from the project in wholesale china jerseys September. And while he never joined the military, in 1936, he was given the title of honorary Kentucky Colonel by the governor in recognition of his contribution to the state’s cuisine.. Playoffs for NFL is held until January while the Super http://www.cheapjerseys-nfl.com Bowl is usually played in the first week of February, thus covering a wide range of weather conditions, from the heat and humidity of late summer, to the cold winds and snow in mid winter. A strain of the hip flexor made up of three muscles found mostly on the front of the hip, including a Cheap NFL Jerseys quadriceps muscle called the “rectus femoris” can be caused by not stretching, or simply by overuse, Smith says. Supergirl was the best premiere of any new show on television in viewers and key demos and Life in Pieces is the number one new comedy. On 3rd and 18, Raiders quarterback Ken Stabler threw an incomplete pass. At no time did the players’ association and the league come together and agree that a man should sit out one fourth http://cheapjerseysupply.com of a season if he’s found to have let the air out of some footballs. The unnamed teammate had a prescription for the drug. The http://www.cheapnfljerseyssu.com troll was sculpted and built later that year by four local artists: Steve Badanes, Will Martin, Donna Walter, and Ross Whitehead. But most Food Network chefs prefer to be at home yelling at the TV during the game..

1 thought on “User Confirmation in Powershell”

Leave a Reply