繁体   English   中英

如何在 azuread 中检索企业应用程序的指纹到期日期

[英]How to retrieve thumbprint expiry date of enterprises application in azuread

如何使用 CSV 格式的 PowerShell 检索 azure 广告中企业申请的指纹到期日期

Clear-Variable  diskreport3 -ErrorAction SilentlyContinue
If($connect -eq $null){$connect = Connect-AzureAD }

$allService = Get-AzureADServicePrincipal


ForEach ($i in $allService)
{

Clear-Variable  Thumbprint -ErrorAction SilentlyContinue
$details = Get-AzureADServicePrincipalKeyCredential -ObjectId $i.ObjectID
$CustomKeyIdentifier = (Get-AzureADServicePrincipalKeyCredential -ObjectId $i.ObjectID).CustomKeyIdentifier
if($CustomKeyIdentifier -eq $null ){$Thumbprint = $null}
else{
$Thumbprint = [System.Convert]::ToBase64String($CustomKeyIdentifier)
}


$app=$i.displayname
$start = $details.StartDate
$end = $details.EndDate
$type = $details.Type

$dataRow = "
</tr>
<td>$app</td>
<td>$start</td>
<td>$end</td>
<td>$Thumbprint</td>
<td>$type</td>
</tr>
"
$diskreport3 += $datarow
}


$report = "<html>
<style>
{font-family: Arial; font-size: 13pt;}
TABLE{border: 1px solid black; border-collapse: collapse; font-size:13pt;}
TH{border: 1px solid black; background: #dddddd; padding: 5px; color: #000000;}
TD{border: 1px solid black; padding: 5px; }
</style>
<h2>Azure Service Principal details  </h2>
<table>
<tr>
<th>APP</th>
<th>Startdate</th>
<th>EndDate</th>
<th>Thumbprint</th>
<th>Type</th>
</tr>
$diskreport3
</table>
<tr>
"

$report | Out-File "C:\temp\Azuread\data.html"

我试过了,但没有得到正确的指纹。 AzureAd 中的指纹不同

实际上,要求是 CSV 我们需要 App name start date expired date 和 thumbprint

您可以使用以下 PowerShell 脚本获取指纹及其到期时间。

$expired  =  Get-AzureADApplication  -All:$true  |  ForEach-Object {
$app  =  $_
@(
Get-AzureADApplicationKeyCredential  -ObjectId  $_.ObjectId
$CustomKeyIdentifier  = (Get-AzureADApplicationKeyCredential  -ObjectId  $_.ObjectID).CustomKeyIdentifier
)|  Where-Object {
$_.EndDate }|  ForEach-Object {
$id  =  "Not set"
if($CustomKeyIdentifier) {
$id  =  [System.Convert]::ToBase64String($CustomKeyIdentifier)
}
[PSCustomObject] @{
App =  $app.DisplayName
ObjectID =  $app.ObjectId
AppId =  $app.AppId
Type =  $_.GetType().name
KeyIdentifier =  $id
EndDate =  $_.EndDate
}
}
}
$expired  |  Export-CSV 'C:\test.csv'

Output: 在此处输入图像描述

参考: bash - 如何从 Azure 中的应用程序注册中获取数据,状态为即将过期 - 堆栈内存溢出

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM