train-pwsh 0.1.5 → 0.1.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f2abb2512b0e08cfc8c62921943decbd47cc7ba52320755483be12c7c74392e2
4
- data.tar.gz: 6211655d9ae40fa13982f34f6e456f451b3e47a81d31f8cb7d791085b0dc41aa
3
+ metadata.gz: 9c0b97bc0ab701a473da4c28af195434cfc6fc374103614bb00ea02766c7d28f
4
+ data.tar.gz: 86f25bad8916379f13ae5769dc0a0ee89d30b1798c679496903a3b8a874f015f
5
5
  SHA512:
6
- metadata.gz: 253d3d3fc36100ba90563ec290ffd81bf50670065abd029657277ab49feb4d279ddadf21625366fd8c5de27a871f7484a995c580ae43438df44ef4938f75fb50
7
- data.tar.gz: 97952ce6382936fe1bd6c9457a979537b57ec91f418b9048c526a9e10d607ef4a5713b7ffbbafa75a5a5bdede35abc82476e4c008996e292666e6dcf8216f97a
6
+ metadata.gz: 1da78073262a500f458e9208d39850a778aa2b1993f8db53e2e8286bdb5850834e249124cee78b98a4be09b47cca338ad645f3b46fea2b45f8794b95e87672f1
7
+ data.tar.gz: e16e5aebad94903f7d7c7663eb5f41d9939029149f875fd1aa8af1fc1e2936cdd762440c47a8fe0632e362c2e69cf86f0f5f5e267d0504a2aa79ab336c12cfd0
@@ -55,6 +55,7 @@ module TrainPlugins
55
55
  #@pwsh_session_teams_pnp = @options.delete(:teams_pnp_session)
56
56
  @pwsh_session_graph_exchange = ::Pwsh::Manager.instance("#{@pwsh_path}", ['-NoLogo'])
57
57
  @pwsh_session_teams_pnp = ::Pwsh::Manager.instance("#{@pwsh_path}", [])
58
+ @pwsh_session_azure = ::Pwsh::Manager.instance("#{@pwsh_path}", ['-NoProfile'])
58
59
  @client_id = @options.delete(:client_id)
59
60
  @tenant_id = @options.delete(:tenant_id)
60
61
  @client_secret = @options.delete(:client_secret)
@@ -65,10 +66,13 @@ module TrainPlugins
65
66
 
66
67
  exit_status_graph_exchange = install_connect_graph_exchange()
67
68
  exit_status_teams_pnp = install_connect_teams_pnp()
69
+ exit_status_azure = install_azure()
68
70
  if exit_status_graph_exchange != 0
69
71
  return exit_status_graph_exchange
70
72
  elsif exit_status_teams_pnp != 0
71
73
  return exit_status_teams_pnp
74
+ elsif exit_status_azure != 0
75
+ return exit_status_azure
72
76
  end
73
77
 
74
78
  end
@@ -82,6 +86,8 @@ module TrainPlugins
82
86
  return run_script_in_graph_exchange(script)
83
87
  elsif session_type_hash.key?(:teams_pnp_session)
84
88
  return run_script_in_teams_pnp(script)
89
+ elsif session_type_hash.key?(:azure_session)
90
+ return run_script_in_azure(script)
85
91
  else
86
92
  return CommandResult.new("","",0)
87
93
  end
@@ -146,6 +152,24 @@ module TrainPlugins
146
152
  return pwsh_teams_pnp_install_connect_result[:exitcode]
147
153
  end
148
154
 
155
+ def install_azure()
156
+ pwsh_azure_install_connect = %{
157
+ #Collect designated inputs required for Graph, Exchange, and PnP connections
158
+ $client_id = '#{@client_id}'
159
+ $tenantid = '#{@tenant_id}'
160
+ $certificate_password = '#{@certificate_password}'
161
+ $certificate_path = '#{@certificate_path}'
162
+ $sharepoint_admin_url = '#{@sharepoint_admin_url}'
163
+
164
+ #Connect to Teams module
165
+ If ($null -eq (Get-Module -ListAvailable -Name "Az")) {Install-Module Az -Force -AllowClobber}
166
+ If ($null -eq (Get-Module -Name "Az")) {Import-Module Az}
167
+ Connect-AzAccount
168
+ }
169
+ pwsh_azure_install_connect_result = @pwsh_session_azure.execute(pwsh_azure_install_connect)
170
+ return pwsh_azure_install_connect_result[:exitcode]
171
+ end
172
+
149
173
  def run_script_in_graph_exchange(script)
150
174
  result = @pwsh_session_graph_exchange.execute(script)
151
175
  if result[:stdout].nil?
@@ -171,6 +195,19 @@ module TrainPlugins
171
195
  end
172
196
  return CommandResult.new(result[:stdout],result[:stderr],result[:exitcode])
173
197
  end
198
+
199
+ def run_script_in_azure(script)
200
+ result = @pwsh_session_azure.execute(script)
201
+ if result[:stdout].nil?
202
+ result[:stdout] = ""
203
+ end
204
+ if !result[:stdout].empty? && result[:stdout].match?(/is not recognized|session is not established/i)
205
+ result[:stderr] = result[:stdout]
206
+ result[:stdout] = ""
207
+ result[:exitcode] = -1
208
+ end
209
+ return CommandResult.new(result[:stdout],result[:stderr],result[:exitcode])
210
+ end
174
211
  end
175
212
  end
176
213
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Train
4
4
  module Pwsh
5
- VERSION = "0.1.5"
5
+ VERSION = "0.1.6"
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: train-pwsh
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sujay Kandwal
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-12-26 00:00:00.000000000 Z
11
+ date: 2025-02-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: train