在变量前加上类型可以规定变量只能存储该类型的值,若后续给变量赋不能转换为该类型的数值,则出错,例如[int]$x = 1就把$x的类型限制为int,若后续执行命令$x = "a"则出错,因为字符串"a"无法转换为整数。 也可以通过New-Variable定义变量,有如下几种方式: New-Variable<变量名>#变量名不带“$”New-Variable...
= null) { result.Path = path.Path; result.LineNumber = lineNumber; WriteObject(result); } else { // Add the block(line) that did not match to the // collection of non matches , which will be stored // in the SessionState variable $NonMatches nonMatches.Add(items[0]); } ...
get-moduleModuleType Version Name ExportedCommands---Manifest3.1.0.0Microsoft.PowerShell.Management {Add-Computer,Add-Content,Checkpoint-Computer,Clear-Con... Manifest3.1.0.0Microsoft.PowerShell.Utility {Add-Member,Add-Type,Clear-Variable,Compare-Object...} Manifest1.0.0.0NetTCPIP {Find-NetRoute,Get-...
but you can't use wildcard characters to find the names of function help and script help articles. To get help for a script that isn't located in a path that's listed in the `$env:Path` environment variable, type the script's path and file name. If you enter the exact name of ...
$MyVariable Output 複製 The green cat. 若要刪除變數的值,請使用 Clear-Variable Cmdlet 或將值變更為 $null。 PowerShell 複製 Clear-Variable -Name MyVariable PowerShell 複製 $MyVariable = $null 若要刪除變數,請使用 Remove-Variable 或Remove-Item。 PowerShell 複製 Remove-Variable -Name...
可以在远程命令中使用局部变量,但必须在本地会话中定义该变量。 从PowerShell 3.0 开始,可以使用Using范围修饰符在远程命令中标识局部变量。 的Using语法如下所示: 复制 $Using:<VariableName> 在以下示例中$ps,变量在本地会话中创建,但在运行命令的会话中使用。 范围Using修饰符标识$ps为局部变量。
Variable Alias shcm -> Show-Command Alias si -> Set-Item Alias sl -> Set-Location Alias sleep -> Start-Sleep Alias sls -> Select-String Alias sort -> Sort-Object Alias sp -> Set-ItemProperty Alias spjb -> Stop-Job Alias spps -> Stop-Process Alias spsv -> Stop-Service Alias ...
Windows PowerShell 3.0 包含現有 Cmdlet (包括簡化語法) 的新功能,以及下列 Cmdlet 的新參數:Computer Cmdlet、CSV Cmdlet、Get-ChildItem、Get-Command、Get-Content、Get-History、Measure-Object、Security Cmdlet、Select-Object、Select-String、Split-Path、Start-Process、Tee-Object、Test-Connection、Add-Member ...
Cmdlet Add-Member Add-Member [-MemberType] <PSMemberTypes> [-Name]... Cmdlet Add-PSSnapin Add-PSSnapin [-Name] <String[]> [-PassThru] [-Ve... Cmdlet Clear-Content Clear-Content [-Path] <String[]> [-Filter <Strin... Cmdlet Clear-Item Clear-Item [-Path] <String[]> [-Force] [...
Windows PowerShell reserves a few parameter names, referred to as Common parameters, which you can't use: WhatIf, Confirm, Verbose, Debug, ErrorAction, ErrorVariable, OutVariable, and OutBuffer. In addition, the following aliases for these parameter names are reserved: vb, db, ea, ev, ov...