Jump to content
Sign in to follow this  
blumi

TPM status with wmi

Recommended Posts

I found a website where it is explained how to use wmi to check the tpm status of the tmp security chip.

http://windowsitpro.com/security/checking-status-trusted-platform-module-command-line

I tried this with autoit, but had no success.

Anyone here who can give little support to me?

Thanks

#include <Array.au3>

$ScriptName     = "TPM Status"

Dim $sResult
$strComputer = "lapxxx"

$objWMIService = ObjGet("wmic /namespace:\\.\root\cimv2\security\microsofttpm")
;$objWMIService = ObjGet("wmic /namespace:\\" & $strComputer & "\root\cimv2\security\microsofttpm")
;$objWMIService = ObjGet("winmgmts:{impersonationLevel=impersonate}!\\" & $strComputer & "\root\cimv2")
$colItems = $objWMIService.InstancesOf("Select * from Win32_Tpm")

For $objItem In $colItems
    $IsActivated = $objItem.IsActivated_InitialValue
    $IsEnabled = $objItem.IsEnabled_InitialValue

    MsgBox(0, $ScriptName,  "IsActivated: " & $IsActivated & @CRLF & _
                                                    "IsEnabled: " & $IsEnabled & @CRLF & _
                                                    "x: " )
Next




$oMTpm = ObjGet("winmgmts:\\.\root\cimv2\Security\MicrosoftTpm")
$oCol = $oMTpm.InstancesOf("Win32_Tpm")


For $oObj In $oCol

    ConsoleWrite($oObj.IsActivated_InitialValue & @CRLF)
    ConsoleWrite($oObj.IsEnabled_InitialValue & @CRLF)
    ConsoleWrite($oObj.IsOwned_InitialValue & @CRLF)
    ConsoleWrite($oObj.SpecVersion & @CRLF)
    ConsoleWrite($oObj.ManufacturerVersion & @CRLF)
    ConsoleWrite($oObj.ManufacturerVersionInfo & @CRLF)
    ConsoleWrite($oObj.ManufacturerId & @CRLF)
    ConsoleWrite($oObj.PhysicalPresenceVersionInfo & @CRLF)

Next

 

 

Share this post


Link to post
Share on other sites
; TPM Security Info

Opt ( 'MustDeclareVars', 1 )

Local $objWMIService, $colItem, $objItem        ; Declare
Local $strComputer = "."                        ; Local Computer

; WMI Object
$objWMIService = ObjGet ( "WinMgmts:{impersonationLevel=impersonate,AuthenticationLevel=pktprivacy}//" & $strComputer & "\root\CIMV2\Security\MicrosoftTpm" )

; WMI Object check.
If IsObj ( $objWMIService ) Then
    ConsoleWrite ( "Object YES" & @CRLF )   ; Debug console message
Else
    ConsoleWrite ( "Object NO" & @CRLF )
    Exit 1  ; Exit Script Object error / WMI MicrosoftTpm not found.
EndIf

$objItem = $objWMIService.InstancesOf ( "Win32_Tpm" )

For $colItems In $objItem
    ConsoleWrite ( "IsActivated : " & $colItems.IsActivated_InitialValue & @CRLF )
    ConsoleWrite ( "IsEnabled : " & $colItems.IsEnabled_InitialValue & @CRLF )
    ConsoleWrite ( "IsOwned : " & $colItems.IsOwned_InitialValue & @CRLF )
    ConsoleWrite ( "SpecVersion : " & $colItems.SpecVersion & @CRLF )
    ConsoleWrite ( "ManufacturerVersion : " & $colItems.ManufacturerVersion & @CRLF )
    ConsoleWrite ( "ManufacturerVersionInfo : " & $colItems.ManufacturerVersionInfo & @CRLF )
    ConsoleWrite ( "ManufacturerId : " & $colItems.ManufacturerId & @CRLF )
    ConsoleWrite ( "PhysicalPresenceVersionInfo : " & $colItems.PhysicalPresenceVersionInfo & @CRLF )
Next

