如何在Windows中找到证书的安装日期?
发布时间:2020-12-13 23:26:38 所属栏目:Windows 来源:网络整理
导读:我看到有效的日期等,但我正在寻找它实际安装的日期.谢谢. 证书存储在注册表中的以下两个位置,最终键值与证书指纹打印相同.因此,为您提供指纹值,您可以查询正确的regkey [HKLMSOFTWAREMicrosoftSystemCertificates][HKCUSoftwareMicrosoftSystemCertif
我看到有效的日期等,但我正在寻找它实际安装的日期.谢谢.
证书存储在注册表中的以下两个位置,最终键值与证书指纹打印相同.因此,为您提供指纹值,您可以查询正确的regkey
[HKLMSOFTWAREMicrosoftSystemCertificates] [HKCUSoftwareMicrosoftSystemCertificates] 使用此处的PowerShell函数Get-RegistryKeyLastWriteTime,您可以查询注册表项以查找上次写入时间. 下面的PowerShell函数的完整代码,以防链接死亡(这不是我的工作) Function Get-RegistryKeyTimestamp { <# .SYNOPSIS Retrieves the registry key timestamp from a local or remote system. .DESCRIPTION Retrieves the registry key timestamp from a local or remote system. .PARAMETER RegistryKey Registry key object that can be passed into function. .PARAMETER SubKey The subkey path to view timestamp. .PARAMETER RegistryHive The registry hive that you will connect to. Accepted Values: ClassesRoot CurrentUser LocalMachine Users PerformanceData CurrentConfig DynData .NOTES Name: Get-RegistryKeyTimestamp Author: Boe Prox Version History: 1.0 -- Boe Prox 17 Dec 2014 -Initial Build .EXAMPLE $RegistryKey = Get-Item "HKLM:SystemCurrentControlSetControlLsa" $RegistryKey | Get-RegistryKeyTimestamp | Format-List FullName : HKEY_LOCAL_MACHINESystemCurrentControlSetControlLsa Name : Lsa LastWriteTime : 12/16/2014 10:16:35 PM Description ----------- Displays the lastwritetime timestamp for the Lsa registry key. .EXAMPLE Get-RegistryKeyTimestamp -Computername Server1 -RegistryHive LocalMachine -SubKey 'SystemCurrentControlSetControlLsa' | Format-List FullName : HKEY_LOCAL_MACHINESystemCurrentControlSetControlLsa Name : Lsa LastWriteTime : 12/17/2014 6:46:08 AM Description ----------- Displays the lastwritetime timestamp for the Lsa registry key of the remote system. .INPUTS System.String Microsoft.Win32.RegistryKey .OUTPUTS Microsoft.Registry.Timestamp #> [OutputType('Microsoft.Registry.Timestamp')] [cmdletbinding( DefaultParameterSetName = 'ByValue' )] Param ( [parameter(ValueFromPipeline=$True,ParameterSetName='ByValue')] [Microsoft.Win32.RegistryKey]$RegistryKey,[parameter(ParameterSetName='ByPath')] [string]$SubKey,[parameter(ParameterSetName='ByPath')] [Microsoft.Win32.RegistryHive]$RegistryHive,[parameter(ParameterSetName='ByPath')] [string]$Computername ) Begin { #region Create Win32 API Object Try { [void][advapi32] } Catch { #region Module Builder $Domain = [AppDomain]::CurrentDomain $DynAssembly = New-Object System.Reflection.AssemblyName('RegAssembly') $AssemblyBuilder = $Domain.DefineDynamicAssembly($DynAssembly,[System.Reflection.Emit.AssemblyBuilderAccess]::Run) # Only run in memory $ModuleBuilder = $AssemblyBuilder.DefineDynamicModule('RegistryTimeStampModule',$False) #endregion Module Builder #region DllImport $TypeBuilder = $ModuleBuilder.DefineType('advapi32','Public,Class') #region RegQueryInfoKey Method $PInvokeMethod = $TypeBuilder.DefineMethod( 'RegQueryInfoKey',#Method Name [Reflection.MethodAttributes] 'PrivateScope,Public,Static,HideBySig,PinvokeImpl',#Method Attributes [IntPtr],#Method Return Type [Type[]] @( [Microsoft.Win32.SafeHandles.SafeRegistryHandle],#Registry Handle [System.Text.StringBuilder],#Class Name [UInt32 ].MakeByRefType(),#Class Length [UInt32],#Reserved [UInt32 ].MakeByRefType(),#Subkey Count [UInt32 ].MakeByRefType(),#Max Subkey Name Length [UInt32 ].MakeByRefType(),#Max Class Length [UInt32 ].MakeByRefType(),#Value Count [UInt32 ].MakeByRefType(),#Max Value Name Length [UInt32 ].MakeByRefType(),#Security Descriptor Size [long].MakeByRefType() #LastWriteTime ) #Method Parameters ) $DllImportConstructor = [Runtime.InteropServices.DllImportAttribute].GetConstructor(@([String])) $FieldArray = [Reflection.FieldInfo[]] @( [Runtime.InteropServices.DllImportAttribute].GetField('EntryPoint'),[Runtime.InteropServices.DllImportAttribute].GetField('SetLastError') ) $FieldValueArray = [Object[]] @( 'RegQueryInfoKey',#CASE SENSITIVE!! $True ) $SetLastErrorCustomAttribute = New-Object Reflection.Emit.CustomAttributeBuilder( $DllImportConstructor,@('advapi32.dll'),$FieldArray,$FieldValueArray ) $PInvokeMethod.SetCustomAttribute($SetLastErrorCustomAttribute) #endregion RegQueryInfoKey Method [void]$TypeBuilder.CreateType() #endregion DllImport } #endregion Create Win32 API object } Process { #region Constant Variables $ClassLength = 255 [long]$TimeStamp = $null #endregion Constant Variables #region Registry Key Data If ($PSCmdlet.ParameterSetName -eq 'ByPath') { #Get registry key data $RegistryKey = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey($RegistryHive,$Computername).OpenSubKey($SubKey) If ($RegistryKey -isnot [Microsoft.Win32.RegistryKey]) { Throw "Cannot open or locate $SubKey on $Computername" } } $ClassName = New-Object System.Text.StringBuilder $RegistryKey.Name $RegistryHandle = $RegistryKey.Handle #endregion Registry Key Data #region Retrieve timestamp $Return = [advapi32]::RegQueryInfoKey( $RegistryHandle,$ClassName,[ref]$ClassLength,$Null,[ref]$Null,[ref]$TimeStamp ) Switch ($Return) { 0 { #Convert High/Low date to DateTime Object $LastWriteTime = [datetime]::FromFileTime($TimeStamp) #Return object $Object = [pscustomobject]@{ FullName = $RegistryKey.Name Name = $RegistryKey.Name -replace '.*(.*)','$1' LastWriteTime = $LastWriteTime } $Object.pstypenames.insert(0,'Microsoft.Registry.Timestamp') $Object } 122 { Throw "ERROR_INSUFFICIENT_BUFFER (0x7a)" } Default { Throw "Error ($return) occurred" } } #endregion Retrieve timestamp } } 用法: $RegistryKey = Get-Item "HKLM:<key name>" $RegistryKey | Get-RegistryKeyTimestamp | Format-List (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- Windows 7 、Windows Server 2008 和 Windows Server 2008
- Window10 64bit Tomcat9 安装
- windows – 如何在不注销的情况下修改用户的PATH环境变量?
- windows-server-2008-r2 – 虚拟机内的磁盘延迟
- Windows上安装Meteor的位置在哪里?
- 使用与客户端相同的.NET版本替换COM注册的.dll时,.NET客户端
- windows-server-2008 – 当我以管理员身份运行程序时,Windo
- microsoft-office – 带有零售版产品密钥的Microsoft Offic
- windows-server-2012 – Windows Server 2012默认RAM分配策
- windows-mobile – Windows Mobile上的Java(ME)
推荐文章
站长推荐
- windows-server-2012 – 基于访问的枚举和遍历文
- windows-server-2003 – Windows文件服务器性能调
- windows – 以具有SVN修订号的MFC应用程序编程更
- 使用Force在Windows上导入大型MySQL .sql文件
- windows-service – 从命令提示符显示Windows服务
- ClickOnce或Windows安装程序用于自动更新C#应用程
- windows – Django Apache/mod_python管理CSS不显
- 当我升级到Windows 7时,Delphi未注册
- 为什么Windows Phone 7不完全支持C#规范?
- WSUS部署Win10大版本功能更新 先决条件
热点阅读