Skip to content

Commit

Permalink
update configs for beta36+ of core tools and add windows if check (#23)
Browse files Browse the repository at this point in the history
* update configs for beta36 of core tools and add windows if check

* add a comment to explain why execution policy is needed
  • Loading branch information
TylerLeonhardt committed Sep 1, 2018
1 parent fec8b11 commit 274e079
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
1 change: 1 addition & 0 deletions examples/PSCoreApp/host.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"version": "2.0",
"logger": {
"categoryFilter": {
"defaultLevel": "Trace",
Expand Down
9 changes: 8 additions & 1 deletion src/PowerShell/PowerShellManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,14 @@ internal class PowerShellManager
internal PowerShellManager(RpcLogger logger)
{
var initialSessionState = InitialSessionState.CreateDefault();
initialSessionState.ExecutionPolicy = Microsoft.PowerShell.ExecutionPolicy.Unrestricted;

// Setting the execution policy on macOS and Linux throws an exception so only update it on Windows
if(Platform.IsWindows)
{
// This sets the execution policy on Windows to Unrestricted which is required to run the user's function scripts on
// Windows client versions. This is needed if a user is testing their function locally with the func CLI
initialSessionState.ExecutionPolicy = Microsoft.PowerShell.ExecutionPolicy.Unrestricted;
}
_pwsh = PowerShell.Create(initialSessionState);
_logger = logger;

Expand Down
10 changes: 5 additions & 5 deletions src/worker.config.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"Description":{
"Language":"powershell",
"Extension":".ps1",
"DefaultExecutablePath":"dotnet",
"DefaultWorkerPath":"Azure.Functions.PowerShell.Worker.dll"
"description":{
"language":"powershell",
"extensions":[".ps1"],
"defaultExecutablePath":"dotnet",
"defaultWorkerPath":"Azure.Functions.PowerShell.Worker.dll"
}
}

0 comments on commit 274e079

Please sign in to comment.