Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

xRemoteFile fails to generate and execute with PowerShell 7 #739

Open
i2bglobal opened this issue Oct 31, 2021 · 0 comments
Open

xRemoteFile fails to generate and execute with PowerShell 7 #739

i2bglobal opened this issue Oct 31, 2021 · 0 comments

Comments

@i2bglobal
Copy link

i2bglobal commented Oct 31, 2021

Problem description

when running the example configuration to generate MOF

xRemoteFile_DownloadFile_Config -DestinationPath "$env:SystemDrive\fileName.jpg" -Uri 'http://www.contoso.com/image.jpg' -UserAgent [Microsoft.PowerShell.Commands.PSUserAgent]::InternetExplorer -Headers @{'Accept-Language' = 'en-US'}

I get this exception:

	 Invalid MOF definition for node 'localhost': Exception calling "ValidateInstanceText" with "1" argument(s): "Convert
		property 'Headers' value from type 'INSTANCE' to type 'INSTANCE[]' failed  At line:27, char:2  Buffer: wnloadFile_Config"; };^ insta "

Once the Headers is omitted then it works and generates the MOF file.
However when you run the push command 👍

Start-DscConfiguration –Path xRemoteFile_DownloadFile_Config –Wait -Force -Verbose

It errors out with this error:

	InvalidOperation: The PowerShell DSC resource DSC_xRemoteFile from module <xPSDesiredStateConfiguration,9.1.0> does not exist
	at the PowerShell module path nor is it registered as a WMI DSC resource.

Verbose logs

Invalid MOF definition for node 'localhost': Exception calling "ValidateInstanceText" with "1" argument(s): "Convert
			property 'Headers' value from type 'INSTANCE' to type 'INSTANCE[]' failed  At line:27, char:2  Buffer: wnloadFile_Config"; };^ insta "

		InvalidOperation: The PowerShell DSC resource DSC_xRemoteFile from module <xPSDesiredStateConfiguration,9.1.0> does not exist
		at the PowerShell module path nor is it registered as a WMI DSC resource.

DSC configuration

#Requires -Module xPSDesiredStateConfiguration
configuration xRemoteFile_DownloadFile_Config
{
    param
    (
        [Parameter(Mandatory = $true)]
        [ValidateNotNullOrEmpty()]
        [System.String]
        $DestinationPath,

        [Parameter(Mandatory = $true)]
        [ValidateNotNullOrEmpty()]
        [System.String]
        $Uri,

        [Parameter()]
        [System.String]
        $UserAgent,

        [Parameter()]
        [System.Collections.Hashtable]
        $Headers
    )

    Import-DscResource -ModuleName xPSDesiredStateConfiguration

    Node localhost
    {
        xRemoteFile DownloadFile
        {
            DestinationPath = $DestinationPath
            Uri             = $Uri
            UserAgent       = $UserAgent
            Headers         = $Headers
        }
    }
}

Suggested solution

Nope

Operating system the target node is running

OsName               : Microsoft Windows Server 2012 R2 Standard
OsOperatingSystemSKU : StandardServerEdition
OsArchitecture       : 64-bit
WindowsVersion       :
WindowsBuildLabEx    : 9600.20144.amd64fre.winblue_ltsb_escrow.211004-1908
OsLanguage           : en-US
OsMuiLanguages       : {en-US}

PowerShell version and build the target node is running

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

xPSDesiredStateConfiguration version

----                         ------- ----
xPSDesiredStateConfiguration 
9.1.0   C:\Users\SVC_RAView_Dev\Documents\PowerShell\Modules\xPSDesiredStateConfiguration\9.1.0\xPSDe.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant