RedGazelle
RedGazelle

Reputation: 47

Dumping all variables to a text file

I've made a windows forms application that seems to create a memory leak very occasionally. Is there a way to dump all variable information to a text file so I can look through it and see what might be causing this?

Upvotes: 0

Views: 644

Answers (1)

Ansgar Wiechers
Ansgar Wiechers

Reputation: 200373

Get-Variable lists all variables with their values. There are various ways of dumping this information into a file, e.g.:

Get-Variable | Export-Csv 'C:\variables.csv'
Get-Variable | Export-Clixml 'C:\variables.xml'
(Get-Variable | ConvertTo-Xml).Save('C:\variables.xml')
Get-Variable | ConvertTo-Json | Out-File 'C:\variables.json'
Get-Variable | Format-Table -Wrap | Out-String | Out-File 'C:\variables.txt'
...

Upvotes: 1

Related Questions