@@ -701,6 +701,15 @@ private CommandInfo GetCommandInfoInternal(string cmdName, CommandTypes commandT
701
701
return null ;
702
702
}
703
703
704
+ // Don't hold the lock during the pipeline call
705
+ lock ( getCommandLock )
706
+ {
707
+ CommandInfo cmdletInfo ;
708
+ if ( commandInfoCache . TryGetValue ( cmdName , out cmdletInfo ) ) {
709
+ return cmdletInfo ;
710
+ }
711
+ }
712
+
704
713
using ( var ps = System . Management . Automation . PowerShell . Create ( ) )
705
714
{
706
715
var psCommand = ps . AddCommand ( "Get-Command" )
@@ -711,6 +720,14 @@ private CommandInfo GetCommandInfoInternal(string cmdName, CommandTypes commandT
711
720
var commandInfo = psCommand . Invoke < CommandInfo > ( )
712
721
. FirstOrDefault ( ) ;
713
722
723
+ lock ( getCommandLock )
724
+ {
725
+ CommandInfo cmdletInfo ;
726
+ if ( ! commandInfoCache . TryGetValue ( cmdName , out cmdletInfo ) )
727
+ {
728
+ commandInfoCache . Add ( cmdName , commandInfo ) ;
729
+ }
730
+ }
714
731
return commandInfo ;
715
732
}
716
733
}
@@ -723,6 +740,8 @@ private CommandInfo GetCommandInfoInternal(string cmdName, CommandTypes commandT
723
740
/// <returns>The first CommandInfo found based on the name and type or null if nothing was found</returns>
724
741
public CommandInfo GetCommandInfo ( string name , CommandTypes commandType )
725
742
{
743
+ // We don't check for alias in this case as the user has been explicit about
744
+ // the CommandTypes desired
726
745
return GetCommandInfoInternal ( name , commandType ) ;
727
746
}
728
747
@@ -733,7 +752,13 @@ public CommandInfo GetCommandInfo(string name, CommandTypes commandType)
733
752
/// <returns>The first CommandInfo found based on the name of any command type or null if nothing was found</returns>
734
753
public CommandInfo GetCommandInfo ( string name )
735
754
{
736
- return GetCommandInfo ( name , CommandTypes . All ) ;
755
+ // check to see if it's an alias and use the resolved cmdlet name if it is
756
+ string cmdletName = Helper . Instance . GetCmdletNameFromAlias ( name ) ;
757
+ if ( string . IsNullOrWhiteSpace ( cmdletName ) )
758
+ {
759
+ cmdletName = name ;
760
+ }
761
+ return GetCommandInfo ( cmdletName , CommandTypes . All ) ;
737
762
}
738
763
739
764
/// <summary>
0 commit comments