test vs confirm, which verb to choose?
-
Wednesday, May 02, 2012 11:09 AM
I would like to understand the diffrence between Test and Confirm verbs used by powershell cmdlets.
If anyone can also present examples that strictly show it, I'll be more than grateful
What I mean, if I want to check existance of something or correct configuration of it and return true or false which verb is more appropriate?- Edited by BlindroodMicrosoft Community Contributor Wednesday, May 02, 2012 11:11 AM
All Replies
-
Wednesday, May 02, 2012 12:57 PM
Test is used to confirm the existence of or verify a condition, good examples of this are:
Test-Connection
PowerShell version of Ping, verifies if a system responds to ping
Test-Path
As it says, tests for the existence of an object (file/folder/reg key/...)
Confirm is used in a different context, whether or not you want a command to execute without prompting. For example:
Remove-Item $Pathtofileorfolder -Confirm
Will prompt for confirmation before executing the command.
So to answer your question at the end, Test is the verb you are looking for.
-
Wednesday, May 02, 2012 1:12 PM
I know confirm parameter but official verbs list that can be used with powershell cmdlets contains 'confirm'
So to be specific, my question is: when to use confirm instead of test? An example would be great
-
Wednesday, May 02, 2012 2:17 PMModerator
?
Confirm means the action will happen if the user consents.
Test only shows what would happen without doing it.
Bill
-
Wednesday, May 02, 2012 2:33 PM
I think we're still talking about confirm parameter :)
You can create cmdlet Test-Something but You can also create cmdlet Confirm-Something (according to official verbs list)
What I want to know is when it is appropriate to use first and when to use second option
-
Wednesday, May 02, 2012 2:50 PMModerator
Hi,
Confirm is a lifecycle verb, not a common verb. It is not one of the verbs used to define a cmdlet name (these are called common verbs). See the Cmdlet Verbs help topic.
Bill
- Proposed As Answer by Bill_StewartMicrosoft Community Contributor, Moderator Thursday, May 03, 2012 6:14 PM
- Marked As Answer by Richard MuellerMVP, Moderator Monday, May 14, 2012 1:29 AM
-
Wednesday, May 02, 2012 3:03 PM
can I ask why? :)
I just don't get it. Start/Stop are lifecycle verbs and are used for cmdlets (service,process etc.) we also have wait-process, invoke-command
so why is confirm so specific that 'it is not one of the verbs used to define a cmdlet name' ??and if it isn't, why it is on a officiall verbs list?
-
Wednesday, May 02, 2012 3:17 PMModerator
Hi,
That's knowledge to be gained by reading the developer documentation.
Bill
-
Tuesday, May 08, 2012 1:22 AMModerator
Per the link Bill provided, my guess is that Confirm could be used as a verb for a cmdlet, but has not (as yet). Same for Assert and Request in the same category.
Richard Mueller - MVP Directory Services
-
Tuesday, May 08, 2012 3:25 AM
Test - positive assertive action. "Test your powder before going to battle!"
Confirm - a query about readiness. "Please 'confirm' that you have sufficient cajones for the battle ahead"
Subtle but oh so different.
Confirm is more likely to be used as a filter.
dir c:\*.* -recurse | Confirm-Action | Remove-Item
Kids! Don't try this at home. The stunts you see here are all done by trained professionals.
;)
¯\_(ツ)_/¯
- Edited by jrvMicrosoft Community Contributor Tuesday, May 08, 2012 3:30 AM
-
Monday, May 14, 2012 1:30 AMModerator
As there has been no activity in this thread for a few days, we assume the issue is resolved. We will mark it as "answered" to assist others in similar situations. If you disagree, please reply with further information. You can unmark the answer if you wish. If a reply helped answer your question, please mark it as the answer.
Richard Mueller - MVP Directory Services

