@@ -121,7 +121,8 @@ public static void ExecuteSynchronouslyOrAsJob<T>(this T cmdlet, Action<T> execu
121
121
throw new ArgumentNullException ( nameof ( executor ) ) ;
122
122
}
123
123
124
- if ( cmdlet . AsJobPresent ( ) )
124
+ // Since right now NoWait and AsJob are not in different parameter sets this check is necessary
125
+ if ( cmdlet . IsBound ( "AsJob" ) && ! cmdlet . IsBound ( "NoWait" ) )
125
126
{
126
127
cmdlet . WriteObject ( cmdlet . ExecuteAsJob ( cmdlet . ImplementationBackgroundJobDescription , executor ) ) ;
127
128
}
@@ -212,7 +213,7 @@ public static void SafeCopyParameterSet<T>(this T source, T target) where T : Az
212
213
/// <returns>true if the parameter was provided by the user, otherwise false</returns>
213
214
public static bool IsBound ( this PSCmdlet cmdlet , string parameterName )
214
215
{
215
- return cmdlet . MyInvocation . BoundParameters . ContainsKey ( parameterName ) ;
216
+ return cmdlet . MyInvocation ? . BoundParameters . ContainsKey ( parameterName ) ?? false ;
216
217
}
217
218
218
219
public static string AsAbsoluteLocation ( this string realtivePath )
@@ -358,7 +359,7 @@ public static List<T> ExecuteScript<T>(this PSCmdlet cmdlet, string contents)
358
359
public static bool IsParameterBound < TPSCmdlet , TProp > ( this TPSCmdlet cmdlet , Expression < Func < TPSCmdlet , TProp > > propertySelector ) where TPSCmdlet : PSCmdlet
359
360
{
360
361
var propName = ( ( MemberExpression ) propertySelector . Body ) . Member . Name ;
361
- return cmdlet . MyInvocation . BoundParameters . ContainsKey ( propName ) ;
362
+ return cmdlet . IsBound ( propName ) ;
362
363
}
363
364
364
365
#region PowerShell Commands
0 commit comments