0

I have a script that lists all installed applications on all the servers I have on my network.

The problem is that I am unable to list server name. How do I add $server.name to the select statement so that it is the first column in the output?

 # Pinging the server in Powershell-way!
if (Test-Connection -ComputerName $server.name -count 1 -Quiet ) {
    echo -computername 
    echo $server.name
    echo $services = $services, 
        (Get-WmiObject -ComputerName $server.name win32_product | select name, vendor, version | Export-CSV -Path $File -Force -Append -Verbose)
}

2 Answers 2

2

you should replace:

(Get-WmiObject -ComputerName $server.name win32_product | select name, vendor, version | Export-CSV -Path $File -Force -Append -Verbose)

With:

(Get-WmiObject -ComputerName $server.name win32_product | select pscomputername, name, vendor, version | Export-CSV -Path $File -Force -Append -Verbose)

/edit, yes PScomputer name is what you are after, in futureuse get-member have a look at your options

Sign up to request clarification or add additional context in comments.

Comments

0

I was too quick to ask the question. There is a variable called PSComputerName in win32_product which is the meachine name

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.