Skip to content

Unblock-File provides no message if the file is ReadOnly (and thus fails) #4390

@Aprazeth

Description

@Aprazeth

Steps to reproduce

Using Pester;

        $TestPath = "TestDrive:\test.ps1"
        Set-Content -Path $TestPath -value 'Break'
        $ZoneIdentifier = {
            [ZoneTransfer]
            ZoneId=3
        }
        Set-Content -Path $Testpath -Value $ZoneIdentifier -Stream 'Zone.Identifier'
        Set-ItemProperty -Path $TestPath -Name IsReadOnly -Value $True
        .\Set-UnblockPS1.ps1 -Path $Testpath

Expected behavior

  • Warning/Error/Message (anything?) that the file has failed to be unblocked. Even a generic error would be useful - for example:
Write-Warning -Message "Skipping file $($file) as it is ReadOnly"

Alternative would be:

Write-Warning -Message: "Failed to unblock $($file)"

Actual behavior

No output (also not via -Verbose or -Debug) is given.

Environment data

> $PSVersionTable
Name                           Value
----                           -----
PSVersion                      6.0.0-beta
PSEdition                      Core
GitCommitId                    v6.0.0-beta.4
OS                             Microsoft Windows 10.0.16232
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0
> $PSVersionTable
Name                           Value
----                           -----
PSVersion                      5.1.16232.1000
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.16232.1000
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    Issue-BugIssue has been identified as a bug in the productResolution-FixedThe issue is fixed.WG-Cmdlets-Utilitycmdlets in the Microsoft.PowerShell.Utility module

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions