Skip to content
This repository has been archived by the owner on Jul 14, 2021. It is now read-only.

Update start-chefdk.ps1 #1478

Closed
wants to merge 1 commit into from
Closed

Update start-chefdk.ps1 #1478

wants to merge 1 commit into from

Conversation

bastianschwarz
Copy link

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?

Fix #472
Add ExecutionPolicy Bypass to spawned powershell process so powershell modules can be loaded
@bastianschwarz bastianschwarz requested a review from a team December 17, 2017 14:32
Copy link

@smurawski smurawski left a 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.

Copy link

@stuartpreston stuartpreston left a 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

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'"

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'"

@stuartpreston
Copy link

@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.

@stuartpreston
Copy link

@bastianschwarz Also are you able to add your DCO Signed-off-by to your commit? Thanks!

@tas50
Copy link
Contributor

tas50 commented Sep 22, 2018

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.

@tas50 tas50 closed this Sep 22, 2018
@lock
Copy link

lock bot commented Nov 21, 2018

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.

@lock lock bot locked as resolved and limited conversation to collaborators Nov 21, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

Successfully merging this pull request may close these issues.

PowerShell Wrappers: Docs assume elevation since Windows cannot access modules directory when non-elevated
4 participants