dsccommunity / xPSDesiredStateConfiguration

DSC resources for configuring common operating systems features, files and settings.
https://dsccommunity.org
MIT License
204 stars 132 forks source link

xRemoteFile does not work with PowerShell 7.2.1 #743

Open IlleNilsson opened 2 years ago

IlleNilsson commented 2 years ago

Problem description

When using Header property of xRemoteFile, creating MOF-file fails.

    Headers = @{ 'Accept-Language' = 'en-US' } # NOTE: This line does not work with newer versions than 5.1 of WindowsPowerShell

Verbose logs

-

DSC configuration

configuration SetupPSTools {
    param(
        [PSCredential]$SetupCredential,
        [string[]]$DependsOnResource
    )

    Import-DscResource -ModuleName xPSDesiredStateConfiguration -ModuleVersion 9.1.0
    Import-DscResource -ModuleName PSDesiredStateConfiguration

    $psToolsFileName = 'PSTools.zip'
    $psToolsUrl = "https://download.sysinternals.com/files/$psToolsFileName"
    $psToolsDestination = "C:\Users\Public\Downloads\$psToolsFileName"
    $psToolsFolder = '%ProgramFiles%\PSTools'

    # INFO: Unzip PSTools in Program Folder
    Archive 'PSTools' {
        PsDscRunAsCredential = $SetupCredential
        Path = $psToolsDestination
        Destination = $psToolsFolder
        DependsOn = @('[xRemoteFile]PSTools')
    }
    # INFO: Download PSTools Files to Download Folder
    xRemoteFile 'PSTools' {
        PsDscRunAsCredential = $SetupCredential
        Uri = $psToolsUrl
        DestinationPath = $psToolsDestination
        MatchSource = $true
        UserAgent = [Microsoft.PowerShell.Commands.PSUserAgent]::InternetExplorer
        Headers = @{ 'Accept-Language' = 'en-US' } # NOTE: This line does not work with newer versions than 5.1 of WindowsPowerShell
        DependsOn = $DependsOnResource
    }
}

Suggested solution

I have no idea

Operating system the target node is running

Windows 10, up to date

PowerShell version and build the target node is running

PowerShell 7.2.1

xPSDesiredStateConfiguration version

9.1.0
PlagueHO commented 2 years ago

Hi @IlleNilsson - thank you for raising this.

A few questions to help us diagnose this:

  1. Does an error occur when passing the headers or are they just ignored?
  2. Is the issue with the specific Accept-Language header or any header?

Thank you!

IlleNilsson commented 2 years ago

Hi Daniel,

I have reverted to PS 5.1 and can’t get the exact error message. But it looked like a buffer error saying unable to create mof while writing the headers to it.

I have only tried the header I reported.

BR // Ilian


From: Daniel Scott-Raynsford @.> Sent: Saturday, February 5, 2022 7:52:38 PM To: dsccommunity/xPSDesiredStateConfiguration @.> Cc: Ilian Nilsson @.>; Mention @.> Subject: Re: [dsccommunity/xPSDesiredStateConfiguration] xRemoteFile does not work with PowerShell 7.2.1 (Issue #743)

Hi @IlleNilssonhttps://github.com/IlleNilsson - thank you for raising this.

A few questions to help us diagnose this:

  1. Does an error occur when passing the headers or are they just ignored?
  2. Is the issue with the specific Accept-Language header or any header?

Thank you!

— Reply to this email directly, view it on GitHubhttps://github.com/dsccommunity/xPSDesiredStateConfiguration/issues/743#issuecomment-1030679536, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AID6F4BF5FC5BE5PB6ONJSDUZVWXNANCNFSM5NTTXH2A. Triage notifications on the go with GitHub Mobile for iOShttps://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Androidhttps://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub. You are receiving this because you were mentioned.Message ID: @.***>

PlagueHO commented 2 years ago

Thanks @IlleNilsson - It sounds like this error was occurring while compiling the MOF, rather than while running the code. Does that sound correct?

IlleNilsson commented 2 years ago

Yes that sound about right


From: Daniel Scott-Raynsford @.> Sent: Wednesday, February 9, 2022 2:40:26 AM To: dsccommunity/xPSDesiredStateConfiguration @.> Cc: Ilian Nilsson @.>; Mention @.> Subject: Re: [dsccommunity/xPSDesiredStateConfiguration] xRemoteFile does not work with PowerShell 7.2.1 (Issue #743)

Thanks @IlleNilssonhttps://github.com/IlleNilsson - It sounds like this error was occurring while compiling the MOF, rather than while running the code. Does that sound correct?

— Reply to this email directly, view it on GitHubhttps://github.com/dsccommunity/xPSDesiredStateConfiguration/issues/743#issuecomment-1033243008, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AID6F4GUPUV6KOCILYEO7FDU2HAYVANCNFSM5NTTXH2A. Triage notifications on the go with GitHub Mobile for iOShttps://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Androidhttps://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub. You are receiving this because you were mentioned.Message ID: @.***>