当前位置:网站首页 > 更多 > 玩电脑 > 正文

[玩转系统] 如何使用 PowerShell 从 SharePoint 中的 Secure Store Service 恢复凭据?

作者:精品下载站 日期:2024-12-14 14:06:37 浏览:14 分类:玩电脑

如何使用 PowerShell 从 SharePoint 中的 Secure Store Service 恢复凭据?


那么,前任 SharePoint 管理员离开时没有记录 SharePoint 安全存储服务密码吗?遗憾的是,无法从管理中心站点的 SharePoint 安全存储服务获取存储的用户名和密码。

[玩转系统] 如何使用 PowerShell 从 SharePoint 中的 Secure Store Service 恢复凭据?

不用担心,让我们使用 PowerShell 来解密 SharePoint 安全存储服务中存储的所有用户名和密码。

PowerShell 从 Secure Store Service 获取凭据:

以下是用于从 SharePoint 安全存储检索已保存凭据的 PowerShell 脚本。


Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue

#Any web application associated with SSS proxy application or central admin
$WebAppURL="https://intranet.crescent.com"

#Establish the Context
$Provider = New-Object Microsoft.Office.SecureStoreService.Server.SecureStoreProvider
$Provider.Context =  Get-SPServiceContext -Site $WebAppURL
 
#Get All Target Applications
$TargetApps = $provider.GetTargetApplications()
foreach ($App in $TargetApps)
{
    Write-Output $App.Name
    
    #Get the credentials for the App
    $Credentials = $provider.GetCredentials($App.Name)
    foreach ($Cred in $Credentials)
    {
        $EncryptString  = [System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($cred.Credential)
        $DecryptString  = [System.Runtime.InteropServices.Marshal]::PtrToStringBSTR($EncryptString)
 
        Write-Output "$($cred.CredentialType): $($DecryptString)"
    }
 }

您需要 登录账户 后才能发表评论

取消回复欢迎 发表评论:

关灯