Last active
July 8, 2021 19:34
-
-
Save rezarahimian/d688385f88f0ceac56f2adfedc3f6ae7 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<# | |
// Data class to be inventoried by SCCM hardware inventory on the client | |
[SMS_Report(TRUE),SMS_Group_Name("Certificates"),SMS_Class_ID("Custom Inventory|Certificates|1.0")] | |
Class Certificates: SMS_Class_Template | |
{ | |
[ SMS_Report (FALSE), Key ] String Thumbprint; | |
[ SMS_Report (FALSE) ] String Subject; | |
[ SMS_Report (FALSE) ] String NotBefore; | |
[ SMS_Report (FALSE) ] String NotAfter; | |
[ SMS_Report (FALSE) ] String SignatureAlgorithm; | |
[ SMS_Report (FALSE) ] DateTime CheckDate; | |
} | |
#> | |
$Rec = 1 | |
$MIFName = 'Certificates' | |
$MIFClass = ('"Custom Inventory|{0}|1.0"' -f $MIFName) | |
$MIFData = @('Start Component','Name="Workstation"') | |
Get-ChildItem -Path 'Cert:\LocalMachine\ROOT' | Where-Object { $_.Issuer -like '*infra.private*' } | ForEach-Object { | |
$MIFData += @('Start Group',('Name="{0}"' -f $MIFName),('ID={0}' -f $Rec++),('Class={0}' -f $MIFClass)) | |
$MIFData += ('Start Attribute Name="Thumbprint" ID=1 Type=String Value="{0}" End Attribute' -f $_.Thumbprint) | |
$MIFData += ('Start Attribute Name="Subject" ID=2 Type=String Value="{0}" End Attribute' -f $_.Subject) | |
$MIFData += ('Start Attribute Name="NotBefore" ID=3 Type=String Value="{0}" End Attribute' -f $_.NotBefore) | |
$MIFData += ('Start Attribute Name="NotAfter" ID=4 Type=String Value="{0}" End Attribute' -f $_.NotAfter) | |
$MIFData += ('Start Attribute Name="SignatureAlgorithm" ID=5 Type=String Value="{0}" End Attribute' -f $_.SignatureAlgorithm.FriendlyName) | |
$MIFData += ('Start Attribute Name="CheckDate" ID=6 Type=Date Value="{0}" End Attribute' -f ('{0}.000000+000' -f (Get-Date).ToUniversalTime().ToString('yyyyMMddHHmmss'))) | |
$MIFData += ('End Group') | |
} | |
$MIFData += 'End Component' | |
$MIFPath = ('{0}\CCM\Inventory\noidmifs\{1}.mif' -f ($env:windir),$MIFName) | |
$MIFData | ForEach-Object { ([String]$_).Replace('\','\\') } | Set-Content -Path $MIFPath -Force |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment