Unblock a file with PowerShell?

前端 未结 13 1756
野性不改
野性不改 2020-12-08 02:52

I am trying to have PowerShell unblock a file in Win2K8 R2.

Does anyone have a pointer as to the syntax?

相关标签:
13条回答
  • 2020-12-08 03:11

    If you are using PowerShell 3.0 or above vesion, Unblock-file PowerShell cmdlet should solve this problem with unblocking the file, even though if you don't have unblock button on the file properties window.

    The Unblock-File cmdlet lets you open files that were downloaded from the Internet. It unblocks Windows PowerShell script files that were downloaded from the Internet so you can run them, even when the Windows PowerShell execution policy is RemoteSigned. By default, these files are blocked to protect the computer from untrusted files.

    Just open the powerShell window and follow below syntax. To find more information about the syntax go to here

    Example :

    unblock-file -path C:\Downloads\MyFileName.chm
    

    Unblock file with PowerShell screen shot

    Warning: Do not unblock unsecure files.

    0 讨论(0)
  • 2020-12-08 03:12

    The PoshCode module includes Set-DownloadFlag and Remove-DownloadFlag functions which work as advertised. :) I've just pulled that piece out into it's own script contribution http://poshcode.org/1430 ... it will work on PowerShell 1 too, if you use the New-Type function in place of Add-Type ( http://poshcode.org/720 )

    0 讨论(0)
  • 2020-12-08 03:14

    new to posting in forums like this and this might be an old topic but here is what you are looking for.

    get-item -Path "path to file(s)" -Stream "Zone.Identifier" -ErrorAction "SilentlyContinue"
    

    This should list out files that are blocked only.

    Unblock-File -Path "Path to blocked file(s)"
    

    This will unblock them.

    0 讨论(0)
  • 2020-12-08 03:17

    Remove the alternate file stream using Streams.exe see this post: http://www.paraesthesia.com/archive/2010/05/19/unblocking-multiple-files-at-once.aspx

    0 讨论(0)
  • 2020-12-08 03:17

    To unblock a folder and it's subfolder recursive (>= PowerShell v3) you can use the Get-ChildItem (gci) command:

    Get-ChildItem "C:\Temp\" -recurse | Unblock-File
    

    where C:\Temp is the starting folder.

    0 讨论(0)
  • Do you mean this:

    set-executionpolicy remotesigned
    

    This will allow you to execute local scripts without them being signed, and remote ones if they are signed. More info available here.

    0 讨论(0)
提交回复
热议问题