Remove-Variable cmdlet 从定义变量的范围中删除变量及其值,例如当前会话。 不能使用此 cmdlet 删除设置为常量或系统拥有的变量。
1. 使用Remove-Variable命令: Remove-Variable -Name 变量名 该命令会删除指定变量的值和名称。 2. 使用Clear-Variable命令: Clear-Variable -Name 变量名 该命令会清除指定变量的值,但保留变量的名称。 3. 使用Set-Variable命令赋予变量一个空值: Set-Variable -Name 变量名 -Value $null 该命令将指定变量的值...
Remove-Variable 參考 意見反應 模組: Microsoft.PowerShell.Utility 刪除變數及其值。 Syntax PowerShell 複製 Remove-Variable [-Name] <String[]> [-Include <String[]>] [-Exclude <String[]>] [-Force] [-Scope <String>] [-WhatIf] [-Confirm] [<CommonParameters>] Description Remove-Variable ...
若要刪除變數,請使用Remove-Variable或Remove-Item。 PowerShell Remove-Variable-NameMyVariable PowerShell Remove-Item-PathVariable:\MyVariable 您也可以使用一個語句將值指派給多個變數。 下列範例會將相同的值指派給多個變數: PowerShell $a=$b=$c=0 ...
PowerShell 复制 Remove-Variable -Name a 乘法运算符赋值通过乘法运算符 *= 进行的赋值会乘以数值或追加变量字符串值的指定副本数。当变量包含单个数值时,该值乘以运算符右侧的值。 例如,以下示例演示如何使用 *= 运算符将变量的值相乘:PowerShell 复制 $a = 3 $a *= 4 $a Output 复制 ...
variable is: False Now the $? variable is: True 出于后者的目的,应改用 $PSCmdlet.WriteError()。 对于本机命令(可执行文件),当 $? 为0 时, 设置为 $LASTEXITCODE,当 为任何其他值时设置为 $LASTEXITCODE。 备注 在PowerShell 7 之前,用括号 (...)、子表达式语法 $(...)或数组表达式 @(.....
Get-Process -Id 2 -ErrorVariable +a The following command displays the contents of $a: PowerShell Copy $a You can use this parameter to create a variable that contains only error messages from specific commands and doesn't affect the behavior of the $Error automatic variable. The $Erro...
New-Variable Cmdlet Creates a new variable. Set-Variable Cmdlet Sets the value of a variable. Creates the variable if one with the requested name does not exist. Remove-Variable Cmdlet Deletes a variable and its value. Clear-Variable Cmdlet Deletes the value of a variable. ...
Remove-PSDrive Removes a Windows PowerShell drive from its location. Remove-PSSession Closes one or more Windows PSSessions. Remove-PSSnapin Removes Windows PowerShell snap-ins from the current session. Remove-Variable Deletes a variable and its value. Remove-WmiObject Deletes an instance of an ex...
Closed bagder wants to merge 1 commit into PowerShell:master from bagder:remove-curl-wget-aliasesClosed initialsession: remove curl and wget aliases #1901 bagder wants to merge 1 commit into PowerShell:master from bagder:remove-curl-wget-aliasesConversation...