specinfra 0.5.5 → 0.5.6
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3fbfc9272049c0efc0e7b3430719d72547ec5bd1
|
4
|
+
data.tar.gz: 16b88cf1fd04e29eff60421b60f688fe80496948
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 065a3f9ece6c188b117a378e826a5b1b7aaabb2f7b17f67c07a9e4fa5bb999fb8d8f3e91e72763e6ae5119a3b0c0485b0b17867109159b18adc7fdf9e854acf8
|
7
|
+
data.tar.gz: 565a0f1febe195e6cdbe6cab501e1cdf88cfa2c92dcd7c0469e215f4c9b29f91e8075b67a1e987999ac1042fd8e54022453ff5c6e29616026736895e1af76343
|
@@ -1,26 +1,45 @@
|
|
1
1
|
function ListWindowsFeatures
|
2
2
|
{
|
3
|
-
|
3
|
+
|
4
|
+
param(
|
5
|
+
[string]$feature,
|
6
|
+
[string]$provider="dism"
|
7
|
+
)
|
8
|
+
|
9
|
+
$cachepath = "${env:temp}/ListWindowsFeatures-${provider}.xml"
|
4
10
|
$maxAge = 2
|
5
11
|
|
6
12
|
$cache = Get-Item $cachepath -erroraction SilentlyContinue
|
7
13
|
|
8
14
|
if($cache -ne $null -and ((get-date) - $cache.LastWriteTime).minutes -lt $maxage){
|
9
|
-
|
15
|
+
$features = Import-Clixml $cachepath | Select *| Where-Object {(($_.name -like $feature) -or ($_.displayName -like $feature)) -and (($_.installed -eq $true) -or ($_.state -eq "Enabled"))}
|
16
|
+
return $features
|
10
17
|
}
|
11
18
|
else{
|
12
|
-
|
19
|
+
|
20
|
+
switch($provider)
|
13
21
|
{
|
14
|
-
|
22
|
+
"dism" { return features_dism | Select * | Where-Object {($_.name -eq $feature) -and ($_.state -eq "Enabled")} }
|
23
|
+
"powershell" { return features_powershell | Select * | Where-Object {(($_.name -like $feature) -or ($_.displayName -like $feature)) -and ($_.installed -eq $true)} }
|
24
|
+
default {throw "Unsupported provider"}
|
25
|
+
}
|
26
|
+
|
27
|
+
}
|
28
|
+
}
|
29
|
+
|
30
|
+
function features_dism{
|
31
|
+
try
|
32
|
+
{
|
33
|
+
$out = DISM /Online /Get-Features /Format:List | Where-Object {$_}
|
15
34
|
|
16
35
|
if($LASTEXITCODE -ne 0)
|
17
36
|
{
|
18
|
-
Write-Error $
|
37
|
+
Write-Error $out
|
19
38
|
Break
|
20
39
|
}
|
21
40
|
|
22
|
-
$f = $
|
23
|
-
$
|
41
|
+
$f = $out[4..($out.length-2)]
|
42
|
+
$features = for($i=0; $i -lt $f.length;$i+=2)
|
24
43
|
{
|
25
44
|
$tmp = $f[$i],$f[$i+1] -replace '^([^:]+:\s)'
|
26
45
|
|
@@ -30,14 +49,20 @@ function ListWindowsFeatures
|
|
30
49
|
}
|
31
50
|
}
|
32
51
|
|
33
|
-
$
|
52
|
+
$features | Export-Clixml $cachepath
|
34
53
|
|
35
|
-
return $
|
54
|
+
return $features
|
36
55
|
}
|
37
56
|
catch
|
38
57
|
{
|
39
58
|
Throw
|
40
59
|
}
|
60
|
+
}
|
41
61
|
|
42
|
-
|
62
|
+
function features_powershell{
|
63
|
+
$ProgressPreference = "SilentlyContinue"
|
64
|
+
import-module servermanager
|
65
|
+
$features = Get-WindowsFeature
|
66
|
+
$features | Export-Clixml $cachepath
|
67
|
+
return Get-WindowsFeature
|
43
68
|
}
|
@@ -203,13 +203,23 @@ module SpecInfra
|
|
203
203
|
end
|
204
204
|
end
|
205
205
|
|
206
|
-
def check_windows_feature_enabled(name)
|
207
|
-
|
208
|
-
Backend::PowerShell::Command.new do
|
209
|
-
using 'list_windows_features.ps1'
|
210
|
-
exec "@(ListWindowsFeatures | Where-Object {($_.name -eq '#{name}') -and ($_.State -eq 'enabled')}).count -gt 0"
|
211
|
-
end
|
206
|
+
def check_windows_feature_enabled(name,provider)
|
212
207
|
|
208
|
+
if provider.nil?
|
209
|
+
cmd = "@(ListWindowsFeatures -feature #{name}).count -gt 0"
|
210
|
+
else
|
211
|
+
cmd = "@(ListWindowsFeatures -feature #{name} -provider #{provider}).count -gt 0"
|
212
|
+
end
|
213
|
+
|
214
|
+
Backend::PowerShell::Command.new do
|
215
|
+
using 'list_windows_features.ps1'
|
216
|
+
exec cmd
|
217
|
+
end
|
218
|
+
end
|
219
|
+
|
220
|
+
def check_file_version(name,version)
|
221
|
+
cmd = "((Get-Command '#{name}').FileVersionInfo.ProductVersion -eq '#{version}') -or ((Get-Command '#{name}').FileVersionInfo.FileVersion -eq '#{version}')"
|
222
|
+
Backend::PowerShell::Command.new { exec cmd }
|
213
223
|
end
|
214
224
|
|
215
225
|
private
|
data/lib/specinfra/version.rb
CHANGED