I'm new to Powershell and I have just started using datatables.
How do I clean them up (Destroy) datatables after I've finished with them?
Below is my code...
I want to cleanup/destroy table after I have viewed it.
$sRegistoryLocations = “RegistoryLocations”
#Create RegistoryLocations Table object
#Add the Columns
#Enter path 1 to search.
#Enter path 2 to search.
#Enter path 3 to search.
#Display the table
#Now I want to destroy/clean up the datatable
Once your script finishes and the variables go out of scope, .NET will garbage collect them automatically.
You can also use a
Choice... Thanks guys... I really appreciate the help.
Yeah I'm writing powershell code using the Powershell ISE.
If I create a table using the following method
# Create table
it doesn't seem to get garbage collected when the script ends. Because when I type at the command prompt in the Powershell ISE like the following I get...
PS C:\Windows\system32> $dvPeople
userlogin : TEST1
However if I call the I get the following message...
PS C:\Windows\system32> remove-Variable -$dvPeople
So I'm not sure where I'm going wrong... The datatable appears to be there after the script has been run... But when I goto delete it it says it can't find it.
That's the ISE. it maintains scope; it's a development feature and is on purpose. Try it in the console.
And the $ is not part of the name.. you need to only use the name..
Remove-Variable -name dvPeople
You guys are awesome thanks heaps!
You must be logged in to reply to this topic.