@@ -74,7 +74,10 @@ public async Task<bool> ImportPlasterIfInstalledAsync()
7474
7575 IReadOnlyList < PSObject > moduleObject =
7676 await _executionService . ExecutePSCommandAsync < PSObject > (
77- psCommand , CancellationToken . None ) . ConfigureAwait ( false ) ;
77+ psCommand ,
78+ CancellationToken . None ,
79+ new PowerShellExecutionOptions { ThrowOnError = false } )
80+ . ConfigureAwait ( false ) ;
7881
7982 isPlasterInstalled = moduleObject . Count > 0 ;
8083 _logger . LogTrace ( "Plaster installed: " + isPlasterInstalled . Value ) ;
@@ -86,13 +89,19 @@ await _executionService.ExecutePSCommandAsync<PSObject>(
8689
8790 psCommand = new PSCommand ( ) ;
8891 psCommand
89- . AddCommand ( "Import-Module" )
92+ . AddCommand ( "Microsoft.PowerShell.Core \\ Import-Module" )
9093 . AddParameter ( "ModuleInfo" , ( PSModuleInfo ) moduleObject [ 0 ] . ImmediateBaseObject )
91- . AddParameter ( "PassThru" ) ;
94+ . AddParameter ( "PassThru" )
95+ . AddParameter ( "ErrorAction" , ActionPreference . Ignore ) ;
9296
93- IReadOnlyList < PSModuleInfo > importResult = await _executionService . ExecutePSCommandAsync < PSModuleInfo > ( psCommand , CancellationToken . None ) . ConfigureAwait ( false ) ;
97+ IReadOnlyList < PSModuleInfo > plasterModule =
98+ await _executionService . ExecutePSCommandAsync < PSModuleInfo > (
99+ psCommand ,
100+ CancellationToken . None ,
101+ new PowerShellExecutionOptions { ThrowOnError = false } )
102+ . ConfigureAwait ( false ) ;
94103
95- isPlasterLoaded = importResult . Count > 0 ;
104+ isPlasterLoaded = plasterModule . Count > 0 ;
96105 _logger . LogTrace ( "Plaster loaded: " + isPlasterLoaded ) ;
97106 }
98107 }
0 commit comments