VMware Cloud Community
LANTIS1982
Contributor
Contributor

"MountvmfsVolume" in PowerCli .NET Api

Hi

i am trying to develop an app in PowerCli .net Api

i could not find out that how can i use "MountVmfsVolume" method under the HostStorageSystem.

HS.MountVmfsVolume needs an vmfsUuid and i retrive it from "QueryUnresolvedVmfsVolume"

But i get this error :  "The object or item referred to could not be found."

İ try to code like this,

HostStorageSystem HS = new HostStorageSystem(Host.Client, mor);

foreach (HostUnresolvedVmfsVolume V in HS.QueryUnresolvedVmfsVolume())

  {

   string[] array = new string[] { V.VmfsUuid };

      HS.MountVmfsVolume(array[0]);

  

   //HS.MountVmfsVolume(array[0].ToString());

}

Thank you for your help.

Reply
0 Kudos
2 Replies
RvdNieuwendijk
Leadership
Leadership

Your code converted to PowerCLI, will be something like the following:

$VMHostStorage = Get-VMHost -Name ESXi01 | Get-VMHostStorage | Get-View

foreach ($Volume in ($VMHostStorage.QueryUnresolvedVmfsVolume()))

{

   $VMHostStorage.MountVmfsVolume($Volume.vmfsUuid)

}

Blog: https://rvdnieuwendijk.com/ | Twitter: @rvdnieuwendijk | Author of: https://www.packtpub.com/virtualization-and-cloud/learning-powercli-second-edition
Reply
0 Kudos
LANTIS1982
Contributor
Contributor

Hello

İ wrote this code in .NET below  and i found uuid as "56fe100d-d5f3a81a-853b-441ea1430778"

HostStorageSystem HS = new HostStorageSystem(Host.Client, mor);

foreach (var item in HS.QueryUnresolvedVmfsVolume())

  {

  HS.MountVmfsVolume(item.VmfsUuid.ToString());

  }

But i got same error..

Reply
0 Kudos