fborges555
Enthusiast
Enthusiast

reclaim storage

Jump to solution

HI

I am reclaiming storage at this point doing the following

ssh to the esxi

and run esxcli storage vmfs unmap -l DS

can I accomplish the same using PSC to connect to the esxi host and run that command and not SSH to it

I can connect to the esxi by  connect-viserver but I dont know how to run the esxcli storage vmfs unmap -l DS from within Powershell cli

Thanks for any help

0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership

You can use the Get-EsxCli cmdlet for that (while connected to the vCenter).

$esxName ='MyEsx'

$esxcli = Get-EsxCli -VMHost $esxName -V2

$argHash = @{

    volumelabel = 'DS'

}

$esxcli.storage.vmfs.unmap.Invoke($argHash)


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

View solution in original post

0 Kudos
18 Replies
LucD
Leadership
Leadership

You can use the Get-EsxCli cmdlet for that (while connected to the vCenter).

$esxName ='MyEsx'

$esxcli = Get-EsxCli -VMHost $esxName -V2

$argHash = @{

    volumelabel = 'DS'

}

$esxcli.storage.vmfs.unmap.Invoke($argHash)


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

View solution in original post

0 Kudos
fborges555
Enthusiast
Enthusiast

L.

I am glad you dont sleeeeeepppppp

I get this error

pastedImage_0.png

any thought

0 Kudos
LucD
Leadership
Leadership

You would need to provide more info about the storage and its backing.


In KB2048466 it says

"The VAAI primitive UNMAP only works on SAN arrays where the partition offset is a multiple of 1 MB"

VMFS 6 requires unmap granularity of 1MB.

It could be that your SAN has a larger unmap granularity block size than 1MB.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
fborges555
Enthusiast
Enthusiast

L.

where would I go getting more info on this cmdlet

does it matter if the vmfs is 5 or 6 ? they have to be thin provisioning correct ?

Thanks

0 Kudos
fborges555
Enthusiast
Enthusiast

L.

learning curve

what is wrong with this statement

$Esxcli=get-esxcli -vmhost xxx.xxx.xxx.xxx

$Esxcli.storage.vmfs.unmap("DS")

when ran I get

pastedImage_0.png

0 Kudos
LucD
Leadership
Leadership

It could be that port 902 is not open on the ESXi node (FW rule).

You can test with the curl command.

Something like: curl esx.domain:902


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
fborges555
Enthusiast
Enthusiast

L.

I ran your script  and It came back with the following error

Index(zero Base) must be greater than or equal to zero.....

any ideas why

Thanks

0 Kudos
LucD
Leadership
Leadership

Which PowerCLI version are you using?


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
fborges555
Enthusiast
Enthusiast

5.1.1798

0 Kudos
LucD
Leadership
Leadership

Really?

Any specific reason for that?


That is a very old version.

Can you upgrade?
See Welcome PowerCLI to the PowerShell Gallery – Install Process Updates for detailed instructions.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
fborges555
Enthusiast
Enthusiast

L.

Just came with my VDI , my bad I did not check on version and upgrade for a most up-to-date one

on my way

0 Kudos
fborges555
Enthusiast
Enthusiast

L.

I am getting somewhere!!!

after running the script (while on vcenter)

I got the following error

   pastedImage_0.png

Then I connected to the esxi directly and ran the script again but now I get the following

pastedImage_1.png

suggestions chief

Thanks

0 Kudos
LucD
Leadership
Leadership

You are most probably hitting the timeout mentioned (and solved) in PowerCLI for SCSI Unmap


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
fborges555
Enthusiast
Enthusiast

L.

How can I go on your script and check when the entire process is done?

Thanks a bunch

0 Kudos
LucD
Leadership
Leadership

You mean something like this?

$code = {

  $esxName ='MyEsx'


  $esxcli = Get-EsxCli -VMHost $esxName -V2

  $argHash = @{

    volumelabel = 'DS'

  }

  $esxcli.storage.vmfs.unmap.Invoke($argHash)

}

Measure-Command -Expression $code


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
fborges555
Enthusiast
Enthusiast

L.

I would like to know when the process is completed, so I can close the ps session?

I will check on your code

Thanks

0 Kudos
LucD
Leadership
Leadership

That depends how you are running this.

Are you starting a .ps1 script from your PS session?
If yes, adding the following line at the end should work.

Stop-Process $PID


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
fborges555
Enthusiast
Enthusiast

L.

I would like to convert this on a PS1 that can be used on a schedule to run twice a week.

Thanks

0 Kudos