Quantcast
Channel: PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources: Active Threads
Viewing all articles
Browse latest Browse all 8411

Clearing only Variables if they are not null

$
0
0

So, either i'm missing something or it's just not possible in the fashion i'm doing it.

 

So I take all the variables I have and put them in an array like

 

$vararray = @("A","B","C","D")

Then I tried something like

$vararray | % {

if ($_ -ne $Null) {

clear-variable -name $_

}

}

But that will not work b/c $_ will always be a letter

So, then I tried to build a string out of it, but that didn't work either.


Please tell me i'm missing something and there is something simple to do this other than If statements


Viewing all articles
Browse latest Browse all 8411

Latest Images

Trending Articles



Latest Images