{"id":23046927,"url":"https://github.com/matsest/get-az-modules","last_synced_at":"2026-05-15T20:05:10.993Z","repository":{"id":106353557,"uuid":"411453883","full_name":"matsest/get-az-modules","owner":"matsest","description":"Identify exactly which Az modules you need to run your script","archived":false,"fork":false,"pushed_at":"2024-01-31T09:53:47.000Z","size":12,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-10-11T18:20:39.655Z","etag":null,"topics":["az","azure","azure-powershell","dependencies","dependencies-checking","powershell","pwsh"],"latest_commit_sha":null,"homepage":"","language":"PowerShell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/matsest.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2021-09-28T22:18:49.000Z","updated_at":"2025-04-09T11:48:18.000Z","dependencies_parsed_at":null,"dependency_job_id":"ebd5f322-135e-4c80-bdb9-ab53c3bf2f9e","html_url":"https://github.com/matsest/get-az-modules","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/matsest/get-az-modules","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/matsest%2Fget-az-modules","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/matsest%2Fget-az-modules/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/matsest%2Fget-az-modules/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/matsest%2Fget-az-modules/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/matsest","download_url":"https://codeload.github.com/matsest/get-az-modules/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/matsest%2Fget-az-modules/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33078024,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-15T11:35:32.926Z","status":"ssl_error","status_checked_at":"2026-05-15T11:35:31.362Z","response_time":103,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["az","azure","azure-powershell","dependencies","dependencies-checking","powershell","pwsh"],"created_at":"2024-12-15T22:30:05.321Z","updated_at":"2026-05-15T20:05:10.965Z","avatar_url":"https://github.com/matsest.png","language":"PowerShell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Get Az Modules\n\n## Description\n\nA Powershell script that identifies which Az modules is needed to run a script that contains Az cmdlets. Can also be used to identify required Az modules for your custom module.\n\nAvoid installing all [Az.* modules](https://github.com/Azure/azure-powershell/) in GitHub runners, Azure Automation accounts and other transient/minimal environments to save time and resources and handle your dependencies more explicitly.\n\nWhy?\n\n1. Only use the depencies you need (only use required modules)\n2. Deal with dependencies explicitly (use required versions)\n\nPS: If you're new to the Az module please refer to the [official installation docs](https://docs.microsoft.com/en-us/powershell/azure/install-az-ps).\n\n## Usage\n\n\n```powershell\n./Get-AzModules.ps1 -Path \u003cpath to .ps1 or .psm1 file\u003e\n```\n\n### Examples\n\nTips: Try to run the script against any of the files in [examples](./examples).\n\n#### Basic usage\n\n```powershell\n./Get-AzModules.ps1 -Path ./examples/sample.ps1\n\nLooking for Az modules needed for sample.ps1...\nNumber of unique Az cmdlets found: 17\nNumber of Az modules used: 3\nAz.Compute\nAz.Network\nAz.Resources\n```\n\n#### Check versions of installed modules\n```powershell\n./Get-AzModules.ps1 -Path ./examples/sample.ps1 -CheckVersions\n\nLooking for Az modules needed for sample.ps1...\nNumber of unique Az cmdlets found: 17\nNumber of Az modules used: 3\nWARNING: Az.Resources: latest version [4.3.1] newer than installed version [4.2.0]\nWARNING: Az.Compute: latest version [4.17.0] newer than installed version [4.15.0]\nWARNING: Az.Network: latest version [4.11.0] newer than installed version [4.10.0]\n\nName         InstalledVersion LatestVersion\n----         ---------------- -------------\nAz.Resources 4.2.0            4.3.1\nAz.Compute   4.15.0           4.17.0\nAz.Network   4.10.0           4.11.0\n```\n\n#### Get info about modules not installed\n\n```powershell\n/Get-AzModules.ps1 -Path ./examples/nondefault.ps1\n\nLooking for Az modules needed for nondefault.ps1...\nNumber of unique Az cmdlets found: 3\nWARNING: Get-AzSubscriptionAlias was not found. Available in module Az.Subscription [0.8.0] from PSGallery\nWARNING: Get-AzStackEdgeDevice was not found. Available in module Az.StackEdge [0.1.0] from PSGallery\nNumber of Az modules used: 3\nAz.Resources\nAz.StackEdge\nAz.Subscription\n```\n\n#### Print all cmdlets\n\n```powershell\n./Get-AzModules.ps1 -Path ./examples/sample.ps1 -Verbose\n\nLooking for Az modules needed for sample.ps1...\nNumber of unique Az cmdlets found: 17\nVERBOSE: New-AzResourceGroup uses Az.Resources\nVERBOSE: New-AzAvailabilitySet uses Az.Compute\nVERBOSE: New-AzVirtualNetworkSubnetConfig uses Az.Network\nVERBOSE: New-AzVirtualNetwork uses Az.Network\nVERBOSE: New-AzPublicIpAddress uses Az.Network\nVERBOSE: New-AzLoadBalancerFrontendIpConfig uses Az.Network\nVERBOSE: New-AzLoadBalancerBackendAddressPoolConfig uses Az.Network\nVERBOSE: New-AzLoadBalancerProbeConfig uses Az.Network\nVERBOSE: New-AzLoadBalancerRuleConfig uses Az.Network\nVERBOSE: New-AzLoadBalancer uses Az.Network\nVERBOSE: New-AzNetworkInterfaceIpConfig uses Az.Network\nVERBOSE: New-AzNetworkInterface uses Az.Network\nVERBOSE: New-AzVMConfig uses Az.Compute\nVERBOSE: Set-AzVMOperatingSystem uses Az.Compute\nVERBOSE: Set-AzVMSourceImage uses Az.Compute\nVERBOSE: Add-AzVMNetworkInterface uses Az.Compute\nVERBOSE: New-AzVM uses Az.Compute\nNumber of Az modules used: 3\nAz.Compute\nAz.Network\nAz.Resources\n```\n\n#### Use in script or pipeline\n\n```powershell\n$modules = ./Get-AzModules.ps1 -Path ./examples/sample.ps1 -CheckVersions\n\nforeach ($module in $modules){\n    Install-Module $module.Name -RequiredVersion $module.LatestVersion -Force\n}\n```\n\n#### Check against other modules than Az\n```powershell\n./Get-AzModules.ps1 -Path ./examples/sample-mg.ps1 -Prefix Mg\n\nLooking for Mg modules needed for sample-mg.ps1...\nNumber of unique Mg cmdlets found: 3\nNumber of Mg modules used: 3\nMicrosoft.Graph.Authentication\nMicrosoft.Graph.Teams\nMicrosoft.Graph.Users\n```\n\n## Dealing with dependencies in scripts\n\n### Using #requires\n\nIn the beginning of your script you can add the [#requires](https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_requires?view=powershell-7.4#-modules-module-name--hashtable) statement.\n\n```powershell\n#Requires -Modules @{ ModuleName=\"\u003cmodulename\u003e\"; ModuleVersion=\"\u003cversion\u003e\" }\n```\n\nThis will need to be added for each module you want to use. Note that `ModuleVersion` only specifies the minimum acceptable version of the module. To require an exact, required version of a module, replace `ModuleVersion` with `RequiredVersion`.\n\n## Using Import-Module\n\nAn alternative is to in your script, or in a separate script, run [`Import-Module`](https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/import-module?view=powershell-7.4) explicitly with versions specified:\n\n```powershell\nImport-Module -Name Az.Resources -RequiredVersion 4.3.1 # specify exact version\nImport-Module -Name Az.Resources -MinimumVersion 4.3.0 # specify minimum version\nImport-Module -Name Az.Resources -MaximumVersion 4.4.0 # specify maximum version\n```\n\nYou can also add `-ErrorAction Stop` to the cmdlets or set `$ErrorActionPreference=\"Stop\"` in your script to ensure the script ensures the cmdlets run without errors.\n\n## License\n\nThe MIT License applies to the code contained in this repo. For more information, see [LICENSE](./LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmatsest%2Fget-az-modules","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmatsest%2Fget-az-modules","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmatsest%2Fget-az-modules/lists"}