title: Converting VBScript's Imp Operator
body: <p>If you google for <a href="https://www.google.nl/search?q=PowerShell%20Imp" rel="nofollow noreferrer">PowerShell Imp</a> you currently will find the <a href="https://technet.microsoft.com/library/ee176871.aspx" rel="nofollow noreferrer">VBScript-to-Windows PowerShell Conversion Guide</a> on top of the list. Yet the answer is much of technical help:</p>
  
  <h1><em>Imp Operator</em></h1>
  
  <p><strong><em>Definition:</strong> Performs a logical implication on two expressions.</em></p>
  
  <p><em>What do we know about the Imp operator? Two things: 1) it’s not supported in Visual Basic .NET, and 2) we have never heard of anyone actually using it. Therefore, we’re going to say that it doesn’t really matter whether or not there’s a Windows PowerShell equivalent.</em></p>
  
  <p>In fact, I used the <code>Imp</code> operator (also written as: <code>A→B</code>) a  number of times in VBScript and likely would have used it in PowerShell if it existed.</p>
  
  <h1>Example 1</h1>
  
  <p>I want to copy any file that is not hidden except if it is set to be archived (it also needs to be copied).<br>
  A command for this would have been something like:</p>
  
  <pre><code>If (($File.Attributes -match "Hidden") -imp ($File.Attributes -match "Archive")) {Copy $File}
  </code></pre>
  
  <h1>Example 2</h1>
  
  <p>I have a <code>Log-Entry</code> cmdlet with a <code>Log-Debug</code> alias. Similar to the native <code>Write-Host</code>/<code>Write-Debug</code> functions; when the <code>Log-Debug</code> <em>alias</em> is used, the information not be revealed but only be recorded when the common <code>-Debug</code> is supplied.
  A command for this would have been something like:</p>
  
  <pre><code>If (($Noun -eq "Debug") -imp $MyInvocation.BoundParameters.Debug.IsPresent) {Add-content $LogFile $$Entry}
  </code></pre>
  
  <p>How can I build a logical implication operator with a minimum of code?</p>