|
| 1 | +# region Generated |
| 2 | + # ---------------------------------------------------------------------------------- |
| 3 | + # Copyright (c) Microsoft Corporation. All rights reserved. |
| 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 | +# Code generated by Microsoft (R) AutoRest Code Generator.Changes may cause incorrect behavior and will be lost if the code |
| 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 | + } |
| 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 | + } |
| 32 | + } |
| 33 | + } |
| 34 | + |
| 35 | + if(-not $accountsModule) { |
| 36 | + Write-Error "`nThis module requires $accountsName version 2.7.5 or greater. For installation instructions, please see: https://learn.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)'" |
| 41 | + |
| 42 | + # Load the private module dll |
| 43 | + $null = Import-Module -Name (Join-Path $PSScriptRoot './bin/Az.Dns.private.dll') |
| 44 | + |
| 45 | + # Get the private module's instance |
| 46 | + $instance = [Microsoft.Azure.PowerShell.Cmdlets.Dns.Module]::Instance |
| 47 | + |
| 48 | + # Ask for the shared functionality table |
| 49 | + $VTable = Register-AzModule |
| 50 | + |
| 51 | + # Tweaks the pipeline on module load |
| 52 | + $instance.OnModuleLoad = $VTable.OnModuleLoad |
| 53 | + |
| 54 | + # Following two delegates are added for telemetry |
| 55 | + $instance.GetTelemetryId = $VTable.GetTelemetryId |
| 56 | + $instance.Telemetry = $VTable.Telemetry |
| 57 | + |
| 58 | + |
| 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 |
| 73 | + |
| 74 | + |
| 75 | + # Load the custom module |
| 76 | + $customModulePath = Join-Path $PSScriptRoot './custom/Az.Dns.custom.psm1' |
| 77 | + if(Test-Path $customModulePath) { |
| 78 | + $null = Import-Module -Name $customModulePath |
| 79 | + } |
| 80 | + |
| 81 | + # Export nothing to clear implicit exports |
| 82 | + Export-ModuleMember |
| 83 | + |
| 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 | + } |
| 111 | + |
| 112 | + # Finalize initialization of this module |
| 113 | + $instance.Init(); |
| 114 | + Write-Information "Loaded Module '$($instance.Name)'" |
| 115 | +# endregion |
0 commit comments