locked
Variable to output RRS feed

  • Question

  • Hi

    Struggling with this for a bit. The following is the script i would like to add the original object that it scans for in the output. Suggestions? I am looking to get the original server name added to the output so i can see what actually was scanned versus the final output of what it was able to contact.

    Any help would be great

    thanks

    $Srvs = get-content c:\temp\servers.txt
    foreach ($Srv in $Srvs)
    {
        $serv = $srv
        Schtasks.exe /query /s $Srv /V /FO CSV | ConvertFrom-CSV | Where-Object { $_.Author -notlike "*Microsoft*"} | Select-Object @{Label = "Host Name To Scan"; expression = {$serv}},@{Label = "Host Name"; expression = {$_.HostName}}, @{Label = "Scheduled Task Name"; expression = {$_.TaskName}}, @{Label = "Author"; expression = {$_.Author}}, @{Label = "Comment"; expression = {$_.Comment}} | export-csv c:\temp\tasks.csv -NoTypeInformation -UseCulture -append
    }

    Thursday, November 30, 2017 3:31 AM

All replies

  • This is  actually very simple:

     Get-Content c:\temp\servers.txt |
        ForEach-Object{
    $server = $_ Schtasks.exe /query /s $server /V /FO CSV | ConvertFrom-CSV | Select @{n='Server';e={$server}},* } | Export-Csv tasks.csv


    \_(ツ)_/



    • Edited by jrv Thursday, November 30, 2017 3:55 AM
    • Proposed as answer by PRASOON KARUNAN V Thursday, November 30, 2017 4:15 PM
    Thursday, November 30, 2017 3:54 AM