Server 2016 - The filename or extension is too long

This topic contains 10 replies, has 3 voices, and was last updated by Profile photo of David David 1 day, 3 hours ago.

  • Author
    Posts
  • #72565
    Profile photo of Zuldan
    Zuldan
    Participant

    I've got a really weird issue (according to Google I'm the only one who has this issue with DSC and 2016) and I'm having a really hard time trying to figure out how to diagnose this.

    I have a DSC configuration that runs perfectly on Server 2012 R2 (WMF 5.1) but when I run the exact same configuration on Server 2016 and use PsDscRunAsCredential in a resource, I get "Invoke-CimMethod : The filename or extension is too long". So to summarize.

    2012 R2, resources with PsDscRunAsCredential = works
    2012 R2, resources without PsDscRunAsCredential = works
    2016, resources with PsDscRunAsCredential = fails
    2016, resources without PsDscRunAsCredential = works

    VERBOSE: [LABSERVER01]: LCM:  [ Start  Resource ]  [[Script]DisableFirewall]
    VERBOSE: [LABSERVER01]: LCM:  [ Start  Test     ]  [[Script]DisableFirewall]
    VERBOSE: [LABSERVER01]: LCM:  [ End    Test     ]  [[Script]DisableFirewall]  in 0.0320 seconds.
    Invoke-CimMethod : The filename or extension is too long
    At C:\Lab\Invoke-LabTest.ps1:20 char:5
    +     Invoke-CimMethod -CimSession $ServerName -Name PerformRequiredCon ...
    +     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : AuthenticationError: (:) [Invoke-CimMethod], CimException
        + FullyQualifiedErrorId : Win32Error:206,Microsoft.Management.Infrastructure.CimCmdlets.InvokeCimMethodCommand
        + PSComputerName        : LABSERVER01

    Even though I do not believe it's a path length issue I've enabled long path support (https://blogs.msdn.microsoft.com/jeremykuhne/2016/07/30/net-4-6-2-and-long-paths-on-windows-10/). This error still persists.

    I've also tried to diagnose the issue using all the tips from https://msdn.microsoft.com/en-us/powershell/dsc/troubleshooting but I can't find anything in event logs that would point to what part of DSC is having the issue.

    I'm using certificates to encrypt the password as per (https://msdn.microsoft.com/en-us/powershell/dsc/securemof). I double checked my certificate settings against what they should be and everything is 100% correct. I thought maybe the Subject name was over 260 characters but it's not.

    The DSC configuration is using partial configurations.

    This is driving me nuts! sorry if this sounds a bit confusing. Happy to clarify anything. Any pointers as to what the issue may be would be greatly appreciated.

    Name                           Value
    ----                           -----
    PSVersion                      5.1.14393.693
    PSEdition                      Desktop
    PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
    BuildVersion                   10.0.14393.693
    CLRVersion                     4.0.30319.42000
    WSManStackVersion              3.0
    PSRemotingProtocolVersion      2.3
    SerializationVersion           1.1.0.1
  • #72566
    Profile photo of Zuldan
    Zuldan
    Participant

    Below is what happens in event log.

    Log Name:      Microsoft-Windows-DSC/Operational
    Source:        Microsoft-Windows-DSC
    Date:          12/06/2017 3:10:05 PM
    Event ID:      4321
    Task Category: None
    Level:         Information
    Keywords:      
    User:          SYSTEM
    Computer:      LABSERVER01.lab.local
    Description:
    Job {62B02027-4F2D-11E7-B30A-005056B62440} : 
     PsDscRunAsCredential has been specified. The user name is MYLAB\labuser01.
    Log Name:      Microsoft-Windows-DSC/Operational
    Source:        Microsoft-Windows-DSC
    Date:          12/06/2017 3:10:05 PM
    Event ID:      4097
    Task Category: Send configuration scenario for Local configuration manager
    Level:         Error
    Keywords:      
    User:          SYSTEM
    Computer:      LABSERVER01.lab.local
    Description:
    Job {62B02027-4F2D-11E7-B30A-005056B62440} : 
    This event indicates that failure happens when LCM is processing the configuration. Error Id is 0x1. Error Detail is The SendConfigurationApply function did not succeed.. Resource Id is [Script]DisableFirewall and Source Info is C:\Lab\BaseServerConfig.ps1::175::13::Script. Error Message is The filename or extension is too long.
    Log Name:      Microsoft-Windows-DSC/Operational
    Source:        Microsoft-Windows-DSC
    Date:          12/06/2017 3:10:05 PM
    Event ID:      4252
    Task Category: None
    Level:         Error
    Keywords:      
    User:          SYSTEM
    Computer:      LABSERVER01.lab.local
    Description:
    Job {62B02027-4F2D-11E7-B30A-005056B62440} : 
    MIResult: 1
    Error Message: The filename or extension is too long
    Message ID: Win32Error:206
    Error Category: 28
    Error Code: 1
    Error Type: MI
  • #72568
    Profile photo of Zuldan
    Zuldan
    Participant

    and here are the MOF files that are applied to the target node.

    /*
    @TargetNode='LABSERVER01'
    @GeneratedBy=labuser01
    @GenerationDate=06/12/2017 15:29:36
    @GenerationHost=ITSERVER01
    */
    
    instance of MSFT_Credential as $MSFT_Credential1ref
    {
    Password = "-----BEGIN CMS-----\nMIIBpAYJKoZIhvcNAQcDoIIBlTCCAZECAQAxggFMMIIBSAIBADAwMBwxGjAYBgNVBAMMEURzY0Vu\nY3J5cHRpb25DZXJ0AhA95yX386E/sUG6QaOXtPL7MA0GCSqGSIb3DQEBBzAABIIBABg1oz7X+5hs\n3vvOu6RARXoEiDNG4REI3IHDH2O8Jgbt3t0Qn3GWDySwzvCkXv+RK4L6kw1EePi7+amL1DSi043B\nz3DSwVaEtuuh1XFyDyAZDH1dRdDol7stE+Tc6WGrTRYnWCpSQGcRb1oX8CC5ktiM0xmzoIQI/HI0\nzZXUU7+uuui2KxMv8i0JJcLhpMNy88Suxd0u45oxZVRUy8ijTWIyK4wVvpLXGi7r37EmaRzuAYKN\nMv8oX4kufMhXjEfVro/+IqILvg3TwcIR/oYMUW8YM5a0tqx8LstMqjWBwBXtngj8rjLnd5MDOaQd\nR3Q3GadrgYRvLu4oRlstdi24Ag8wPAYJKoZIhvcNAQcBMB0GCWCGSAFlAwQBKgQQXnKzEmh1CV/p\niYKHILrmgIAQA0wVOWKipc8zCdIcjSj+jA==\n-----END CMS-----";
     UserName = "LAB\\labuser01";
    
    };
    
    instance of MSFT_ScriptResource as $MSFT_ScriptResource1ref
    {
    ResourceID = "[Script]DisableFirewall";
     PsDscRunAsCredential = $MSFT_Credential1ref;
     GetScript = "\n                    @{\n                        GetScript = $GetScript\n                        SetScript = $SetScript\n                        TestScript = $TestScript\n                        Result = -not('True' -in (Get-NetFirewallProfile -All).Enabled)\n                    }\n                ";
     TestScript = "\n                    $Status = -not('True' -in (Get-NetFirewallProfile -All).Enabled)\n                    $Status -eq $True\n                ";
     SourceInfo = "C:\\Program Files\\WindowsPowerShell\\Modules\\PSDSCConfigManager\\Files\\Roles\\BaseServer\\BaseServerConfig.ps1::177::13::Script";
     SetScript = "\n                    Set-NetFirewallProfile -All -Enabled False -Verbose\n                ";
     ModuleName = "PSDesiredStateConfiguration";
    
    ModuleVersion = "0.0";
    
     ConfigurationName = "BaseServerConfig";
    
    };
    instance of OMI_ConfigurationDocument
    
    
                        {
     Version="2.0.0";
     
    
                            MinimumCompatibleVersion = "2.0.0";
     
    
                            CompatibleVersionAdditionalProperties= {"Omi_BaseResource:ConfigurationName"};
     
    
                            Author="labuser01";
     
    
                            GenerationDate="06/12/2017 15:29:36";
     
    
                            GenerationHost="ITSERVER01";
    
    
                            ContentType="PasswordEncrypted";
     
    
                            Name="BaseServerConfig";
    
    
                        };
    /*
    @TargetNode='LABSERVER01'
    @GeneratedBy=labuser01
    @GenerationDate=06/12/2017 15:29:32
    @GenerationHost=ITSERVER01
    */
    
    instance of MSFT_RegistryResource as $MSFT_RegistryResource1ref
    {
    ResourceID = "[Registry]EnforcerBaseFileServerConfigBuild";
     ValueName = "EnforcerRoleBaseFileServerConfigBuild";
     Key = "HKEY_LOCAL_MACHINE\\SOFTWARE\\MyCompany";
     Ensure = "Present";
     Force = True;
     SourceInfo = "C:\\Program Files\\WindowsPowerShell\\Modules\\PSDSCConfigManager\\Files\\Roles\\BaseFileServer\\BaseFileServerConfig.ps1::9::9::Registry";
     ValueType = "String";
     ModuleName = "PSDesiredStateConfiguration";
     ValueData = {
        "1000"
    };
    
    ModuleVersion = "1.0";
    
     ConfigurationName = "BaseFileServerConfig";
    
    };
    instance of MSFT_xWindowsFeature as $MSFT_xWindowsFeature1ref
    {
    ResourceID = "[xWindowsFeature]DHCPServer";
     Ensure = "Present";
     SourceInfo = "C:\\Program Files\\WindowsPowerShell\\Modules\\PSDSCConfigManager\\Files\\Roles\\BaseFileServer\\BaseFileServerConfig.ps1::80::9::xWindowsFeature";
     Name = "DHCP";
     ModuleName = "xPSDesiredStateConfiguration";
     ModuleVersion = "6.2.0.1";
    
     ConfigurationName = "BaseFileServerConfig";
    
    };
    instance of OMI_ConfigurationDocument
    
    
                        {
     Version="2.0.0";
     
    
                            MinimumCompatibleVersion = "1.0.0";
     
    
                            CompatibleVersionAdditionalProperties= {"Omi_BaseResource:ConfigurationName"};
     
    
                            Author="labuser01";
     
    
                            GenerationDate="06/12/2017 15:29:32";
     
    
                            GenerationHost="ITSERVER01";
     
    
                            Name="BaseFileServerConfig";
    
    
                        };
  • #72571
    Profile photo of Zuldan
    Zuldan
    Participant

    and LCM config

    Name                           Value                                                                                                                                                                                                                             
    ----                           -----                                                                                                                                                                                                                             
    CertThumbprint                 4D86AA6709937368FA8EF3034F7B764F0B942F42                                                                                                                                                                                          
    Secure                         True                                                                                                                                                                                                                              
    ServerName                     LABSERVER01                                                                                                                                                                                                                   
    Verbose                        False                                                                                                                                                                                                                             
    RebootIfNeeded                 True                                                                                                                                                                                                                              
    DebugMode                      NONE                                                                                                                                                                                                                              
    OutputPath                     C:\Users\labuser01\AppData\Local\Temp\7                                                                                                                                                                                            
    ConfigurationID                206f79b4-72fc-4dd6-85af-3f94f5130b47                                                                                                                                                                                              
    RefreshFrequencyMins           120                                                                                                                                                                                                                               
    ConfigurationModeFrequencyMins 60                                                                                                                                                                                                                                
    ConfigurationMode              ApplyAndAutoCorrect   
    
    [DSCLocalConfigurationManager()]
    Configuration PSDSCManagerLCM
    {
        param
            (
                [Parameter(Mandatory = $True)]
                [string[]]$ServerName,
    
                [Parameter(Mandatory = $True)]
                [string]$ConfigurationID,
    
                [Parameter(Mandatory = $True)]
                [string]$CertThumbprint,
    
                [Parameter(Mandatory = $True)]
                [ValidateSet('ApplyAndAutoCorrect','ApplyAndMonitor','ApplyOnly')]
                [string]$ConfigurationMode,
    
                [int]$RefreshFrequencyMins,
    
                [int]$ConfigurationModeFrequencyMins,
    
                [Parameter(Mandatory = $True)]
                [ValidateSet('All','ForceModuleImport','None','ResourceScriptBreakAll')]
                [string]$DebugMode,
    
                [Parameter(Mandatory = $True)]
                [switch]$Secure,
    
                [switch]$RebootIfNeeded
            )
    
        switch ($Secure)
        {
            $False { 
                $HTTPType = 'http' 
            }
            $True { 
                $HTTPType = 'https' 
            }
        }
                 	
    	Node $ServerName {
    		Settings
            {
    			AllowModuleOverwrite           = $True
                ConfigurationMode              = $ConfigurationMode
    			RefreshMode                    = 'Pull'
                RefreshFrequencyMins           = $RefreshFrequencyMins
                RebootNodeIfNeeded             = $RebootIfNeeded
                ActionAfterReboot              = 'ContinueConfiguration'
                ConfigurationModeFrequencyMins = $ConfigurationModeFrequencyMins
    			ConfigurationID                = $ConfigurationID
                CertificateID                  = $CertThumbprint
                DebugMode                      = $DebugMode
            }
    
            ConfigurationRepositoryWeb PSDSCManagerConfigurationRepositoryWeb 
            {
                ServerURL               = "$($HTTPType)://$($PSDSCManagerPullServerFQDN):8080/PSDSCPullServer.svc"
                AllowUnsecureConnection = -not($Secure)
            }
    
            ResourceRepositoryWeb PSDSCManagerResourceRepositoryWeb
            {
                ServerURL               = "$($HTTPType)://$($PSDSCManagerResourceServerFQDN):8080/PSDSCPullServer.svc"
                AllowUnsecureConnection = -not($Secure)
            }
    
            ReportServerWeb PSDSCManagerReportServerWeb
            {
                ServerURL               = "$($HTTPType)://$($PSDSCManagerReportServerFQDN):8080/PSDSCPullServer.svc"
                AllowUnsecureConnection = -not($Secure)
            }
    
            PartialConfiguration BaseFileServerConfig
            {
                Description = 'Test description'
                ConfigurationSource = '[ConfigurationRepositoryWeb]PSDSCManagerConfigurationRepositoryWeb'
                ResourceModuleSource = '[ResourceRepositoryWeb]PSDSCManagerResourceRepositoryWeb'
                DependsOn = '[PartialConfiguration]BaseServerConfig'
            }
            PartialConfiguration BaseServerConfig
            {
                Description = 'Test description'
                ConfigurationSource = '[ConfigurationRepositoryWeb]PSDSCManagerConfigurationRepositoryWeb'
                ResourceModuleSource = '[ResourceRepositoryWeb]PSDSCManagerResourceRepositoryWeb'
            }
     	}
    }
  • #72674
    Profile photo of Mark Gray (MSFT)
    Mark Gray (MSFT)
    Participant

    Zuldan,

    Can you see if you can duplicate this issue on a 2016 server that has the latest updates? From the version information that you posted here, it looks like this system is not up to date on patches.

    I was NOT able to reproduce this on a 2016 Core server with the following:
    PS C:\Configs> $PSVersionTable

    Name Value
    —- —–
    PSVersion 5.1.14393.1198
    PSEdition Desktop
    PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
    BuildVersion 10.0.14393.1198
    CLRVersion 4.0.30319.42000
    WSManStackVersion 3.0
    PSRemotingProtocolVersion 2.3
    SerializationVersion 1.1.0.1

    If you still have the issue after updating, please gather troubleshooting info as follows and forward to me directly:
    https://github.com/PowerShell/xdscdiagnostics#gather-diagnostics-from-the-machine-running-dsc-or-dsc-extension

    MarkG

  • #72677
    Profile photo of Zuldan
    Zuldan
    Participant

    Mark thank you for the very quick response. I did manually install the May CU and noticed the WMF build number increase from the 1607 ISO install. I'll connect the server directly to the Internet today and grab all the latest patches.

  • #72725
    Profile photo of Zuldan
    Zuldan
    Participant

    Mark, the server is now fully up-to-date but the issue still persist. I've got the logs now, how can I get them directly to you? Mark dot Grey at Microsoft ok?

    PS C:\windows\system32> $PSVersionTable

    Name Value
    —- —–
    PSVersion 5.1.14393.1198
    PSEdition Desktop
    PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
    BuildVersion 10.0.14393.1198
    CLRVersion 4.0.30319.42000
    WSManStackVersion 3.0
    PSRemotingProtocolVersion 2.3
    SerializationVersion 1.1.0.1

  • #72773
    Profile photo of Mark Gray (MSFT)
    Mark Gray (MSFT)
    Participant

    Yes, just make sure to spell my last name correctly 🙂

  • #72800
    Profile photo of Zuldan
    Zuldan
    Participant

    My apologies Mark. I had a colleague with a surname with the spelling of Grey 😉 Email has been sent.

  • #73267
    Profile photo of Zuldan
    Zuldan
    Participant

    @Mark, I'd like to report back I've had some success. I generated the MOF file on a 2016 server instead of the 2012 R2 server (running WMF 5.1) and now the "The filename or extension is too long" no longer appears on my 2016 node. I'm going to do some more testing but so far it's looking good.

    Can you see any reason why MOF generation is different on 2016 WMF 5.1 vs 2012 R2 WMF 5.1?

  • #73541
    Profile photo of David
    David
    Participant

    I am experiencing a similar issue, although I'm generating the MOF on 2012 R2 and it is being applied to a 2012 R2 target node. The PS version is 5.1.14393.1198 for both servers.
    I found that it was the encrypted password (used by PSDscRunAsCredential) in the MOF that it's complaining about being too long. Not encrypting the password allowed DSC to apply, and manually shortening the encrypted password in the MOF meant DSC wouldn't throw the same "the filename or extension is too long" error, instead it just complained about the password/username being incorrect, as expected.
    So it seems that the PSDscRunAsCredential parameter has a limit to the length, even when its an encrypted password?
    Any help would be appreciated.

You must be logged in to reply to this topic.