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 ...
Get-Command-NounVariable 若要取得特定 Cmdlet 的說明,請輸入: PowerShell Get-Help<cmdlet-name> Cmdlet 名稱描述 Clear-Variable刪除變數的值。 Get-Variable取得目前控制台中的變數。 New-Variable建立新變數。 Remove-Variable刪除變數及其值。 Set-Variable變更變數的值。
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. ...
可以在 PowerShell 中使用 .NET 类的静态属性。 静态属性是类的属性,与标准属性不同,标准属性是对象的属性。 若要获取类的静态属性,请使用 cmdlet 的Get-MemberStatic参数。 例如,以下命令获取 类的System.DateTime静态属性。 PowerShell Get-Date|Get-Member-MemberTypeProperty-Static ...
variable is: True 出于后者的目的,应改用 $PSCmdlet.WriteError()。 对于本机命令(可执行文件),当 $? 为0 时, 设置为 $LASTEXITCODE,当 为任何其他值时设置为 $LASTEXITCODE。 备注 在PowerShell 7 之前,用括号 (...)、子表达式语法 $(...)或数组表达式 @(...) 包裹语句时,总是将 $? 重置...
Remove-Item -Path C:\temp3.txt -Confirm:$false $DebugPreference Determines how PowerShell responds to debugging messages generated by a script, cmdlet or provider, or by a Write-Debug command at the command line. The $DebugPreference variable takes one of the ActionPreference enumeration...
Remove-Item Env:\TestVariable Alternatively you can use the SetEnvironmentVariable method, assigning the environment variable a null value: [Environment]::SetEnvironmentVariable("TestVariable",$null,"User") Again, if you use SetEnvironmentVariable the deleted variable might still show up when you ca...
Remove-PSSnapin Removes Windows PowerShell snap-ins from the current session. rujb Resume-Job Restarts a suspended job rv Remove-Variable Deletes a variable and its value. rvpa Resolve-Path Resolves the wildcard characters in a path, and displays the path contents. rwmi Remove-WMI...