I have used Az module in powershell script which is getting executed from powershell core but getting error while executing the script from application (.Net core SDK 2.1).
$VMExistanceCheck = Get-azVM -ResourceGroupName $VMResourceGroup -Name $NewComputerName -ErrorAction SilentlyContinue
I checked that Az.Compute module had been imported there.
I added Import-Module Az.compute -verbose -force
inside the script also.
I got the following error while the script is getting invoked from application using runspace(System.Management.Automation, Version=6.1.0.0):
System.Management.Automation.RuntimeException: The 'Get-azVM' command was found in the module 'Az.Compute', but the module could not be loaded. For more information, run 'Import-Module Az.Compute'. ---> System.Management.Automation.CommandNotFoundException: The 'Get-azVM' command was found in the module 'Az.Compute', but the module could not be loaded. For more information, run 'Import-Module Az.Compute'.
'Get-Module -ListAvailable ' shows that Az.Compute module is avilable but while the command 'import-module Az.Compute' is executed using Powershell 6, nothing is importing.