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.<\/p>\n
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.<\/p>\n
Here is my program for now:<\/p>\n
#############<\/p>\n
$Output = @()<\/p>\n
$Computers = Get-content “C: powershell\\test.csv”<\/p>\n
ForEach ($Computer In $Computers) {<\/p>\n
Get-Tpm<\/p>\n
$Output + = “$Computer, yes”<\/p>\n
}<\/p>\n
$Output | Out-file “C:\\powershell\\result.csv”<\/p>\n
#############<\/p>\n
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).<\/p>\n
Thank you in advance for your answers.<\/p>","upvoteCount":4,"answerCount":4,"datePublished":"2021-10-20T08:52:21.000Z","author":{"@type":"Person","name":"spiceuser-3difc","url":"https://community.spiceworks.com/u/spiceuser-3difc"},"suggestedAnswer":[{"@type":"Answer","text":"
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.<\/p>\n
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.<\/p>\n
Here is my program for now:<\/p>\n
#############<\/p>\n
$Output = @()<\/p>\n
$Computers = Get-content “C: powershell\\test.csv”<\/p>\n
ForEach ($Computer In $Computers) {<\/p>\n
Get-Tpm<\/p>\n
$Output + = “$Computer, yes”<\/p>\n
}<\/p>\n
$Output | Out-file “C:\\powershell\\result.csv”<\/p>\n
#############<\/p>\n
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).<\/p>\n
Thank you in advance for your answers.<\/p>","upvoteCount":4,"datePublished":"2021-10-20T08:52:21.000Z","url":"https://community.spiceworks.com/t/script-tpm-lits-of-computers/814544/1","author":{"@type":"Person","name":"spiceuser-3difc","url":"https://community.spiceworks.com/u/spiceuser-3difc"}},{"@type":"Answer","text":"
First - you need Admin rights for get-TPM.<\/p>\n
Second, this code will show ALL systems working!<\/p>\n
You might try this:<\/p>\n
$Output = @()\n\n$Computers = Get-content \"C: powershell\\test.csv\"\nForEach ($Computer In $Computers) {\n Try {\n $TPM = Get-Tpm\n if ($TPM.Activated) {\n $Output + = \"$Computer, yes\"\n else {\n $Output + = \"$Computer, no\"\n }\n}\n# OUTPUT\n$Output | Out-file \"C:\\powershell\\result.csv\"\n<\/code><\/pre>","upvoteCount":0,"datePublished":"2021-10-20T09:19:25.000Z","url":"https://community.spiceworks.com/t/script-tpm-lits-of-computers/814544/2","author":{"@type":"Person","name":"DoctorDNS","url":"https://community.spiceworks.com/u/DoctorDNS"}},{"@type":"Answer","text":"One way I can think of to do a list of computers is using Invoke-Command with a ScriptBlock.
\nGet-TPM doesn’t have a -Computers option.<\/p>\n
IIRC, there may also be a WMI option albeit more complicated.<\/p>","upvoteCount":0,"datePublished":"2021-10-20T11:12:18.000Z","url":"https://community.spiceworks.com/t/script-tpm-lits-of-computers/814544/3","author":{"@type":"Person","name":"gary-m-g","url":"https://community.spiceworks.com/u/gary-m-g"}},{"@type":"Answer","text":"
try anything<\/p>\n
$Computers = Get-content \"C: powershell\\test.csv\"\n\n$data=ForEach ($Computer In $Computers) {\n\nInvoke-Command -ComputerName $Computer -ScriptBlock{Get-Tpm|select TPMpresent,tpmready,@{n='Computer';e={$Computer}}\n#or\nGet-WmiObject -class Win32_Tpm -namespace root\\CIMV2\\Security\\MicrosoftTpm -ComputerName $Computer|select IsActivated_InitialValue,IsEnabled_InitialValue,@{n='Computer';e={$Computer}}\n\n}\n\n$data|Export-Csv \n<\/code><\/pre>","upvoteCount":1,"datePublished":"2021-10-20T11:46:06.000Z","url":"https://community.spiceworks.com/t/script-tpm-lits-of-computers/814544/4","author":{"@type":"Person","name":"jitensh","url":"https://community.spiceworks.com/u/jitensh"}}]}}