Get-TpmStatus
12/20/2013 09:42<#
.SYNOPSIS
Get the current status of the TPM.
.DESCRIPTION
Tests the status of the Trusted Platform Module, only returns true if both enabled and activated.
.EXAMPLE
Get-TpmStatus
.EXAMPLE
Get-TpmStatus -ComputerName "mycomputer.mydomain.org"
.LINKS
https://github.com/necromorph1024/HPTpmAndBitLocker
https://msdn.microsoft.com/en-us/library/windows/desktop/aa376484%28v=vs.85%29.aspx
#>
function Get-TpmStatus
{
[CmdletBinding()]
[OutputType([PSobject])]
Param
(
# ComputerName, Type string, System to evaluate TPM against.
[Parameter(Position=0,
ValueFromPipeline=$true)]
[string[]]
$ComputerName=$env:COMPUTERNAME
)
if (-not(Test-Connection -ComputerName $ComputerName -Quiet -Count 2))
{
throw "Failed to connect to $ComputerName. Please ensure the system is available."
}
try
{
$tpm=Get-WmiObject -Class Win32_Tpm -Namespace "root\CIMV2\Security\MicrosoftTpm" -ComputerName $ComputerName -ErrorAction Stop
}
catch
{
throw "Failed to connect to the Win32_Tpm Namespace, You may not have sufficent rights."
}
if (-not($tpm.IsEnabled_InitialValue))
{
$enabled="No"
}
else
{
$enabled="Yes"
}
if (-not($tpm.IsActivated_InitialValue))
{
$activated="No"
}
else
{
$activated="Yes"
}
$tpmStatus=[PSCustomObject] @{
'Enabled' =$enabled
'Activated'=$activated
}
return $tpmStatus
}
Tags:
———
Back