Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/RequestProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ internal StreamingMessage ProcessFunctionLoadRequest(StreamingMessage request)
// This PowerShell instance is shared by the first PowerShellManager instance created in the pool,
// and the dependency manager (used to download dependent modules if needed).
var pwsh = Utils.NewPwshInstance();
LogPowerShellVersion(rpcLogger, pwsh);
_powershellPool.Initialize(pwsh);

// Start the download asynchronously if needed.
Expand Down Expand Up @@ -492,6 +493,12 @@ private void BindOutputFromResult(InvocationResponse response, AzFunctionInfo fu
}
}

private static void LogPowerShellVersion(RpcLogger rpcLogger, System.Management.Automation.PowerShell pwsh)
{
var message = string.Format(PowerShellWorkerStrings.PowerShellVersion, Utils.GetPowerShellVersion(pwsh));
rpcLogger.Log(isUserOnlyLog: false, LogLevel.Information, message);
}

#endregion
}
}
12 changes: 11 additions & 1 deletion src/Utility/Utils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading;
using Microsoft.PowerShell.Commands;

namespace Microsoft.Azure.Functions.PowerShellWorker.Utility
Expand Down Expand Up @@ -222,5 +222,15 @@ internal static bool AreDurableFunctionsEnabled()
{
return PowerShellWorkerConfiguration.GetBoolean("PSWorkerEnableExperimentalDurableFunctions") ?? false;
}

internal static string GetPowerShellVersion(PowerShell pwsh)
{
const string versionTableVariableName = "PSVersionTable";
const string versionPropertyName = "PSVersion";

var versionTableVariable = GetGlobalVariables(pwsh).First(v => string.CompareOrdinal(v.Name, versionTableVariableName) == 0);
var versionTable = (PSVersionHashTable)versionTableVariable.Value;
return versionTable[versionPropertyName].ToString();
}
}
}
3 changes: 3 additions & 0 deletions src/resources/PowerShellWorkerStrings.resx
Original file line number Diff line number Diff line change
Expand Up @@ -307,4 +307,7 @@
<data name="CommandNotFoundException_Exception" xml:space="preserve">
<value>CommandNotFoundException detected (exception).</value>
</data>
<data name="PowerShellVersion" xml:space="preserve">
<value>PowerShell version: '{0}'.</value>
</data>
</root>