@@ -701,6 +701,15 @@ private CommandInfo GetCommandInfoInternal(string cmdName, CommandTypes commandT
701701                return  null ; 
702702            } 
703703
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+ 
704713            using  ( var  ps  =  System . Management . Automation . PowerShell . Create ( ) ) 
705714            { 
706715                var  psCommand  =  ps . AddCommand ( "Get-Command" ) 
@@ -711,6 +720,14 @@ private CommandInfo GetCommandInfoInternal(string cmdName, CommandTypes commandT
711720                var  commandInfo  =  psCommand . Invoke < CommandInfo > ( ) 
712721                         . FirstOrDefault ( ) ; 
713722
723+                 lock  ( getCommandLock ) 
724+                 { 
725+                     CommandInfo  cmdletInfo ; 
726+                     if  ( !  commandInfoCache . TryGetValue ( cmdName ,  out  cmdletInfo )  ) 
727+                     { 
728+                         commandInfoCache . Add ( cmdName ,  commandInfo ) ; 
729+                     } 
730+                 } 
714731                return  commandInfo ; 
715732            } 
716733        } 
@@ -723,6 +740,8 @@ private CommandInfo GetCommandInfoInternal(string cmdName, CommandTypes commandT
723740        /// <returns>The first CommandInfo found based on the name and type or null if nothing was found</returns> 
724741        public  CommandInfo  GetCommandInfo ( string  name ,  CommandTypes  commandType ) 
725742        { 
743+             // We don't check for alias in this case as the user has been explicit about 
744+             // the CommandTypes desired 
726745            return  GetCommandInfoInternal ( name ,  commandType ) ; 
727746        } 
728747
@@ -733,7 +752,13 @@ public CommandInfo GetCommandInfo(string name, CommandTypes commandType)
733752        /// <returns>The first CommandInfo found based on the name of any command type or null if nothing was found</returns> 
734753        public  CommandInfo  GetCommandInfo ( string  name ) 
735754        { 
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 ) ; 
737762        } 
738763
739764        /// <summary> 
0 commit comments