I am trying to run PowerShell script to Create the target resource settings object for a VM. But it’s throwing error :
PS /home/user> $targetResourceSettingsObj = New-Object Microsoft.Azure.PowerShell.Cmdlets.ResourceMover.Models.Api202101.VirtualMachineResourceSettings
New-Object: Cannot find type [Microsoft.Azure.PowerShell.Cmdlets.ResourceMover.Models.Api202101.VirtualMachineResourceSettings]: verify that the assembly containing this type is loaded.
I found it’s a dependency Assembly needs to be installed for that.
https://learn.microsoft.com/en-us/dotnet/api/microsoft.azure.powershell.cmdlets.resourcemover.models.api202101.virtualmachineresourcesettings?view=az-ps-7
How to import it in PowerShell script? I am trying to do this on Azure portal through PowerShell.
2
Answers
I tried solution from shared link by jdweng:
VERBOSE: Authenticating to Azure ... VERBOSE: Building your Azure drive ... PS /home/user> Install-Module AzureAD -Scope CurrentUser -Force
PS /home/user> Import-Module AzureAD -Force
Import-Module: Assembly with same name is already loaded PS /home/user> $targetResourceSettingsObj = New-Object Microsoft.Azure.PowerShell.Cmdlets.ResourceMover.Models.Api202101.VirtualMachineResourceSettings New-Object: Cannot find type [Microsoft.Azure.PowerShell.Cmdlets.ResourceMover.Models.Api202101.VirtualMachineResourceSettings]: verify that the assembly containing this type is loaded.
But it didn't work.
I tried
Add-type -path "Az.ResourceMover.private.dll’
It didn’t work