-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGetAzModuleData.ps1
More file actions
86 lines (70 loc) · 3.23 KB
/
GetAzModuleData.ps1
File metadata and controls
86 lines (70 loc) · 3.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
[CmdletBinding()]
param (
[Parameter(Mandatory=$false,
HelpMessage="The current path as the value of the path parameter if not passed Path parameter."
)]
[string]
$Path,
[Parameter(Mandatory=$false,
HelpMessage="The Path parameter and the OutPath parameter are the same if not passed OutPath parameter."
)]
[string]
$OutPath
)
try {
if (!$PSBoundParameters.ContainsKey("Path")) {
$Path = $PSScriptRoot
}
if (!$PSBoundParameters.ContainsKey("OutPath")) {
$OutPath = $PSScriptRoot
}
$DataOfAzModules = (Get-Content -Path $Path)
function Get-AzModuleDataFunction{
param (
$AzModuleData
)
$OutPutTitle = @("Module,CurrentVersion,AssemblyName,NumberOfCmdlets,NumberOfUpdatesIn2020,NumberOfUpdatesIn2021")
$parameters = @{
TypeName = 'System.Collections.Generic.HashSet[string]'
ArgumentList = ([string[]]$OutPutTitle, [System.StringComparer]::OrdinalIgnoreCase)
}
$AzModuleOutPut = New-Object @parameters
foreach ($AzModule in $AzModuleData){
# $AzModuleOutPut = New-Object PSObject
# Add-Member -InputObject $AzModuleOutPut -MemberType NoteProperty -Name Module -Value $NULL
# Add-Member -InputObject $AzModuleOutPut -MemberType NoteProperty -Name CurrentVersion -Value $NULL
# Add-Member -InputObject $AzModuleOutPut -MemberType NoteProperty -Name AssemblyName -Value $NULL
# Add-Member -InputObject $AzModuleOutPut -MemberType NoteProperty -Name NumberOfCmdlets -Value $NULL
# Add-Member -InputObject $AzModuleOutPut -MemberType NoteProperty -Name NumberOfUpdatesIn2020 -Value $NULL
# Add-Member -InputObject $AzModuleOutPut -MemberType NoteProperty -Name NumberOfUpdatesIn2021 -Value $NULL
$Name = $AzModule.Split(" ")[0]
$CurrentVersion = $AzModule.Split(" ")[1]
$AssemblyName = $AzModule.Split(" ")[2]
$NumberOfCmdlets = (Get-Command -Module $Name).length
# $NumberOfCmdlets = (Get-Command -Module $Name -CommandType Cmdlet,Function).length
$NumberOfUpdatesIn2020 = 0
$NumberOfUpdatesIn2021 = 0
$ModuleList = find-module $Name -Repository PSgallery -AllVersions
foreach ($item in $ModuleList){
$PublishedDate = $item.PublishedDate.ToString("yyyyMMdd")
if ("20200101" -le $PublishedDate -And $PublishedDate -le "20201231"){
$NumberOfUpdatesIn2020++
}
if ("20210101" -le $PublishedDate -And $PublishedDate -le "20211231"){
$NumberOfUpdatesIn2021++
}
}
$null = $AzModuleOutPut.Add("$Name,$CurrentVersion,$AssemblyName,$NumberOfCmdlets,$NumberOfUpdatesIn2020,$NumberOfUpdatesIn2021")
}
$designFile = 'Az1Module.txt'
$outFilePath = Join-Path $OutPath $designFile
$AzModuleOutPut | Out-File -FilePath $outFilePath -Append -ErrorAction Stop
Write-Host -ForegroundColor Green "Genereated $designFile completed in $OutPath. path."
return
}
Get-AzModuleDataFunction -AzModuleData $DataOfAzModules
}
catch {
throw
return
}