Export-csv
good morning,

I am newbie in powershell, and would like you guys to help.
I am creating a powershell script that runs every day at 02:00 in the morning.
The script is very simple, a Get-WmiObject to get the information Caption and CSName, all within a case, which runs on a specific range of IP.

Today the output of this script is being played in a .txt file
Would help to play it in a .csv file. I took a read on the export-csv, but I'm having a lot of difficulty. Could someone help me pr kindness?

Follow my script:

for($i=33; $i -le 50; $i++){

    Get-WmiObject Win32_OperatingSystem -ComputerName 10.195.230.$i | Format-Table Caption,CSName >> C:\Test.txt

}
May 29th, 2015 9:30am

You could change your code this way...

for($i=33; $i -le 50; $i++){

    Get-WmiObject Win32_OperatingSystem -ComputerName 10.195.230.$i | select Caption,CSName | export-csv C:\Test.csv

}

Without seeing your other non-working code or knowing more about your issues, I can't really tell you what was wrong with it, but this should do what you're looking for.

Free Windows Admin Tool Kit Click here and download it now
May 29th, 2015 9:54am

Won't work.  Do it like this.

33..50 | 
    %{
        Get-WmiObject Win32_OperatingSystem -ComputerName 10.195.230.$_
    } | 
    select Caption,CSName | 
    export-csv C:\Test.csv -NoType


May 29th, 2015 10:20am

Thank you man ! Excellent :D
Free Windows Admin Tool Kit Click here and download it now
May 29th, 2015 10:58am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics