locked
output to txt or csv RRS feed

  • Question

  •  Hi,I am calling a list of servers and checking the log status for each but when I try to output I get nothing

    I have tried >, and out-file and export-csv ...thanks

    $servers = get-content "c:\file path"
    foreach
     ($server in $servers) {
    Get-PIBackupSummary
     -Connection (Connect-PIDataArchive -PIDataArchiveMachineName $server) | 
    select
     $server,status,statusmessage,type,backupend |
    Where StatusMessage -ne "[0] Success" 
    } 
    
    | Export-Csv  "P:\file path\Log_Errors.csv" -NoTypeInformation -Encoding UTF8 
    
    

    Friday, November 16, 2018 4:15 PM

All replies

  • **don't know how to delete additional code box :(
    Friday, November 16, 2018 4:16 PM
  • You code is badly formed.

    Get-Content c:\file path |
        ForEach-Object{
            Get-PIBackupSummary -Connection (Connect-PIDataArchive -PIDataArchiveMachineName $_)
        } | 
        Where-Object{ $_.StatusMessage -notmatch 'Success'} |
        Select-Object PsComputerName, ,status,statusmessage,type,backupend |
        Export-Csv  "P:\file path\Log_Errors.csv" -NoTypeInformation -Encoding UTF8 

    Stop guessing. It will waste too much time:

    1. Microsoft Virtual Academy - Getting Started with Microsoft PowerShell
    2. PowerShell Documentation
    3. PowerShell Style Guidelines


    \_(ツ)_/


    Friday, November 16, 2018 4:54 PM
  • Probably better off asking on https://powershell.org
    Friday, November 16, 2018 5:25 PM
  • Hi,

    Was your issue resolved?

    If you resolved it using our solution, please "mark it as answer" to help other community members find the helpful reply quickly.

    If you resolve it using your own solution, please share your experience and solution here. It will be very beneficial for other community members who have similar questions.

    If no, please reply and tell us the current situation in order to provide further help.

    Best Regards,

    LEE


    Just do it.

    Tuesday, November 27, 2018 2:43 AM