dsccommunity / ActiveDirectoryDsc

This module contains DSC resources for deployment and configuration of Active Directory Domain Services.
MIT License
345 stars 142 forks source link

ResourceName: ADServicePrincipalName After PSGallery installation of ActiveDirectoryDsc a simple use case of the configuration returns the "does not exist at the PowerShell module path nor is it registered as a WMI DSC" error #697

Closed PhilBlackRose closed 1 year ago

PhilBlackRose commented 1 year ago

Problem description

See #120 for a similar error but same cause seemingly eliminated.

My Use case is 'PUSH' so I am running Powershell commands directly on the target to apply the configuration, in an elevated Powershell Prompt.

Following are similar checks requested from the linked prior issue:

PS F:\DSC> Get-DscResource -Module ActiveDirectoryDsc -Name ADServicePrincipalName | Format-List

ImplementationDetail : ScriptBased
ResourceType         : MSFT_ADServicePrincipalName
Name                 : ADServicePrincipalName
FriendlyName         : ADServicePrincipalName
Module               : ActiveDirectoryDsc
ModuleName           : ActiveDirectoryDsc
Version              : 6.2.0
Path                 : C:\Program Files\PowerShell\Modules\ActiveDirectoryDsc\6.2.0\DscResources\MSFT_ADServicePrincipalName\MSFT_ADServicePrincipalName.psm1
ParentPath           : C:\Program Files\PowerShell\Modules\ActiveDirectoryDsc\6.2.0\DscResources\MSFT_ADServicePrincipalName
ImplementedAs        : PowerShell
CompanyName          : DSC Community
Properties           : {ServicePrincipalName, Account, DependsOn, Ensure…}

Other checks:

Verbose logs

PS F:\DSC> Start-DscConfiguration -Path 'F:\DSC\DoServiceAccountSPNs' -Wait -Verbose -Force
InvalidOperation: The PowerShell DSC resource MSFT_ADServicePrincipalName from module <ActiveDirectoryDsc,6.2.0> does not exist at the PowerShell module path nor is it registered as a WMI DSC resource.

DSC configuration

Configuration DoServiceAccountSPNs
{

    Import-DscResource -ModuleName 'PSDesiredStateConfiguration'
    Import-DscResource -ModuleName PSDscResources
    Import-DscResource -ModuleName ActiveDirectoryDsc

    Node localhost
    {
        ADServicePrincipalName 'BoServiceAccountSPNs'
        {
            ServicePrincipalName = 'MYSPNPREFIX/myserviceaccount.mydomain.com'
            Account = 'myserviceaccount'
        }
    }

}

DoServiceAccountSPNs -OutputPath:"./DoServiceAccountSPNs"

Suggested solution

I am pretty sure this is an issue with my configuration or versions as I'm new to this and it is a new level of dependency hell I haven't experienced before.

Operating system the target node is running

OsName               : Microsoft Windows Server 2022 Standard
OsOperatingSystemSKU : StandardServerEdition
OsArchitecture       : 64-bit
WindowsVersion       : 2009
WindowsBuildLabEx    : 20348.1.amd64fre.fe_release.210507-1500
OsLanguage           : en-US
OsMuiLanguages       : {en-US}

PowerShell version and build the target node is running

PS F:\DSC> $PSVersionTable

Name                           Value
----                           -----
PSVersion                      7.2.11
PSEdition                      Core
GitCommitId                    7.2.11
OS                             Microsoft Windows 10.0.20348
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

ActiveDirectoryDsc version

Name               Version Path
----               ------- ----
ActiveDirectoryDsc 6.2.0   C:\Program Files\PowerShell\Modules\ActiveDirectoryDsc\6.2.0\ActiveDirectoryDsc.psd1
stale[bot] commented 1 year ago

This issue has been automatically marked as stale because it has not had activity from the community in the last 30 days. It will be closed if no further activity occurs within 10 days. If the issue is labelled with any of the work labels (e.g bug, enhancement, documentation, or tests) then the issue will not auto-close.

phunkyg commented 1 year ago

FWIW I believe the issue was in using Powershell 7 with our setup as reverting to the preinstalled PS seemed to enable DSC.

johlju commented 1 year ago

PowerShell 7 does not include support for DSC resources, must use Windows PowerShelll. In the future with DSCv3 it could be possible, see PS Team talk about it here:

Watch the video

johlju commented 1 year ago

Closing this as this is not something we can resolve in this repository.