Display results from multiple targets

Hello guys,

I want to get the Last time boot from my servers, but I want to display the results in a single report file (txt or csv). Is it possible?

To take the information I need, I am using the script:

Get-CimInstance -ClassName win32_operatingsystem | select csname, lastbootuptime

However, I dont know how to put the results from all the servers in a single file.

Thanks

Hi @nsantos.br!

You could probably use something like this https://gallery.technet.microsoft.com/scriptcenter/Powershell-script-to-check-b1bfbc21 (with some minor edits of course) to perform this, assuming that your list of machines is somewhat static.

If your infrastructure varies wildly, and the only common thread is having a tentacle installed, then you would likely need set up Octopus to run your command on each target, and then consolidate the information out of the task log (since it will be broken up per-machine) with Select-String or grep, depending on your infrastructure.

Hope this helps!

Hello Justin,

Thank you for your response. The servers are not in the domain, so I can not use a list of servers in my script because I’ll get an Access Denied error.

Using Octopus, is there a way to consolidate the information from all the servers? Can you send me an example using the Select-String, please?

Thanks.

Hi @nsantos.br

Owing to the inability to use a remote powershell session, you would likely need to use the latter option suggested, of scraping the task log for information. Sadly, I don’t have a script for this, but here’s a great resource on using Select-String in PowerShell to pull out the information you need: https://blog.ipswitch.com/select-string-the-grep-of-powershell

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.