Hello, I am trying to set up a script which would ask a list of computers if they have a tpm chip, with the final aim of obtaining a .csv file with all the computers on my list as well as their version in order to know which ones can pass under Windows 11.

Despite my extensive research on the subject I do not understand it or, it does not work in my case. If you can help me I would love to.

Here is my program for now:

#############

$Output = @()

$Computers = Get-content “C: powershell\test.csv”

ForEach ($Computer In $Computers) {

Get-Tpm

$Output + = “$Computer, yes”

}

$Output | Out-file “C:\powershell\result.csv”

#############

The problem I am having is that this program only tests my station rather than the one in the “test” file there is only one at the moment (I try before expanding the list).

Thank you in advance for your answers.

4 Spice ups

First - you need Admin rights for get-TPM.

Second, this code will show ALL systems working!

You might try this:

$Output = @()

$Computers = Get-content "C: powershell\test.csv"
ForEach ($Computer In $Computers) {
 Try {
  $TPM = Get-Tpm
  if ($TPM.Activated) {
    $Output + = "$Computer, yes"
  else {
    $Output + = "$Computer, no"
  }
}
# OUTPUT
$Output | Out-file "C:\powershell\result.csv"

One way I can think of to do a list of computers is using Invoke-Command with a ScriptBlock.
Get-TPM doesn’t have a -Computers option.

IIRC, there may also be a WMI option albeit more complicated.

try anything

$Computers = Get-content "C: powershell\test.csv"

$data=ForEach ($Computer In $Computers) {

Invoke-Command -ComputerName $Computer -ScriptBlock{Get-Tpm|select TPMpresent,tpmready,@{n='Computer';e={$Computer}}
#or
Get-WmiObject -class Win32_Tpm -namespace root\CIMV2\Security\MicrosoftTpm -ComputerName $Computer|select IsActivated_InitialValue,IsEnabled_InitialValue,@{n='Computer';e={$Computer}}

}

$data|Export-Csv 
1 Spice up