1

I have created a script that pulls all of the installed software from the domain connected computers. The problem is no matter what I do with format-table and select-object, it never seems to display the computer name, which I need to figure out what computer has what. The command takes an input of computers from Get-ADComputer script and runs the command for each name in the list.

I have tried properties like computername, systemname, pscomputername, and ADcomputer

Get-Content -Path \\server\C$\folder\Computers.txt | ForEach-Object {Get-ItemProperty HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\*} | Select-Object DisplayName, DisplayVersion, Publisher, InstallDate, SystemName | format-table SystemName, DisplayName, DisplayVersion, InstallDate -auto | Format-List -Property * | Out-File -FilePath \\server\C$\Folder\Computers11.txt

Each time it shows the computername blank

1
  • 1
    in your ForEach-Object scriptblock, build a PSCustomObject that has what you want in it. that way you can skip the Select-Object, and the remarkably silly & destructive Format-* cmdlets. Commented Oct 31, 2019 at 19:57

1 Answer 1

0

Are you looking for $env:computername?

$env: is essentially a drive that gives you access to all environmental variables, and computername is one that shows your current computer name.

You can list all of them with

Get-Item -Path Env:
Sign up to request clarification or add additional context in comments.

2 Comments

I have tried the $env:computername and it now displays my Computername as a Header for the column and not for the rest of the list. I'm trying to list computer names for each software that pulls up in the list.
Yes. For each software that it pulls

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.