|
1 | 1 | # region Generated
|
2 |
| -# ---------------------------------------------------------------------------------- |
3 |
| -# Copyright (c) Microsoft Corporation. All rights reserved. |
| 2 | + # ---------------------------------------------------------------------------------- |
| 3 | + # Copyright (c) Microsoft Corporation. All rights reserved. |
4 | 4 | # Licensed under the Apache License, Version 2.0 (the "License");
|
5 | 5 | # you may not use this file except in compliance with the License.
|
6 | 6 | # You may obtain a copy of the License at
|
|
12 | 12 | # limitations under the License.
|
13 | 13 | # Code generated by Microsoft (R) AutoRest Code Generator.Changes may cause incorrect behavior and will be lost if the code
|
14 | 14 | # is regenerated.
|
15 |
| -# ---------------------------------------------------------------------------------- |
16 |
| -# Load required Az.Accounts module |
17 |
| -$accountsName = 'Az.Accounts' |
18 |
| -$accountsModule = Get-Module -Name $accountsName |
19 |
| -if(-not $accountsModule) { |
20 |
| - $localAccountsPath = Join-Path $PSScriptRoot 'generated\modules' |
21 |
| - if(Test-Path -Path $localAccountsPath) { |
22 |
| - $localAccounts = Get-ChildItem -Path $localAccountsPath -Recurse -Include 'Az.Accounts.psd1' | Select-Object -Last 1 |
23 |
| - if($localAccounts) { |
24 |
| - $accountsModule = Import-Module -Name ($localAccounts.FullName) -Scope Global -PassThru |
25 |
| - } |
26 |
| - } |
| 15 | + # ---------------------------------------------------------------------------------- |
| 16 | + # Load required Az.Accounts module |
| 17 | + $accountsName = 'Az.Accounts' |
| 18 | + $accountsModule = Get-Module -Name $accountsName |
27 | 19 | if(-not $accountsModule) {
|
28 |
| - $hasAdequateVersion = (Get-Module -Name $accountsName -ListAvailable | Where-Object { $_.Version -ge [System.Version]'2.2.3' } | Measure-Object).Count -gt 0 |
29 |
| - if($hasAdequateVersion) { |
30 |
| - $accountsModule = Import-Module -Name $accountsName -MinimumVersion 2.2.3 -Scope Global -PassThru |
| 20 | + $localAccountsPath = Join-Path $PSScriptRoot 'generated\modules' |
| 21 | + if(Test-Path -Path $localAccountsPath) { |
| 22 | + $localAccounts = Get-ChildItem -Path $localAccountsPath -Recurse -Include 'Az.Accounts.psd1' | Select-Object -Last 1 |
| 23 | + if($localAccounts) { |
| 24 | + $accountsModule = Import-Module -Name ($localAccounts.FullName) -Scope Global -PassThru |
| 25 | + } |
| 26 | + } |
| 27 | + if(-not $accountsModule) { |
| 28 | + $hasAdequateVersion = (Get-Module -Name $accountsName -ListAvailable | Where-Object { $_.Version -ge [System.Version]'2.7.5' } | Measure-Object).Count -gt 0 |
| 29 | + if($hasAdequateVersion) { |
| 30 | + $accountsModule = Import-Module -Name $accountsName -MinimumVersion 2.7.5 -Scope Global -PassThru |
| 31 | + } |
31 | 32 | }
|
32 | 33 | }
|
33 |
| -} |
34 |
| -if(-not $accountsModule) { |
35 |
| - Write-Error "`nThis module requires $accountsName version 2.2.3 or greater. For installation instructions, please see: https://docs.microsoft.com/powershell/azure/install-az-ps" -ErrorAction Stop |
36 |
| -} elseif (($accountsModule.Version -lt [System.Version]'2.2.3') -and (-not $localAccounts)) { |
37 |
| - Write-Error "`nThis module requires $accountsName version 2.2.3 or greater. An earlier version of Az.Accounts is imported in the current PowerShell session. If you are running test, please try to add the switch '-RegenerateSupportModule' when executing 'test-module.ps1'. Otherwise please open a new PowerShell session and import this module again.`nAdditionally, this error could indicate that multiple incompatible versions of Azure PowerShell modules are installed on your system. For troubleshooting information, please see: https://aka.ms/azps-version-error" -ErrorAction Stop |
38 |
| -} |
39 |
| -Write-Information "Loaded Module '$($accountsModule.Name)'" |
40 |
| -# Load the private module dll |
41 |
| -$null = Import-Module -Name (Join-Path $PSScriptRoot './bin/Az.DataProtection.private.dll') |
42 |
| -# Get the private module's instance |
43 |
| -$instance = [Microsoft.Azure.PowerShell.Cmdlets.DataProtection.Module]::Instance |
44 |
| -# Ask for the shared functionality table |
45 |
| -$VTable = Register-AzModule |
46 | 34 |
|
47 |
| -# Tweaks the pipeline on module load |
48 |
| -$instance.OnModuleLoad = $VTable.OnModuleLoad |
49 |
| - |
50 |
| -# Tweaks the pipeline per call |
51 |
| -$instance.OnNewRequest = $VTable.OnNewRequest |
| 35 | + if(-not $accountsModule) { |
| 36 | + Write-Error "`nThis module requires $accountsName version 2.7.5 or greater. For installation instructions, please see: https://docs.microsoft.com/powershell/azure/install-az-ps" -ErrorAction Stop |
| 37 | + } elseif (($accountsModule.Version -lt [System.Version]'2.7.5') -and (-not $localAccounts)) { |
| 38 | + Write-Error "`nThis module requires $accountsName version 2.7.5 or greater. An earlier version of Az.Accounts is imported in the current PowerShell session. If you are running test, please try to add the switch '-RegenerateSupportModule' when executing 'test-module.ps1'. Otherwise please open a new PowerShell session and import this module again.`nAdditionally, this error could indicate that multiple incompatible versions of Azure PowerShell modules are installed on your system. For troubleshooting information, please see: https://aka.ms/azps-version-error" -ErrorAction Stop |
| 39 | + } |
| 40 | + Write-Information "Loaded Module '$($accountsModule.Name)'" |
52 | 41 |
|
53 |
| -# Gets shared parameter values |
54 |
| -$instance.GetParameterValue = $VTable.GetParameterValue |
| 42 | + # Load the private module dll |
| 43 | + $null = Import-Module -Name (Join-Path $PSScriptRoot './bin/Az.DataProtection.private.dll') |
55 | 44 |
|
56 |
| -# Allows shared module to listen to events from this module |
57 |
| -$instance.EventListener = $VTable.EventListener |
| 45 | + # Get the private module's instance |
| 46 | + $instance = [Microsoft.Azure.PowerShell.Cmdlets.DataProtection.Module]::Instance |
58 | 47 |
|
59 |
| -# Gets shared argument completers |
60 |
| -$instance.ArgumentCompleter = $VTable.ArgumentCompleter |
| 48 | + # Ask for the shared functionality table |
| 49 | + $VTable = Register-AzModule |
| 50 | + |
| 51 | + # Tweaks the pipeline on module load |
| 52 | + $instance.OnModuleLoad = $VTable.OnModuleLoad |
61 | 53 |
|
62 |
| -# The name of the currently selected Azure profile |
63 |
| -$instance.ProfileName = $VTable.ProfileName |
| 54 | + # Following two delegates are added for telemetry |
| 55 | + $instance.GetTelemetryId = $VTable.GetTelemetryId |
| 56 | + $instance.Telemetry = $VTable.Telemetry |
| 57 | + |
64 | 58 |
|
65 |
| -# Load the custom module |
66 |
| -$customModulePath = Join-Path $PSScriptRoot './custom/Az.DataProtection.custom.psm1' |
67 |
| -if(Test-Path $customModulePath) { |
68 |
| - $null = Import-Module -Name $customModulePath |
69 |
| -} |
| 59 | + # Tweaks the pipeline per call |
| 60 | + $instance.OnNewRequest = $VTable.OnNewRequest |
| 61 | + |
| 62 | + # Gets shared parameter values |
| 63 | + $instance.GetParameterValue = $VTable.GetParameterValue |
| 64 | + |
| 65 | + # Allows shared module to listen to events from this module |
| 66 | + $instance.EventListener = $VTable.EventListener |
| 67 | + |
| 68 | + # Gets shared argument completers |
| 69 | + $instance.ArgumentCompleter = $VTable.ArgumentCompleter |
| 70 | + |
| 71 | + # The name of the currently selected Azure profile |
| 72 | + $instance.ProfileName = $VTable.ProfileName |
70 | 73 |
|
71 |
| -# Export nothing to clear implicit exports |
72 |
| -Export-ModuleMember |
73 |
| -# Export proxy cmdlet scripts |
74 |
| -$exportsPath = Join-Path $PSScriptRoot './exports' |
75 |
| -$directories = Get-ChildItem -Directory -Path $exportsPath |
76 |
| -$profileDirectory = $null |
77 |
| -if($instance.ProfileName) { |
78 |
| - if(($directories | ForEach-Object { $_.Name }) -contains $instance.ProfileName) { |
79 |
| - $profileDirectory = $directories | Where-Object { $_.Name -eq $instance.ProfileName } |
80 |
| - } else { |
81 |
| - # Don't export anything if the profile doesn't exist for the module |
82 |
| - $exportsPath = $null |
83 |
| - Write-Warning "Selected Azure profile '$($instance.ProfileName)' does not exist for module '$($instance.Name)'. No cmdlets were loaded." |
| 74 | + |
| 75 | + # Load the custom module |
| 76 | + $customModulePath = Join-Path $PSScriptRoot './custom/Az.DataProtection.custom.psm1' |
| 77 | + if(Test-Path $customModulePath) { |
| 78 | + $null = Import-Module -Name $customModulePath |
84 | 79 | }
|
85 |
| -} elseif(($directories | Measure-Object).Count -gt 0) { |
86 |
| - # Load the last folder if no profile is selected |
87 |
| - $profileDirectory = $directories | Select-Object -Last 1 |
88 |
| -} |
| 80 | + |
| 81 | + # Export nothing to clear implicit exports |
| 82 | + Export-ModuleMember |
89 | 83 |
|
90 |
| -if($profileDirectory) { |
91 |
| - Write-Information "Loaded Azure profile '$($profileDirectory.Name)' for module '$($instance.Name)'" |
92 |
| - $exportsPath = $profileDirectory.FullName |
93 |
| -} |
| 84 | + # Export proxy cmdlet scripts |
| 85 | + $exportsPath = Join-Path $PSScriptRoot './exports' |
| 86 | + $directories = Get-ChildItem -Directory -Path $exportsPath |
| 87 | + $profileDirectory = $null |
| 88 | + if($instance.ProfileName) { |
| 89 | + if(($directories | ForEach-Object { $_.Name }) -contains $instance.ProfileName) { |
| 90 | + $profileDirectory = $directories | Where-Object { $_.Name -eq $instance.ProfileName } |
| 91 | + } else { |
| 92 | + # Don't export anything if the profile doesn't exist for the module |
| 93 | + $exportsPath = $null |
| 94 | + Write-Warning "Selected Azure profile '$($instance.ProfileName)' does not exist for module '$($instance.Name)'. No cmdlets were loaded." |
| 95 | + } |
| 96 | + } elseif(($directories | Measure-Object).Count -gt 0) { |
| 97 | + # Load the last folder if no profile is selected |
| 98 | + $profileDirectory = $directories | Select-Object -Last 1 |
| 99 | + } |
| 100 | + |
| 101 | + if($profileDirectory) { |
| 102 | + Write-Information "Loaded Azure profile '$($profileDirectory.Name)' for module '$($instance.Name)'" |
| 103 | + $exportsPath = $profileDirectory.FullName |
| 104 | + } |
| 105 | + |
| 106 | + if($exportsPath) { |
| 107 | + Get-ChildItem -Path $exportsPath -Recurse -Include '*.ps1' -File | ForEach-Object { . $_.FullName } |
| 108 | + $cmdletNames = Get-ScriptCmdlet -ScriptFolder $exportsPath |
| 109 | + Export-ModuleMember -Function $cmdletNames -Alias (Get-ScriptCmdlet -ScriptFolder $exportsPath -AsAlias) |
| 110 | + } |
94 | 111 |
|
95 |
| -if($exportsPath) { |
96 |
| - Get-ChildItem -Path $exportsPath -Recurse -Include '*.ps1' -File | ForEach-Object { . $_.FullName } |
97 |
| - $cmdletNames = Get-ScriptCmdlet -ScriptFolder $exportsPath |
98 |
| - Export-ModuleMember -Function $cmdletNames -Alias (Get-ScriptCmdlet -ScriptFolder $exportsPath -AsAlias) |
99 |
| -} |
100 |
| -# Finalize initialization of this module |
101 |
| -$instance.Init(); |
102 |
| -Write-Information "Loaded Module '$($instance.Name)'" |
| 112 | + # Finalize initialization of this module |
| 113 | + $instance.Init(); |
| 114 | + Write-Information "Loaded Module '$($instance.Name)'" |
103 | 115 | # endregion
|
0 commit comments