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 +4 -4
- data/lib/train-pwsh/connection.rb +37 -0
- data/lib/train-pwsh/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9c0b97bc0ab701a473da4c28af195434cfc6fc374103614bb00ea02766c7d28f
|
4
|
+
data.tar.gz: 86f25bad8916379f13ae5769dc0a0ee89d30b1798c679496903a3b8a874f015f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
data/lib/train-pwsh/version.rb
CHANGED
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.
|
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:
|
11
|
+
date: 2025-02-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: train
|