Unblock-File not unblocking file

This topic contains 3 replies, has 3 voices, and was last updated by Profile photo of Ben van Zanten Ben van Zanten 1 year, 10 months ago.

  • Author
    Posts
  • #18056
    Profile photo of Brian Burki
    Brian Burki
    Participant

    Hello!

    Working hard to learn Powershell and could use some help.

    Trying to set up a Powershell FTP Client I found here:

    http://gallery.technet.microsoft.com/scriptcenter/PowerShell-FTP-Client-db6fe0cb/

    Module is in the right place (as far as I know)

    [blockquote]%USERPROFILE%\Documents\WindowsPowerShell\Modules
    %WINDIR%\System32\WindowsPowerShell\v1.0\Modules[/blockquote]

    I run the Cmdlet

    [blockquote]Import-Module -name "PSFTP"[/blockquote]

    And get this error

    [blockquote]Import-Module : Errors occurred while loading the format data file:
    C:\Users\Dell T7400\Documents\WindowsPowerShell\Modules\PSFTP\PSFTP.Format.ps1xml, , C:\Users\Dell
    T7400\Documents\WindowsPowerShell\Modules\PSFTP\PSFTP.Format.ps1xml: The file was skipped because of the following validation
    exception: File C:\Users\Dell T7400\Documents\WindowsPowerShell\Modules\PSFTP\PSFTP.Format.ps1xml cannot be loaded. The file
    C:\Users\Dell T7400\Documents\WindowsPowerShell\Modules\PSFTP\PSFTP.Format.ps1xml is not digitally signed. You cannot run this script
    on the current system. For more information about running scripts and setting execution policy, see about_Execution_Policies at
    http://go.microsoft.com/fwlink/?LinkID=135170..[/blockquote]

    I read the Execution Policies page here

    http://technet.microsoft.com/library/hh847748.aspx

    That says to run Unblock-File if my Execution Policy is RemoteSigned, which it is.

    [blockquote]Unblock-File -Path "C:\Users\Dell T7400\Documents\WindowsPowerShell\Modules\PSFTP\PSFTP.Format.ps1xml"[/blockquote]

    I run this without error

    But when I run the same Import-Module Cmdlet I still get the same error.

    [blockquote]Import-Module : Errors occurred while loading the format data file:
    C:\Users\Dell T7400\Documents\WindowsPowerShell\Modules\PSFTP\PSFTP.Format.ps1xml, , C:\Users\Dell
    T7400\Documents\WindowsPowerShell\Modules\PSFTP\PSFTP.Format.ps1xml: The file was skipped because of the following validation
    exception: File C:\Users\Dell T7400\Documents\WindowsPowerShell\Modules\PSFTP\PSFTP.Format.ps1xml cannot be loaded. The file
    C:\Users\Dell T7400\Documents\WindowsPowerShell\Modules\PSFTP\PSFTP.Format.ps1xml is not digitally signed. You cannot run this script
    on the current system. For more information about running scripts and setting execution policy, see about_Execution_Policies at
    http://go.microsoft.com/fwlink/?LinkID=135170..[/blockquote]

    Any ideas?

    Thanks!

  • #18057
    Profile photo of Dave Wyatt
    Dave Wyatt
    Moderator

    Are you using PowerShell 3.0 or later? If so, you can quickly tell whether that file is still blocked by running this command:

    Get-Content -Path 'C:\Users\Dell T7400\Documents\WindowsPowerShell\Modules\PSFTP\PSFTP.Format.ps1xml' -Stream Zone.Identifier
    

    If you get an error that says it couldn't open the alternate data stream Zone.Identifier, then the file is not blocked. If it says:

    [ZoneTransfer]
    ZoneId=3
    

    then the file is, indeed, still blocked for some reason. You could try this command to unblock it, though this should be doing exactly the same thing as Unblock-File, and may fail for the same reason (whatever that reason happens to be):

    Remove-Item -Path 'C:\Users\Dell T7400\Documents\WindowsPowerShell\Modules\PSFTP\PSFTP.Format.ps1xml' -Stream Zone.Identifier
    
  • #19112
    Profile photo of Brian Burki
    Brian Burki
    Participant

    Thanks for your response!

    I ran the first command and got the "couldn't open the alternate..." response to it's apparently not blocked. But when I try and use a cmdlet that the module author specifies like "Set-FTPConnection" I get the error:

    "The term 'Set-FTPConnection' is not recognized as the name of a cmdlet"

    Thanks for you help!

  • #22402
    Profile photo of Ben van Zanten
    Ben van Zanten
    Participant

    I've found the same issue while preparing for a PowerShell demo

    it really looks like PowerShell is caching the info.

    When I try to run a file, get the 'digitally signed' error, then unblock the file.
    Still I cannot immediately run the unblocked file.

    The file IS unblocked.
    If I start a new powershell shell, the file can run..
    it looks as if the first failed run is cached in the powershell session, would like to know how to clear that.

    till then, the workaround is : start a new shell

You must be logged in to reply to this topic.