You are here:

WindowsManagement.com > PowerShell > PowerShell 1.0 > Clear-Variable
ActiveXperts Network Monitor 2019 proactively manages network servers, devices, databases and more.

Clear-Variable - PowerShell 1.0

Microsoft Windows PowerShell is a command-line shell and scripting tool based on the Microsoft .NET Framework. It is designed for system administrators, engineers and developers to control and automate the administration of Windows and applications.

More than hundred command-line tools (so called "cmdlets") can be used to perform system administration tasks and Windows Management Instrumentation (WMI). These cmdlets are easy to use, with standard naming conventions and common parameters, and standard tools for piping, sorting, filtering, and formatting data and objects.

Clear-Variable


Description
Back up your Hyper-V VMs Easy & Fast. 100% built for Hyper-V. Free for 2 VMs, forever.

Usage


Options
-name string
       The name(s) of the variable to be cleared, required.
       Wildcards are permitted.

   -include string[]
       Clear only the specified items, wildcards allowed e.g. "ora*"
        
   -exclude string[]
       Omit the specified items, wildcards allowed e.g. "*ms*"
        
   -scope string
       The scope in which this alias is valid. 
       Valid values are "Global", "Local", or "Script", or a number relative
       to the current scope ( 0 through the number of scopes, where 0 is the
       current scope and 1 is its parent). "Local" is the default.
       For more, type "get-help about_scope".
	
   -force SwitchParameter
       Override restrictions that prevent the command from succeeding, apart
       from security settings. e.g. Force will create file path directories 
       or override a files read-only attribute, but will not change file permissions.
		
   -passThru 
       Pass the object created by Clear-Variable through the pipeline.
       (By default this switch is not set)

   -whatIf
       Describe what would happen if you executed the command without actually
       executing the command.
        
   -confirm
       Prompt for confirmation before executing the command.
 
   CommonParameters:
       -Verbose,-Debug,-ErrorAction,-ErrorVariable,-OutVariable.

Example(s)
Clear a local variable:

PS C:\>clear-variable -name ss64

Clear a global variable:

PS C:\>clear-variable ss64 -global

Clearing a variable in a child scope (e.g. via the invoke operator: &{....} ) will not clear the variables value in the parent scope.