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

Assert-Module: Outputs unnecessary verbose statements due to -ListAvailable is used each time #66

Closed
johlju opened this issue Mar 20, 2021 · 0 comments · Fixed by #67
Closed
Labels
enhancement The issue is an enhancement request.

Comments

@johlju
Copy link
Member

johlju commented Mar 20, 2021

Details of the scenario you tried and the problem that is occurring

Every time when running Assert-Module and $VerbosePreference is set to 'Continue' the command outputs a lot of verbose statements depending on what module is asserted.

Steps to reproduce the problem

$VerbosePreference = 'Continue'
Assert-Module -ModuleName 'DnsServer'

Outputs

VERBOSE: Loading module from path
'C:\Windows\system32\WindowsPowerShell\v1.0\Modules\DnsServer\PS_DnsServerCache_v1.0.0.cdxml'.
VERBOSE: Loading module from path
'C:\Windows\system32\WindowsPowerShell\v1.0\Modules\DnsServer\PS_DnsServerConditionalForwarder_v1.0.0.cdxml'.
VERBOSE: Loading module from path
'C:\Windows\system32\WindowsPowerShell\v1.0\Modules\DnsServer\PS_DnsServerDiagnostics_v1.0.0.cdxml'.
VERBOSE: Loading module from path
'C:\Windows\system32\WindowsPowerShell\v1.0\Modules\DnsServer\PS_DnsServerDirectoryPartition_v1.0.0.cdxml'.
VERBOSE: Loading module from path
'C:\Windows\system32\WindowsPowerShell\v1.0\Modules\DnsServer\PS_DnsServerDsSetting_v1.0.0.cdxml'.
VERBOSE: Loading module from path

.... Removed rows for readability

VERBOSE: Loading module from path
'C:\Windows\system32\WindowsPowerShell\v1.0\Modules\DnsServer\PS_DnsServerRecursionScope_v1.0.0.cdxml'.
VERBOSE: Loading module from path
'C:\Windows\system32\WindowsPowerShell\v1.0\Modules\DnsServer\PS_DnsServerQueryResolutionPolicy_v1.0.0.cdxml'.
VERBOSE: Loading module from path
'C:\Windows\system32\WindowsPowerShell\v1.0\Modules\DnsServer\PS_DnsServerZoneTransferPolicy_v1.0.0.cdxml'.
VERBOSE: Loading module from path
'C:\Windows\system32\WindowsPowerShell\v1.0\Modules\DnsServer\PS_DnsServerPolicy_v1.0.0.cdxml'.
VERBOSE: Loading module from path
'C:\Windows\system32\WindowsPowerShell\v1.0\Modules\DnsServer\PS_DnsServerResponseRateLimiting_v1.0.0.cdxml'.
VERBOSE: Loading module from path
'C:\Windows\system32\WindowsPowerShell\v1.0\Modules\DnsServer\PS_DnsServerResponseRateLimitingExceptionlist_v1.0.0.cdxml'.
VERBOSE: Loading module from path
'C:\Windows\system32\WindowsPowerShell\v1.0\Modules\DnsServer\PS_DnsServerVirtualizationInstance_v1.0.0.cdxml'.

Expected behavior

Only show these verbose messages when the module to assert is not in the session.

Current behavior

Always shows the verbose messages even if the module is already present in the session

Suggested solution to the issue

This is due to -ListAvailable is always used.

if (-not (Get-Module -Name $ModuleName -ListAvailable))

Suggest adding an evaluation if (-not (Get-Module -Name $ModuleName)) before using -ListAvailable. Using that will not output the verbose messages,.

The operating system the target node is running

Windows Server 2016

Version and build of PowerShell the target node is running

5.1

Version of the module that was used

0.10.1

@johlju johlju changed the title Assert-Module: Outputs unnecessary verbose statements due to ListAvailable is used each time Assert-Module: Outputs unnecessary verbose statements due to -ListAvailable is used each time Mar 20, 2021
@johlju johlju added enhancement The issue is an enhancement request. help wanted The issue is up for grabs for anyone in the community. labels Mar 20, 2021
@johlju johlju added in progress The issue is being actively worked on by someone. and removed help wanted The issue is up for grabs for anyone in the community. labels Mar 20, 2021
johlju added a commit that referenced this issue Mar 24, 2021
- `Assert-Module`
  - Now it possible to forcibly import a module using `-ImportModule -Force`
  - It no longer outputs verbose messages that is normally generated when
    using `Get-Module -ListAvailable` if the module that is asserted is
    already in the session (issue #66).
@johlju johlju removed the in progress The issue is being actively worked on by someone. label Mar 24, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement The issue is an enhancement request.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant