1

I'm using Sitecore 9 (Update 2) and have installed Powershell module as well.

Did anyone come across this while running the Unicorn task?

[09:10:57] Starting 'Sync-Unicorn'...
Error: C:\Sitecore\habitat\Habitat-1.6\scripts/Unicorn/./Sync.ps1 : File 
Error: C:\Sitecore\habitat\Habitat-1.6\scripts\Unicorn\Sync.ps1 cannot be loaded. The file 
C:\Sitecore\habitat\Habitat-1.6\scripts\Unicorn\Sync.ps1 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.
At line:1 char:1
+ C:\Sitecore\habitat\Habitat-1.6\scripts/Unicorn/./Sync.ps1 -secret 74 ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : SecurityError: (:) [], PSSecurityException
    + FullyQualifiedErrorId : UnauthorizedAccess
C:\Sitecore\habitat\Habitat-1.6\scripts\unicorn.js:44
    if (err !== null) throw err;
                      ^
Error: Command failed: powershell -executionpolicy unrestricted "C:\Sitecore\habitat\Habitat-1.6\scripts/Unicorn/./Sync.ps1 -secret 749CABBC85EAD20CE55E2C6066F1BE375D2115696C8A8B24DB6ED1FD60613086 -url https://habitat.sc/unicorn.aspx"
C:\Sitecore\habitat\Habitat-1.6\scripts/Unicorn/./Sync.ps1 : File 
C:\Sitecore\habitat\Habitat-1.6\scripts\Unicorn\Sync.ps1 cannot be loaded. The file 
C:\Sitecore\habitat\Habitat-1.6\scripts\Unicorn\Sync.ps1 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.
At line:1 char:1
+ C:\Sitecore\habitat\Habitat-1.6\scripts/Unicorn/./Sync.ps1 -secret 74 ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : SecurityError: (:) [], PSSecurityException
    + FullyQualifiedErrorId : UnauthorizedAccess
    at ChildProcess.exithandler (child_process.js:291:12)
    at ChildProcess.emit (events.js:182:13)
    at maybeClose (internal/child_process.js:961:16)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:248:5)
Process terminated with code 1.

I don't see the unblock option either and I tried setting the policy to unrestricted as well: enter image description here

4
  • Try typing Get-ExecutionPolicy in your prompt, and tell us what it returns. Also, are you running this sync process from the command line, or inside Visual Studio? if Visual Studio, that too needs to be run as administrator.
    – Mark Cassidy
    Aug 30 '18 at 13:50
  • I tried running the above script in vs and outside vs(in powershell) as well and both end up with same issue and yes VS is in Admin mode. So Get-ExecutionPolicy returns RemoteSigned.
    – Vamshi
    Aug 30 '18 at 13:59
  • Here is the List : MachinePolicy: RemoteSigned; UserPolicy: RemoteSigned Process : Undefined CurrentUser: RemoteSigned LocalMachine: Unrestricted
    – Vamshi
    Aug 30 '18 at 14:00
  • I've updated my answer
    – Mark Cassidy
    Aug 30 '18 at 14:09
5

Looks like you're running a non-admin Powershell console. Try running it as an admin user.

If that is not an option, you may need to unblock the script. Locate it in File Explorer and Unblock it.

enter image description here

Further reference: Unable To Run Downloaded PowerShell Script

Edited to add.

If none of this works, you're likely getting an ExecutionPolicy from your AD. You can override this with admin rights. Execute this, in a PowerShell console prompt.

be aware of the implications of doing this however

Set-ExecutionPolicy "Unrestricted" -Scope MachinePolicy -Confirm:$false Set-ExecutionPolicy "Unrestricted" -Scope UserPolicy -Confirm:$false Set-ExecutionPolicy "Unrestricted" -Scope Process -Confirm:$false Set-ExecutionPolicy "Unrestricted" -Scope CurrentUser -Confirm:$false

Source: Set-ExecutionPolicy : Windows PowerShell updated your execution policy successfully, but the setting is overridden by a policy defined at a more specific scope!!!

4
  • @Vamshi , also make sure that you have set the correct Execution Policy : Set-ExecutionPolicy -Scope CurrentUser Unrestricted Aug 30 '18 at 13:39
  • That is already part of his script though. powershell -executionpolicy unrestricted
    – Mark Cassidy
    Aug 30 '18 at 13:40
  • oh , I did not know that , thanks ! Aug 30 '18 at 13:42
  • @MarkCassidy - Please see my screenshot above. I don't see the unblock option on the file itself. Also I am running the powershell in Admin mode.
    – Vamshi
    Aug 30 '18 at 13:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.