尝试在PowerShell登录脚本中使用cmdkey在凭据管理器中存储凭据。当脚本从PowerShell运行时,一切都正常,但是当它作为登录脚本通过组策略运行时,一切都正常。我无法理解为什么cmdkey会在任何地方工作,除非脚本在登录时运行。
# Checks if CRM for Outlook is isntalled by checking the folder path
$installed = Test-Path "C:\Program Files (x86)\Microsoft Dynamics CRM"
# Checks if the CRM has already been configured using the CoreConfigured registry entry
$configured = Get-ItemProperty -Path HKCU:\software\Microsoft\MSCRMClient -Name "CoreConfigured"
# If CRM is installed and not configured, configure it, if CRM is not installed or installed and configured, exit
If ($installed -eq "True" -and $configured.CoreConfigured -ne 1) {
$message1 = New-object -ComObject Wscript.Shell
$message1.Popup("Preparing to configure Microsoft CRM for Outlook, please make sure Outlook is closed.",10,"Systems")
# Prompts user for email address and Password to configure CRM for Outlook
$c = Get-Credential -Message "To confgiure CRM, please enter your email address and password:"
# puts user credentials into Windows Credential Manager using required CRM URLs
cmdkey /generic:Microsoft_CRM_https://disco.crm.dynamics.com/ /user: $c.Username /pass: $c.Password | Out-Null
cmdkey /generic:Microsoft_CRM_https://disco.crm4.dynamics.com/ /user: $c.Username /pass: $c.Password | Out-Null
$message2 = New-Object -ComObject Wscript.Shell
$message2.Popup("Please wait, a notification will appear when the configuration is complete.",10,"Systems")
# Silenty runs the CRM configuration Wizard with custom XML file
$exe = "C:\Program Files (x86)\Microsoft Dynamics CRM\Client\ConfigWizard\Microsoft.Crm.Application.Outlook.ConfigWizard.exe"
&$exe -p /Q /i 'C:\Program Files (x86)\Microsoft Dynamics CRM\Default_Client_Config.xml' /xa /l 'c:\temp\crminstall.txt' | Out-Null
$message3 = New-Object -ComObject Wscript.Shell
$message3.Popup("Configuration complete! You may now open Outlook!",10,"Systems")
}
else {
exit
}发布于 2014-09-01 03:14:28
我猜想cmdkey正在使用Microsoft的数据保护API (DPAPI)加密凭据,因此只有当前用户才能检索它们。除非加载了用户的会话,否则不能使用此API。当您的脚本运行时,在登录过程中加载DPAPI所需的安全信息可能为时尚早。我不确定登录脚本是如何工作的,但是尝试在登录脚本中添加一个延迟,直到您得到一个值。
下面是使用DPAPI加密的PowerShell代码:
$scope = [Security.Cryptography.DataProtectionScope]::CurrentUser
$encryptedBytes = [Security.Cryptography.ProtectedData]::Protect( $plainBytes, $null, $scope )
$decryptedBytes = [Security.Cryptography.ProtectedData]::Unprotect( $encryptedBytes, $null, 0 )在logn脚本中添加一个循环,该循环试图加密/解密一些随机字节数组,直到成功为止。
发布于 2016-06-23 12:40:33
我也有同样的问题:在作为用户登录脚本运行时,cmdkey没有在Powershell中工作。
在我的例子中,这个问题与用户的组成员身份有关。用户是“超级用户”组的成员,但不是“用户”组(或任何其他组)的成员。
据这篇文章来自微软称,“超级用户”组没有“默认用户权限”,而组“用户”有权“执行常见任务,如使用本地和网络打印机运行应用程序”。
解决方案是将我的用户添加到“用户”组中。这立即解决了问题,并允许cmdkey在Powershell登录脚本中工作。
发布于 2017-08-01 17:38:10
在调用PowerShell GPO登录脚本cmdkey.exe时,我也遇到了同样的问题。凭据填充到用户的凭据管理器中,但管理员没有显示凭据。我发现凭据保存在凭据管理器中,但用于提升的用户。如果在提升的命令提示符中运行cmdkey /list,您将在其中看到凭据。
https://stackoverflow.com/questions/25383773
复制相似问题