-
Notifications
You must be signed in to change notification settings - Fork 170
Conversation
Fix #472 Add ExecutionPolicy Bypass to spawned powershell process so powershell modules can be loaded
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't believe that "Bypass" as an ExecutionPolicy is available on PowerShell 2, which is still supported as it is the default on Windows 7 and Server 2008 R2. This would break this shortcut on those systems.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the effort, if you can make a couple of modifications I think we can look at taking this in. References to "-verb runas" should be removed so that elevation is no longer required.
@@ -9,11 +9,11 @@ Try { | |||
|
|||
if ( test-path $conemulocation ) | |||
{ | |||
start-process $conemulocation -verb runas -argumentlist '/title',"`"$chefdktitle`"",'/cmd','powershell.exe','-noexit','-command',$chefdkcommand | |||
start-process $conemulocation -verb runas -argumentlist '-ExecutionPolicy Bypass','/title',"`"$chefdktitle`"",'/cmd','powershell.exe','-noexit','-command',$chefdkcommand |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These arguments are in the wrong order. Removing the "-verb runas", we should be left with:
start-process $conemulocation -argumentlist '/title',"`"$chefdktitle`"",'/cmd','powershell.exe','-ExecutionPolicy Bypass','-noexit','-command',$chefdkcommand
} | ||
else | ||
{ | ||
start-process powershell.exe -verb runas -argumentlist '-noexit','-command',"$chefdkcommand; (get-host).ui.rawui.windowtitle = '$chefdktitle'" | ||
start-process powershell.exe -verb runas -argumentlist '-ExecutionPolicy Bypass','-noexit','-command',"$chefdkcommand; (get-host).ui.rawui.windowtitle = '$chefdktitle'" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be something like:
start-process powershell.exe -argumentlist '-ExecutionPolicy Bypass','-noexit','-command',"$chefdkcommand; (get-host).ui.rawui.windowtitle = '$chefdktitle'"
@smurawski Now that we are no longer obliged to support Windows 7 and Windows 2008 R2 I am inclined to take this in so that we can get rid of the requirement to elevate on Windows 10 systems. The set of users using Windows 7 with the latest ChefDK should be smaller than those using Windows 10. |
@bastianschwarz Also are you able to add your DCO Signed-off-by to your commit? Thanks! |
I'm going to close this out since we haven't heard from the author since @stuartpreston reached out in Jan. If you want to see this merged in please take a look at the comments @bastianschwarz and we can work from there. |
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Description
Add ExecutionPolicy Bypass to spawned powershell process so powershell modules can be loaded
Issues Resolved
Fix #472
Check List
Tiny fix, so I hope these are not necessary?