powershell output question

I have a little script to check the version of SEP on some systems. It works,outputs the name and the version. The problem is it puts the "headers" on each server.
$servers = gc servers.txt
foreach ($server in $servers)
{Invoke-Command -ComputerName $server -Command {Get-ItemProperty -Path "HKLM:SOFTWARE\\Symantec\
\Symantec Endpoint Protection\currentversion"}|ft pscomputername, productversion}

Open in new window



The output looks like this:
PSComputerName PRODUCTVERSION
-------------- --------------
server1        14.0.3752.1000



PSComputerName PRODUCTVERSION
-------------- --------------
server2        14.0.3752.1000

Open in new window

Can I easily get it to look like this:
PSComputerName PRODUCTVERSION
-------------- --------------
server1        14.0.3752.1000
server2        14.0.3752.1000

Open in new window


Thx!
LVL 3
SquigglyMonkeyAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Jason CrawfordTransport NinjaCommented:
Try this:

Invoke-Command -ComputerName (Get-Content .\servers.txt) -ScriptBlock {
    Get-ItemProperty -Path 'HKLM:SOFTWARE\\Symantec\\Symantec Endpoint Protection\currentversion' | Select-Object pscomputername,productversion
}

Open in new window

The benefit to ditching the foreach is the command will fan out concurrently on all servers instead of one at a time with the foreach.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
SquigglyMonkeyAuthor Commented:
Thanks for the response, that's super close to what I'd like it to look like.  The prodcutversion shows up first, and something was added that is not listed at all (runspaceid?)
PRODUCTVERSION PSComputerName RunspaceId
-------------- -------------- ----------
14.0.3752.1000 server1    5190bc88-67b5a09fdd
14.0.3752.1000 server2     fc8d9e89e70b59

Open in new window

0
SquigglyMonkeyAuthor Commented:
I piped it out to ft, and the runspaceid is gone, and the server name is first, thank you!!

The end result or anyone that wants it is:
Invoke-Command -ComputerName (Get-Content .\servers.txt) -ScriptBlock 
{Get-ItemProperty -Path 'HKLM:SOFTWARE\\Symantec\\Symantec Endpoint Protection\currentversion' | 
Select-Object pscomputername, productversion
}|ft pscomputername, productversion

Open in new window

0
How the Cloud Can Help You as an MSSP

Today, every Managed Security Service Provider (MSSP) needs a platform to deliver effective and efficient security-as-a-service to their customers. Scale, elasticity and profitability are a few of the many features that a Cloud platform offers. Register today to learn more!

Jason CrawfordTransport NinjaCommented:
That is weird.  Maybe try rebooting haha kidding.

Maybe try a PSObject:

Invoke-Command -ComputerName (Get-Content .\servers.txt) -ScriptBlock {
    $item = Get-ItemProperty -Path 'HKLM:SOFTWARE\\Symantec\\Symantec Endpoint Protection\currentversion'
    [array]$results += New-Object -TypeName PSObject -Property @{
        'Computer Name' = $item.pscomputername
        'Product Version' = $item.productversion
    }
    $results
}

Open in new window

0
Jason CrawfordTransport NinjaCommented:
Glad I could help.  If my solution was correct please mark it as the answer instead of closing the question.  Take care :)
0
SquigglyMonkeyAuthor Commented:
I don't think the guy who answered is getting the points he deserves.
0
SquigglyMonkeyAuthor Commented:
I canceled the first time I chose your answer as the best solution, I chose your answer as the best solution and this is the same thing that happened the first time.
1
Jason CrawfordTransport NinjaCommented:
It's weird I know.  You're not the first and you won't be the last.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Powershell

From novice to tech pro — start learning today.