Passing a Module array to Get-Command imports modules! - by Joel 'Jaykul' Bennett

Status : 

  Fixed<br /><br />
		This item has been fixed in the current or upcoming version of this product.<br /><br />
		A more detailed explanation for the resolution of this particular item may have been provided in the comments section.

Sign in
to vote
ID 724659 Comments
Status Closed Workarounds
Type Bug Repros 4
Opened 2/12/2012 8:58:27 PM
Access Restriction Public


If I call Get-Command with a list of modules and the command I'm looking for is in a *different* module, it's not found, BUT THAT MODULE IS IMPORTED!

When you call Get-Command with a module name, and the command isn't in that module, you get an error because the command isn't found.  However, if you provide more than one module name, then Get-Command will load the module that DOES contain the command:

Remove-Module Microsoft.PowerShell.Security

# No command found, no module loaded accidentally:
Get-Command Get-Acl -Module Microsoft.PowerShell.Management

# No command found, but the Microsoft.PowerShell.Security module gets loaded!
Get-Command Get-Acl -Module Microsoft.PowerShell.Management, Microsoft.PowerShell.Core
Sign in to post a comment.
Posted by Chris J Warwick on 2/16/2012 at 5:04 AM
Good blog entry - thanks:)

I'm not actually sure I even like the "automatically find a command" option in V3.