Hey Guys,
I am pretty novice with powershell and having some trouble with my latest script.
Basically, it should do nothing more than gather some data from a local machine and append it to a textfile.
In the output-file, I'd like to have one line per computer and list the gathered info separated by commas.
e.g.:
computername1,00:00:00:00:00:00
computername2,00:00:00:00:00:01
computername3,00:00:00:00:00:02
I've tried several stuff but i am stuck here. Instead of writing in one line separated by commas, the only somewhat-useful output i can get looks like this:
computername1
00:00:00:00:00:00
computername2
00:00:00:00:00:01
computername3
00:00:00:00:00:02
Anyone having a hint for me?
Thanks a lot!
The script looks like this (I plan to add some more values, later):
###########
$cs = Get-WmiObject -Query "Select * from Win32_Computersystem"write-host "Hostname : " $cs.Name#$ComputerName = gc env:computername$nw = Get-WmiObject Win32_NetworkAdapterConfiguration -ComputerName $cs.Name | ? {$_.IPEnabled}write-host "Mac Address : " $nw.MACAddresswrite-host "."write-host $cs.Name,$nw.MACAddresswrite-output $cs.Name,$nw.MACAddress | out-file D:\outfile.txt -append ################
"{0},{1}" -f $cs.Name,$nw.MACAddress | out-file D:\outfile.txt -append
This is exactly what I was looking for. Thanks Dude, you made my day!