运行if语句时,PowerShell 会将<test1>条件表达式计算为 true 或 false。 如果<test1>为 true,<statement list 1>则运行,PowerShell 退出 语句if。 如果<test1>为 false,则 PowerShell 将计算条件语句指定的<test2>条件。 有关布尔计算的详细信息,请参阅about_Booleans。
# This expression returns true if the pattern matches big, bog, or bug. 'big' -match 'b[iou]g' 如果要比對的字元清單包含連字元字元 (-),它必須位於清單的開頭或結尾,才能與字元範圍表達式區別。字元範圍模式也可以是字元範圍。 這些字元可以是字母 [A-Z]、數位 [0-9],或甚至...
# Changes the color of the commands in the Console pane to red and then restores it to its default value.$psISE.Options.ConsoleTokenColors["Command"] ='red'$psISE.Options.RestoreDefaultConsoleTokenColors() RestoreDefaults() 在Windows PowerShell ISE 2.0 及更高版本中受支持。
dynamicparam {<statement-list>}在语句列表中,使用 if 语句指定函数中提供参数的条件。以下示例显示了一个函数,其标准参数名为 Name 和Path,并具有一个名为 KeyCount的可选动态参数。 KeyCount 参数位于 ByRegistryPath 参数集中,其类型为 Int32。 仅当 Path 参数的值以 HKLM:开头时,KeyCount 参数...
The keys in a hashtable can be any .NET type. The following statement adds a key-value pair to the hashtable in the $p variable. The key is a Service object that represents the WinRM service, and the value is the current status of the service. PowerShell Copy $p = $p + @{ ...
To add statements to the function, type each statement on a separate line, or use a semicolon;to separate the statements. For example, the following function finds all.jpgfiles in the current user's directories that were changed after the start date. ...
If the statement is used to evaluate the condition. If the condition succeeds then block statement runs. You can specify more than one or more conditions in If statement, depending upon the operators used (comparison, Boolean, bitwise) statement evaluates condition. ...
Quickly learn tips, shortcuts, and common operations in Windows Powershell 4.0, Windows PowerShell Desired State Configuration, Windows PowerShell Workflow, Windows PowerShell ISE, Windows PowerShell Web Access, Server Manager for Windows Server 2012 R2,
The search criteria for the Get-MailboxImportRequest cmdlet is a Boolean And statement. If you use multiple parameters, you narrow your search and reduce your search results. You need to be assigned permissions before you can run this cmdlet. Although this topic lists all parameters for the ...
When you use this switch with the TargetMailbox parameter, messages are copied to the target mailbox and removed from the source mailbox. If you set the logging level for the search to Basic or Full, you must specify a target mailbox and a target folder to place the log in. To delete...