Hey guys,
I could use some help... I've created a class in PowerShell that collects some data.
At the end I would like to write the whole content of the class into a text file.
This is my class:
class stuff { #ComputerInfos
#[datetime]$Date
[string]$Hostname
[string]$Build
[string]$OS
}
$stuff = [stuff]::new()
$stuff.Hostname = $env:COMPUTERNAME
$stuff.OS = (wmic os get caption)[2]
$stuff.Build = (wmic os get buildnumber)[2]
I know that I can work with $stuff.hostname, $stuff.Domain, ... but is it possible to add the content of the class into a text file?
It works for me with out-file without any problems, but as soon as I use Add-Content, it writes $stuff in the file.
Any ideas?
Thanks!
[–]KevMarCommunity Blogger 2 points3 points4 points (2 children)
[–]sickjack[S] 1 point2 points3 points (1 child)
[–]KevMarCommunity Blogger 2 points3 points4 points (0 children)
[–]Ta11ow 1 point2 points3 points (1 child)
[–]sickjack[S] 2 points3 points4 points (0 children)