大佬教程收集整理的这篇文章主要介绍了Windows – PowerShell DSC组资源 – “找不到具有提供名称的主体”,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
Configuration TestSetup { Node localhost { Group Administrators { GroupName = "Administrators" MembersToInclude = "MYDOMAIN\TheAdministratorsGroup" } } }
运行时,这会导致以下错误:
PowerSHell provider MSFT_Groupresource Failed to execute Test-Targetresource functionality with error message: Could not find a principal with the provided name [mydomain\theadministratorsgroup] + CategoryInfo : Invalidoperation: (:) [],CimException + FullyQualifiedErrorId : ProviderOperationExecutionFailure + PSComputerName : localhost
主体确实存在,我可以通过GUI手动添加它并使用Net localgroup.
我知道DSC配置在SYstem帐户下执行,所以我认为这可能是SYstem帐户想要查询Active Directory的权限问题.但是我使用PsExec运行cmd作为SYstem帐户,我能够毫无困难地将域组添加到本地管理员组.
@H_489_2@ @H_674_26@@H_489_2@获取凭据的方式:
$securedString = ConvertTo-SecureString -String $password -AsPlaintext -Force [PSCredential]$cred = New-Object System.Management.Automation.PSCredential ($UserName,$securedString)
这是您需要配置DSC资源的代码
$ConfigurationData = @{ AllNodes = @( @{ Nodename="*" PSDscAllowPlaintextpassword=$true } @{ Nodename="SRV2-WS2012R2" } @{ Nodename="SRV3-WS2012R2" } ) } Node $AllNodes.Nodename { LocalConfigurationManager { RebootNodeIfNeeded = $false } Group $group.Name { GroupName = $group.Name Ensure = $group.Ensure Members = $group.Members Credential = $cred } }
然后简单地执行
ProcessDscresources -ConfigurationData $ConfigurationData -OutputPath $folderPathTmp Start-DscConfiguration -Wait -Force -Path $folderPathTmp@H_489_2@@H_489_2@
以上是大佬教程为你收集整理的Windows – PowerShell DSC组资源 – “找不到具有提供名称的主体”全部内容,希望文章能够帮你解决Windows – PowerShell DSC组资源 – “找不到具有提供名称的主体”所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。