How to clear variable content in powershell?

by darrion.kuhn , in category: Third Party Scripts , 2 days ago

How to clear variable content in powershell?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

by muriel.schmidt , a day ago

@darrion.kuhn 

To clear a variable's content in PowerShell, you can simply assign it a value of $null or an empty string.


Here is an example:

1
2
$variable = "This is some content"
$variable = $null


Alternatively, you can also use the Set-Variable cmdlet to clear a variable's content:

1
Set-Variable -Name variable -Value $null