private static PSModuleInfo GetModuleInfo( string modulePath, string secretMgtModulePath, out ErrorRecord error) { // Get module information by loading it. var results = PowerShellInvoker.InvokeScript <PSModuleInfo>( script: @" param ([string] $ModulePath, [string] $SecretMgtModulePath) # ModulePath module may have a dependency on SecretManagement module, # so make sure it is loaded. $null = Import-Module -Name $SecretMgtModulePath -ErrorAction SilentlyContinue Import-Module -Name $ModulePath -PassThru ", args: new object[] { modulePath, secretMgtModulePath }, out error); return((results.Count == 1) ? results[0] : null); }