Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/powershell/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Powershell:查看远程计算机当前用户证书_Powershell - Fatal编程技术网

Powershell:查看远程计算机当前用户证书

Powershell:查看远程计算机当前用户证书,powershell,Powershell,我正在尝试通过PowerShell远程计算机查看当前用户证书。 类似于Get ChildItem Cert:\CurrentUser\My但对于远程计算机,如果用户以管理员身份登录 任何建议都会有帮助您尝试调用命令了吗 invoke-command <computername> {get-childitem cert:\currentUser\my} invoke命令{get childitem cert:\currentUser\my} 如果需要,你也可以通过考试 Invoke

我正在尝试通过PowerShell远程计算机查看当前用户证书。 类似于
Get ChildItem Cert:\CurrentUser\My
但对于远程计算机,如果用户以管理员身份登录


任何建议都会有帮助

您尝试调用命令了吗

invoke-command <computername> {get-childitem cert:\currentUser\my}
invoke命令{get childitem cert:\currentUser\my}
如果需要,你也可以通过考试

Invoke-Command <computername> -Credential (Get-Credential) {Get-ChildItem cert:\currentUser\my}
Invoke命令-Credential(Get-Credential){Get-ChildItem证书:\currentUser\my}

如果正确配置了PSRemoting,则可以使用简单的
调用命令
从远程计算机获取详细信息

您正在使用的同一命令可以在
Invoke命令中使用,以获取详细信息:

$Servers = "Comp1",
           "Comp2"
 
  $Results = @()
  $Results = Invoke-Command -cn $Servers {
          $Certs = @{} | Select Certificate,Expired
          $Cert = Get-ChildItem Cert:\LocalMachine\My | Where-Object {$_.subject -match [Environment]::GetEnvironmentVariable("computername")}
          If($Cert){
              $Certs.Certificate = $Cert.subject
              $Certs.Expired = $Cert.NotAfter
          }
          Else{
              $Certs.Certificate = " - "
              $Certs.Expired = " - "
          }
          $Certs
  } | Select-Object @{n='ServerName';e={$_.pscomputername}},Certificate,Expired

Powershell Bros and galley有很多类似的例子来做这类工作。

如果我正确阅读了您的问题,您希望从远程会话获取当前用户的证书。这是完全可能的,假设您作为相关用户创建此远程会话。假设您的用户名是ADVIR,我的用户名是PowerShellGuy,您正在尝试从machine1获取我的当前用户证书


看看这个网站:我确实检查了这个网站,但它只提供本地机器,我正在尝试远程检索用户证书,所以有规则:----PS只在启动它的人的用户上下文中运行。您不能以登录用户身份本机使用Powershell运行。这是一个Windows安全边界。你需要使用3rdP工具,比如PSExec来做这类事情。powershellgallery.com中有一些模块可以作为远程用户运行。
$userWeWantCertFrom = "PowerShellGuy"

# This will prompt you for the credentials
$creds = get-credential -UserName $userWeWantCertFrom -Message "Enter password for $userWeWantCertFrom"

Invoke-Command -ComputerName "machine1" -Credential $creds -Scriptblock {
    Get-ChildItem Cert:\CurrentUser\My
}