Skip to content

Commit

Permalink
New Variable: dynamic_commands
Browse files Browse the repository at this point in the history
Name of the File that contains the Functions to fill the dynamic fields
  • Loading branch information
mpetereit committed Jul 20, 2023
1 parent 2dec41c commit 2b4a617
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 8 deletions.
1 change: 1 addition & 0 deletions WebJEA/Config.vb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
Public ParseScript As TriState = TriState.True
Private prvDefaultCommandId As String
Public BasePath As String
Public dynamic_commands As String = "FPIT_Commands.ps1"
Public SendTelemetry As Boolean = False
Public PermittedGroups As New List(Of String)()
Private prvGroupSIDs As New List(Of String)
Expand Down
11 changes: 4 additions & 7 deletions WebJEA/PSCmdParam.vb
Original file line number Diff line number Diff line change
Expand Up @@ -223,17 +223,15 @@ Public Class PSCmdParam
If WebJEA._default.SessionValues.Item(SessionID).Contains("EXEC_" + Name) Then 'If its a Button and has a DefaultValue from a FormGroup Field then execute the additional Script
WebJEA._default.SessionValues.Item(SessionID).Remove("EXEC_" + Name)

Dim FPIT_Path = WebJEA.My.Settings.configfile
FPIT_Path = FPIT_Path.Replace("config.json", Name + ".ps1")
Dim pscommand As String = FPIT_Path & " '" & DefaultValue & "'" & "; exit $LASTEXITCODE"
Dim dynamic_commands_file = WebJEA._default.cfg.BasePath + "\" + WebJEA._default.cfg.dynamic_commands
Dim pscommand As String = dynamic_commands_file & " '" & DefaultValue & "'" & "; exit $LASTEXITCODE"
Dim cmd As String = "powershell.exe -noprofile -NonInteractive -WindowStyle hidden -command " & pscommand
Dim shell = CreateObject("WScript.Shell")
Dim executor = shell.Exec(cmd)
executor.StdIn.Close

psparam.DefaultValue_BT = executor.StdOut.ReadAll


Else 'If its not a button then normally execute the external Script to prefill Fields
If DefaultValue = "" Or DefaultValue = Nothing And Not (ParamType = ParameterType.PSButton) Then
DefaultValue = "0"
Expand All @@ -243,9 +241,8 @@ Public Class PSCmdParam

'Aufruf externes Powershell Script
'script.ps1 <VariablenName> <Wert> C:\temp\WebJEA\WebJea-Scripts\test.ps1
Dim FPIT_Path = WebJEA.My.Settings.configfile
FPIT_Path = FPIT_Path.Replace("config.json", "FPIT_Commands.ps1")
Dim pscommand As String = FPIT_Path & " " & psparam.Name & " '" & DefaultValue & "'" & "; Exit $LASTEXITCODE"
Dim dynamic_commands_file = WebJEA._default.cfg.BasePath + "\" + WebJEA._default.cfg.dynamic_commands
Dim pscommand As String = dynamic_commands_file & " " & psparam.Name & " '" & DefaultValue & "'" & "; Exit $LASTEXITCODE"
Dim cmd As String = "powershell.exe -noprofile -NonInteractive -WindowStyle hidden -command " & pscommand
Dim shell = CreateObject("WScript.Shell")
Dim executor = shell.Exec(cmd)
Expand Down
2 changes: 1 addition & 1 deletion WebJEA/default.aspx.vb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Public Class _default
Private uinfo As New UserInfo(Page.User)
Private objTelemetry As New Telemetry
Public grpfinder As New GroupFinder
Public cfg As WebJEA.Config
Public Shared cfg As WebJEA.Config
' Public Shared CachedFormValues As New Hashtable()
Public Shared SessionValues As New Hashtable()
'advanced functions should be able to retrieve the get-help and parameter data, then permit overriding
Expand Down

0 comments on commit 2b4a617

Please sign in to comment.