Hi, I don't have TPM enabled and i am running Windows in a virtual machine. Anyway i narrowed your'e code a bit down and rewrote a little bit. Hope this works for you. 

Share this post


Link to post
Share on other sites

One more question about the manufactureid.

How to convert it from the id to text?

 

Found this about it.

Data type: uint32
Access type: Read-only
ManufacturerId

The identifying information that uniquely names the TPM manufacturer.

When the data is unavailable, zero is returned.

This integer value can be translated to a string value by interpreting each byte as an ASCII character. For example, an integer value of 1414548736 can be divided into these 4 bytes: 0x54, 0x50, 0x4D, and 0x00. Assuming the string is interpreted from left to right, this integer value translated to a string value of "TPM".

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By shital
      #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_UseX64=y #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** RunAs(test", @ComputerName, "testinng",2,"wmic product where ""name= '%notepadexamples%'"" call uninstall", @SystemDir & "\wbem", @SW_MAXIMIZE)  it not working 
       
    • By Colduction
      Hi AutoIt Programmers!

      I've seen a code that gives Name of Group by writing it's group's SID, but this one response very slower than Windows Command-Line WMIC
       
      Func _GetLocalGroupName($sSID = 'S-1-5-18') $objWMIService = ObjGet ("winmgmts:\\" & @ComputerName & "\root\cimv2") $colItems = $objWMIService.ExecQuery('SELECT Name FROM Win32_Group where SID="' & $sSID & '"') For $GroupNames in $colItems MsgBox (0,"",$GroupNames.Name) ExitLoop Next EndFunc I don't want call and use any third-party programs even CMD, i just want use from Windows API, netapi32.dll or AutoIt Functions (Standalone).
      Do you have any idea to improve speed/performance of this code? I'll happy of your comments
       
       
       
      ====================== SOLOUTION by @Subz ======================
       
    • By edpoguatemala
      Hello Everyone, 
      So I'm using auto it to automate the download of pictures in woocommerce orders. Once images are downloaded, I need to change the status of the order from in process to completed. This is how my code looks like: 
      Download()
      Func Download()
          ; Save the downloaded file to the temporary folder.
          Local $sFilePath = @DesktopDir&"\TestAutomatizacion\"&@YEAR &"_"& @MON &"_"& @MDAY & "_picpic_orders.zip"
          ; Download the file in the background with the selected option of 'force a reload from the remote site.'
          Local $hDownload = InetGet("https://hellopicpic.com/get_pic_orders.php?token=ygtV2bMh23uJ7f6s&type=pic", $sFilePath, $INET_FORCERELOAD, $INET_DOWNLOADBACKGROUND)
          ; Wait for the download to complete by monitoring when the 2nd index value of InetGetInfo returns True.
          Do
              Sleep(250)
          Until InetGetInfo($hDownload, $INET_DOWNLOADCOMPLETE)
          ; Retrieve the number of total bytes received and the filesize.
          Local $iBytesSize = InetGetInfo($hDownload, $INET_DOWNLOADREAD)
          Local $iFileSize = FileGetSize($sFilePath)
          ; Close the handle returned by InetGet.
          InetClose($hDownload)
      EndFunc   ;==>Download
       
      Thanks for any help you can give. 
    • By jresine
      Hello, is it possible to know via a script or command, to have the percentage of disk usage of a process? thank you in advance.
      ps: see image

    • By Dwalfware
      HI
      Another head scratched
      Anyone solve how to get the IPV6 from WMI?
      I followed the usual SELECT * FROM Win32_NetworkAdapter WHERE NetConnectionID='" & GUICtrlRead($cboAdapters) & "'
      get the index 
      port it to 
      Local $query = $objWMIService.ExecQuery("SELECT * FROM Win32_NetworkAdapterConfiguration WHERE Index = " & _GetSelectedNIC(), "WQL", 0x30 )
      All i can see is IPv4 addresses
      My question is is there another place the IPv6 information is hiding? I configured my LAN with IPV6 and my wireless with IPv4 so I can see what shows.
      Thanks in Advance.
      PS. I did try google
       
×
×
  • Create New...