<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>SupportsShouldProcess Archives - the Sysadmin Channel</title>
	<atom:link href="https://thesysadminchannel.com/tag/supportsshouldprocess/feed/" rel="self" type="application/rss+xml" />
	<link>https://thesysadminchannel.com/tag/supportsshouldprocess/</link>
	<description>Documenting My Life as a System Administrator</description>
	<lastBuildDate>Wed, 06 Jan 2021 07:13:54 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.8.3</generator>
<site xmlns="com-wordpress:feed-additions:1">144174110</site>	<item>
		<title>ShouldContinue vs ShouldProcess: What&#8217;s The Difference?</title>
		<link>https://thesysadminchannel.com/shouldcontinue-vs-shouldprocess-whats-the-difference/</link>
					<comments>https://thesysadminchannel.com/shouldcontinue-vs-shouldprocess-whats-the-difference/#respond</comments>
		
		<dc:creator><![CDATA[Paul Contreras]]></dc:creator>
		<pubDate>Tue, 06 Oct 2020 06:58:03 +0000</pubDate>
				<category><![CDATA[Powershell]]></category>
		<category><![CDATA[Powershell advanced functions]]></category>
		<category><![CDATA[ShouldContinue vs ShouldProcess]]></category>
		<category><![CDATA[SupportsShouldProcess]]></category>
		<guid isPermaLink="false">https://thesysadminchannel.com/?p=2691</guid>

					<description><![CDATA[<p>ShouldContinue vs ShouldProcess: What&#8217;s the difference? If you&#8217;re writing advanced functions and using the SupportsShouldProcess CmdletBinding parameter you should be aware of the difference between these 2 options. While they may seem subtle on the outside, they may have some&#8230; <a href="https://thesysadminchannel.com/shouldcontinue-vs-shouldprocess-whats-the-difference/" class="more-link">Continue Reading <span class="meta-nav">&#8594;</span></a></p>
<p>The post <a href="https://thesysadminchannel.com/shouldcontinue-vs-shouldprocess-whats-the-difference/">ShouldContinue vs ShouldProcess: What&#8217;s The Difference?</a> appeared first on <a href="https://thesysadminchannel.com">the Sysadmin Channel</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>ShouldContinue vs ShouldProcess: What&#8217;s the difference?  If you&#8217;re writing advanced functions and using the SupportsShouldProcess CmdletBinding parameter you should be aware of the difference between these 2 options. While they may seem subtle on the outside, they may have some impact on your automation if not used properly.</p>
<p>One thing I should note as well is that this addition now allows your commands to utilize the -Confirm and -Whatif parameters that can be used for testing.</p>
<h2>ShouldContinue vs ShouldProcess</h2>
<p>Here are few highlights for each item that are worth mentioning.</p>
<h3>ShouldContinue</h3>
<ul>
<li>Used to prompt the user by default</li>
<li>Needs a Force parameter added to avoid syntax errors in VSCode</li>
<li>Requires at least 2 messages for the prompts</li>
</ul>
<h3>ShouldProcess</h3>
<ul>
<li>Will NOT prompt user by default</li>
<li>Confirm parameter must be used to prompt for action</li>
<li>Requires at least 1 message for the prompts</li>
</ul>
<h3>Example Code Snippet</h3>
<pre class="brush: powershell; title: ; notranslate">

function Test-SupportsShouldProcess {
    [CmdletBinding(
        SupportsShouldProcess,
        ConfirmImpact='Medium'
    )]
    param(
        [Parameter(
            Mandatory = $false
        )]
        [switch]    $ShouldContinueParam,

        [switch]    $ShouldProcessParam,

        [switch]    $Force

    )

    if ($ShouldContinueParam) {
        if ($Force -or $PSCmdlet.ShouldContinue(&quot;Would you like to continue&quot;, &quot;Should Process Testing&quot;)) {
            Write-Output ''
            Write-Output 'Should continue has been called with the force parameter or typed &quot;Y&quot; when prompted'
        }
    }

    if ($ShouldProcessParam) {
        if ($PSCmdlet.ShouldProcess(&quot;Should Process Testing&quot;) ) {
            Write-Output ''
            Write-Output 'Should Process has been called and should only be prompted with the confirm parameter'
        }
    }
}


</pre>
<p>&nbsp;</p>
<p><a href="https://thesysadminchannel.com/wp-content/uploads/2021/01/SupportsShouldProcess-ShouldContinue.png" target="_blank" rel="noopener noreferrer"><img decoding="async" src="https://thesysadminchannel.com/wp-content/uploads/2021/01/SupportsShouldProcess-ShouldContinue.png" alt="SupportsShouldProcess ShouldContinue" width="850" height="auto" class="aligncenter size-full wp-image-2696" /></a></p>
<p>&nbsp;</p>
<p><a href="https://thesysadminchannel.com/wp-content/uploads/2021/01/SupportsShouldProcess-ShouldProcess.png" target="_blank" rel="noopener noreferrer"><img decoding="async" src="https://thesysadminchannel.com/wp-content/uploads/2021/01/SupportsShouldProcess-ShouldProcess.png" alt="SupportsShouldProcess ShouldProcess" width="850" height="auto" class="aligncenter size-full wp-image-2697" srcset="https://thesysadminchannel.com/wp-content/uploads/2021/01/SupportsShouldProcess-ShouldProcess.png?v=1609910294 806w, https://thesysadminchannel.com/wp-content/uploads/2021/01/SupportsShouldProcess-ShouldProcess-768x313.png?v=1609910294 768w" sizes="(max-width: 806px) 100vw, 806px" /></a></p>
<h2>Conclusion</h2>
<p>I hope this has cleared up some questions regarding ShouldContinue vs ShouldProcess and how to use each.  If you&#8217;re up for it, feel free to check out our other <a href="https://thesysadminchannel.com/powershell/" rel="noopener noreferrer" target="_blank">Powershell Scripts</a> since there are plenty there to use out in the real world.</p>
<p>Also, <a href="https://www.youtube.com/c/theSysadminChannel" rel="noopener noreferrer" target="_blank">@theSysadminChannel</a> on Youtube can be useful if you&#8217;re looking for free sysadmin video content on the internets.</p>
<p>The post <a href="https://thesysadminchannel.com/shouldcontinue-vs-shouldprocess-whats-the-difference/">ShouldContinue vs ShouldProcess: What&#8217;s The Difference?</a> appeared first on <a href="https://thesysadminchannel.com">the Sysadmin Channel</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://thesysadminchannel.com/shouldcontinue-vs-shouldprocess-whats-the-difference/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">2691</post-id>	</item>
	</channel>
</rss>
