title: Azure Powershell Command was found in the module, but the module could not be loaded
body: <p>I have used Az module in winform to control the Azure Winform but getting error while executing the script from winform.</p>
  
  <pre><code>Using objPS As PowerShell = PowerShell.Create()
      'Create the Selected Snapshot to VM OS Disk
      Dim strPowerShellScriptCreateOsDisk = "$storageType = 'StandardSSD_LRS'
                                             $location = 'Southeast Asia'
                                             $diskSizeGB = 64
                                             $snapshot = Get-AzSnapshot -ResourceGroupName '" &amp; gstrResourceGroupName &amp; "' -SnapshotName '" &amp; gstrSelectedSnapshot &amp; "' 
                                                               $osDisk = New-AzDisk -DiskName '" &amp; gstrSelectedSnapshot &amp; "_" &amp; gstrVmName &amp; "' -Disk `
                                                               (New-AzDiskConfig -AccountType $storageType -DiskSizeGB $diskSizeGB `
                                                               -Location $location -CreateOption Copy `
                                                               -SourceResourceId $snapshot.Id) `
                                                               -ResourceGroupName '" &amp; gstrResourceGroupName &amp; "'"
  
              'Swap the Created VM OS Disk to Virtual Machine
              Dim strPowerShellScriptSwapOsDisk = "$vm = Get-AzVM -ResourceGroupName '" &amp; gstrResourceGroupName &amp; "' -Name '" &amp; gstrVmName &amp; "'
                                               $disk = Get-AzDisk -ResourceGroupName '" &amp; gstrResourceGroupName &amp; "' -Name '" &amp; gstrSelectedSnapshot &amp; "_" &amp; gstrVmName &amp; "' 
                                               Set-AzVMOSDisk -VM $vm -ManagedDiskId $disk.Id -Name $disk.Name 
                                               Update-AzVM -ResourceGroupName '" &amp; gstrResourceGroupName &amp; "' -VM $vm"
  
  
              'Delete the Replaced Old Disk from Azure Storage
              Dim strPowerShellScriptDeleteDisk = "Remove-AzDisk -ResourceGroupName '" &amp; gstrResourceGroupName &amp; "' -DiskName '" &amp; strOldDisk &amp; "' -Force"
  
  
              objPS.AddScript(strPowerShellScriptConnectAccount + vbNewLine + strPowerShellScriptCreateOsDisk + vbNewLine + strPowerShellScriptSwapOsDisk + vbNewLine + strPowerShellScriptDeleteDisk)
  
              ' Check if objResult is Nothing then Ignore
              For Each objResult As PSObject In objPS.Invoke()
                  If objResult IsNot Nothing Then Debug.WriteLine(objResult.ToString())
              Next
          End Using
  </code></pre>
  
  <p>It worked on my computer, but when I publish the exe to another computer, the function is not working anymore. I get these errors </p>
  
  <blockquote>
    <p>The 'Disconnect-AzAccount' command was found in the module 'Az.Accounts', but the module could not be loaded. For more information, run 'Import-Module Az.Accounts'.</p>
  </blockquote>
  
  <p>and</p>
  
  <blockquote>
    <p>The 'Get-AzSnapshot' command was found in the module 'Az.Compute', but the module could not be loaded. For more information, run 'Import-Module Az.Compute'</p>
  </blockquote>
  
  <p>but I make sure the target computer Azure powershell, az module, .net core and .net framework is installed and updated. Is there any action I need to install in the target computer?</p>