Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The Test-PowerShellModuleExist function is irrelevant and should be removed #236

Open
JimMoyle opened this issue May 6, 2024 · 0 comments

Comments

@JimMoyle
Copy link

JimMoyle commented May 6, 2024

Brief description of your issue

PowerShell provides a native way to check for required modules and a separate function isn't needed as documented here:

https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_requires?view=powershell-7.4#-modules-module-name--hashtable
The entire test logic for the modules can be replaced by the single line:

#Requires -Modules Az.Resources, Az.Accounts, Az.Websites, Az.Functions, Az.Storage

This line can be placed anywhere in the script, but goes into the begin block by convention.

I will improve the script be bringing it inline with PowerShell standards and making it quicker to error when the modules are not present.

Steps to reproduce

Remove the module test logic and replace with the single line above

Expected behavior

the module cannot be loaded without the modules being present

Actual behavior

module loads, but fails on initial run.

Environment

N/A
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant