VMware Cloud Community
vmk2014
Expert
Expert

Invoke power cli script esxcli storage vmfs unmap

Invoke power cli script esxcli storage vmfs unmap -l

against all the data store.C:\temp\Datastores

Example :-

esxcli storage vmfs unmap -l Windows_PVMAX_3539

Planning to use the scheduled job from windows tasks scheduler.

Any lead will be much appreciated.

thanks

vmk

Tags (1)
Reply
0 Kudos
5 Replies
LucD
Leadership
Leadership

Not sure what you mean by C:\Temp\Datastores, but I assume that is a CSV that contains the datastorenames (under property Name).

In that case, you could do something like this.
If that file is of a different format, the way the script would obtain the datastorenames would need to be changed.

$dsNames = Import-Csv -Path C:\Temp\Datastores.csv -UseCulture


Get-VMHost |

ForEach-Object -Process {

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

   $dsNames | ForEach-Object -Process {

     $esxcli.storage.vmfs.unmap.Invoke(@{'volumelabel'="$($_.Name)"})

   }

}


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

Reply
0 Kudos
vmk2014
Expert
Expert

LucD,

My apologies, it will datastores.csv. We are having vmfs5.5, hence disk pool is getting full from storage end,so inorder to reclaim space we are running everytime manually, until we upgrade to VMFS6.0

Can we schedule this from windows tasks scheduler ?

thanks

vmk

Reply
0 Kudos
LucD
Leadership
Leadership

That should not be a problem.
Have a look at Re: scheduling_powershell script_task scheduler  to see how to create such a shceduled task.


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

Reply
0 Kudos
vmk2014
Expert
Expert

LucD,

Thanks for your response for both the query. I'll get back after testing the script and update you.

Thanks

vm

Reply
0 Kudos
ans4vmware
Contributor
Contributor

How does the input CSV file look ?

Please comment.

Reply
0 Kudos