1
votes

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
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.Lee_Dailey

1 Answers

0
votes

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: