Search code examples
powershellzippscx

How to call an overloaded command in PowerShell


My PowerShell environment has two Expand-Archive commands:

  • Windows 10 -> a function from Microsoft.PowerShell.Archive (1.0.1.0)
  • PowerShell Community Extension -> a CmdLet from Pscx (3.2.2)

My current environment defaults to the CmdLet from Pscx:

PS> (Get-Command Expand-Archive).ModuleName
Pscx

Is there any syntax (fully qualified name) to call a command from another module?
I do not want to unload Pscx.


Solution

  • You can always call a function with its fully-qualified module name.

    In your example:

    Microsoft.PowerShell.Archive\Expand-Archive -Path $Path -Destination $Dest
    

    I think when you don't specify the module, it uses whatever was loaded last