unblock-file command not working

This topic contains 3 replies, has 2 voices, and was last updated by Profile photo of Peter Marsh Peter Marsh 4 months, 2 weeks ago.

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #38718
    Profile photo of Peter Marsh
    Peter Marsh
    Participant

    I am taking the Advanced Tools & Scripting with PowerShell 3.0 Jump Start course (Helmick & Snover), and I have downloaded Jason's scripts. However, the only way I can get these to run is to copy the setup script contents from notepad to the prompt in a PS console. I have unblocked the files, using Jeffry's command and see a verbose response that all files are unblocked. Every attempt to run these startup scripts still give an error message saying they are not digitally signed. I also examined thread # 18056 which gives some code to determine if a file is actually unblocked: that code indicates my startup scripts are indeed unblocked.
    Additional info: Windows 7 box running Powershell Ver 4.0. If I look at the "properties" of these files under Windows, I don't see a box marked "Blocked."
    Any suggestions? This is kind of a nuisance. Haven't tried running my own scripts yet...
    Peter Marsh

    #38719
    Profile photo of Christian Sandfeld
    Christian Sandfeld
    Participant

    Peter: From what you are describing, it does not sound like a problem with the Unblock-File Cmdlet, but rather that you have not configured the PowerShell ExecutionPolicy.

    Try running:

    Get-ExecutionPolicy

    It will likely to return "Restricted" (the default setting) or "AllSigned"

    For more about execution policies, check out:

    help about_Execution_Policies

    And for details on how to change the settings:

    help Set-ExecutionPolicy -Full
    #38737
    Profile photo of Peter Marsh
    Peter Marsh
    Participant

    I had scope localmachine set for remotesigned, but currentuser set for allsigned. From reading about_execution_policy, it appears the scope setting for currentuser over-rides the remotesigned setting, thus requiring my own scripts to be digitally signed. (Which I don't yet know how to do.) I changed the scope for Currentuser to remotesigned, and can now run simple scripts from the ISE console window. Should I eventually set the scope for localmachine to allsigned and provide my scripts with a verified digital signature?
    Peter

    #38911
    Profile photo of Peter Marsh
    Peter Marsh
    Participant

    I can now run scripts I have built. I will explore generating digital certificates later. Right now I'm practicing...

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.