Skip to content

Commit 64a6838

Browse files
authored
psd1 & psm1 of Az.Installer with a demo cmdlet (#12698)
1 parent ddaf855 commit 64a6838

File tree

3 files changed

+221
-0
lines changed

3 files changed

+221
-0
lines changed

src/Installer/Az.Installer.psd1

Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
#
2+
# Module manifest for module 'Az.Installer'
3+
#
4+
# Generated by: Microsoft Corporation
5+
#
6+
# Generated on: 8/19/2020
7+
#
8+
9+
@{
10+
11+
# Script module or binary module file associated with this manifest.
12+
RootModule = 'Az.Installer.psm1'
13+
14+
# Version number of this module.
15+
ModuleVersion = '0.1.0'
16+
17+
# Supported PSEditions
18+
CompatiblePSEditions = 'Core', 'Desktop'
19+
20+
# ID used to uniquely identify this module
21+
GUID = '8c7c6fcd-a96f-460b-89e2-ff822a3246c8'
22+
23+
# Author of this module
24+
Author = 'Microsoft Corporation'
25+
26+
# Company or vendor of this module
27+
CompanyName = 'Microsoft Corporation'
28+
29+
# Copyright statement for this module
30+
Copyright = 'Microsoft Corporation. All rights reserved.'
31+
32+
# Description of the functionality provided by this module
33+
Description = 'Microsoft Azure PowerShell Module Management.'
34+
35+
# Minimum version of the PowerShell engine required by this module
36+
PowerShellVersion = '5.1'
37+
38+
# Name of the PowerShell host required by this module
39+
# PowerShellHostName = ''
40+
41+
# Minimum version of the PowerShell host required by this module
42+
# PowerShellHostVersion = ''
43+
44+
# Minimum version of Microsoft .NET Framework required by this module. This prerequisite is valid for the PowerShell Desktop edition only.
45+
DotNetFrameworkVersion = '4.7.2'
46+
47+
# Minimum version of the common language runtime (CLR) required by this module. This prerequisite is valid for the PowerShell Desktop edition only.
48+
# CLRVersion = ''
49+
50+
# Processor architecture (None, X86, Amd64) required by this module
51+
# ProcessorArchitecture = ''
52+
53+
# Modules that must be imported into the global environment prior to importing this module
54+
RequiredModules = @(@{ModuleName = 'PowerShellGet'; ModuleVersion = '2.1.3'; })
55+
56+
# Assemblies that must be loaded prior to importing this module
57+
#RequiredAssemblies = ''
58+
59+
# Script files (.ps1) that are run in the caller's environment prior to importing this module.
60+
# ScriptsToProcess = @()
61+
62+
# Type files (.ps1xml) to be loaded when importing this module
63+
# TypesToProcess = @()
64+
65+
# Format files (.ps1xml) to be loaded when importing this module
66+
#FormatsToProcess = ''
67+
68+
# Modules to import as nested modules of the module specified in RootModule/ModuleToProcess
69+
# NestedModules = @()
70+
71+
# Functions to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no functions to export.
72+
FunctionsToExport = '*'
73+
74+
# Cmdlets to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no cmdlets to export.
75+
CmdletsToExport = @()
76+
77+
# Variables to export from this module
78+
# VariablesToExport = @()
79+
80+
# Aliases to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no aliases to export.
81+
AliasesToExport = '*'
82+
83+
# DSC resources to export from this module
84+
# DscResourcesToExport = @()
85+
86+
# List of all modules packaged with this module
87+
# ModuleList = @()
88+
89+
# List of all files packaged with this module
90+
# FileList = @()
91+
92+
# Private data to pass to the module specified in RootModule/ModuleToProcess. This may also contain a PSData hashtable with additional module metadata used by PowerShell.
93+
PrivateData = @{
94+
95+
PSData = @{
96+
97+
# Tags applied to this module. These help with module discovery in online galleries.
98+
#Tags = ''
99+
100+
# A URL to the license for this module.
101+
LicenseUri = 'https://aka.ms/azps-license'
102+
103+
# A URL to the main website for this project.
104+
ProjectUri = 'https://github.com/Azure/azure-powershell'
105+
106+
# A URL to an icon representing this module.
107+
# IconUri = ''
108+
109+
# ReleaseNotes of this module
110+
ReleaseNotes = '* the first preview release'
111+
112+
# Prerelease string of this module
113+
# Prerelease = ''
114+
115+
# Flag to indicate whether the module requires explicit user acceptance for install/update/save
116+
# RequireLicenseAcceptance = $false
117+
118+
# External dependent modules of this module
119+
# ExternalModuleDependencies = @()
120+
121+
} # End of PSData hashtable
122+
123+
} # End of PrivateData hashtable
124+
125+
# HelpInfo URI of this module
126+
# HelpInfoURI = ''
127+
128+
# Default prefix for commands exported from this module. Override the default prefix using Import-Module -Prefix.
129+
# DefaultCommandPrefix = ''
130+
131+
}

src/Installer/Az.Installer.psm1

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# ----------------------------------------------------------------------------------
2+
#
3+
# Copyright Microsoft Corporation
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
# Unless required by applicable law or agreed to in writing, software
9+
# distributed under the License is distributed on an "AS IS" BASIS,
10+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.internal
11+
# See the License for the specific language governing permissions and
12+
# limitations under the License.
13+
# ----------------------------------------------------------------------------------
14+
15+
$getModule = Get-Module -Name "PowerShellGet"
16+
if ($null -ne $getModule -and $getModule.Version -lt [System.Version]"2.1.3") {
17+
Write-Error "This module requires PowerShellGet version 2.1.3. An earlier version of PowerShellGet is imported in the current PowerShell session. Please open a new session before importing this module." -ErrorAction Stop
18+
}
19+
elseif ($null -eq $module) {
20+
Import-Module PowerShellGet -MinimumVersion 2.1.3 -Scope Global
21+
}
22+
23+
$exportedPS1Files = Get-ChildItem -Path $PSScriptRoot/exports -Recurse -Include '*.ps1' -File
24+
$internalPS1Files = Get-ChildItem -Path $PSScriptRoot/internal -Recurse -Include '*.ps1' -File
25+
$exportedPS1Files | ForEach-Object { . $_.FullName }
26+
$internalPS1Files | ForEach-Object { . $_.FullName }
27+
Export-ModuleMember -Function $exportedPS1Files.Basename
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
# ----------------------------------------------------------------------------------
2+
#
3+
# Copyright Microsoft Corporation
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
# Unless required by applicable law or agreed to in writing, software
9+
# distributed under the License is distributed on an "AS IS" BASIS,
10+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
# See the License for the specific language governing permissions and
12+
# limitations under the License.
13+
# ----------------------------------------------------------------------------------
14+
15+
function Get-AzModuleWithUpdate {
16+
[OutputType([System.Collections.ArrayList])]
17+
[CmdletBinding(DefaultParameterSetName = 'Default', PositionalBinding = $false)]
18+
param(
19+
[Parameter(ParameterSetName = 'Default', Mandatory, HelpMessage = 'The Registered Repostory.')]
20+
[ValidateNotNullOrEmpty()]
21+
[System.String]
22+
${Repository}
23+
)
24+
25+
process {
26+
27+
$modules = New-Object System.Collections.ArrayList
28+
29+
if ($PSBoundParameters.ContainsKey('Repository')) {
30+
$installModules = @{}
31+
32+
try {
33+
$null = Get-InstalledModule -Name @('Az', 'Az.*') -ErrorAction Stop | ForEach-Object { $installModules[$_.Name] = $_.Version }
34+
}
35+
catch {
36+
Write-Warning $_
37+
}
38+
39+
$azModule = Find-Module -Name Az -Repository $Repository
40+
if ($azModule) {
41+
Write-Progress -Activity "Find Module" -CurrentOperation "Az with the latest version $($azModule.Version)"
42+
$null = $modules.Add($azModule)
43+
$null = $azModule.Dependencies | ForEach-Object { $_['Name'] } | ForEach-Object {
44+
$m = Find-Module -Name $_ -Repository $Repository
45+
$modules.Add($m)
46+
Write-Progress -Activity "Find Module" -CurrentOperation "$_ with the latest version $($m.Version)"
47+
}
48+
}
49+
$modules = $modules.Where( { $installModules.ContainsKey($_.Name) -and [version]$_.Version -gt [version]$installModules[$_.Name] })
50+
}
51+
52+
Write-Progress -Activity "Find Module" -Completed
53+
54+
If (0 -eq $modules.Count) {
55+
Write-Warning "All of your installed Az modules are update to date."
56+
}
57+
else {
58+
Write-Host "The modules contains update:"
59+
}
60+
return $modules
61+
}
62+
}
63+

0 commit comments

Comments
 (0)