如果您的谷歌爲PowerShell Imp,您當前會在列表的頂部找到VBScript-to-Windows PowerShell Conversion Guide。然而,答案是很大的技術幫助:轉換VBScript的Imp運算符
進出口經營
定義:對兩個表達式的邏輯含義。
我們對Imp運算符有什麼瞭解?有兩件事:1)它在Visual Basic .NET中不受支持,2)我們從來沒有聽說過任何人使用它。因此,我們要說的是,是否有Windows PowerShell等價物並不重要。
事實上,我在VBScript中多次使用了Imp
運算符(也寫爲:A→B
),如果它存在的話,可能會在PowerShell中使用它。
例1
我想複製不隱藏,除非它被設置爲存檔(它也需要被複制)的任何文件。
的命令爲這將是這樣的:
If (($File.Attributes -match "Hidden") -imp ($File.Attributes -match "Archive")) {Copy $File}
實施例2
我有一個小命令Log-Entry
用Log-Debug
別名。類似於本地Write-Host
/Write-Debug
函數;當使用Log-Debug
別名時,不提供信息但只在提供公共-Debug
時記錄。 的命令爲這個本來是這樣的:
If (($Noun -eq "Debug") -imp $MyInvocation.BoundParameters.Debug.IsPresent) {Add-content $LogFile $$Entry}
如何建立用最少的代碼邏輯蘊涵算?