VMware Cloud Community
Compton94
Contributor
Contributor
Jump to solution

Creation of folders in the datastore view with powercli

HI,

we are trying to automate some parts of a build script and we would like to create a folder within the Datastores View to move all the local disk to.  the only location I can create a folder has been in the Cluster, DataCenter and VM views.  is there a way to accomplish this?

thanks

Matt

0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

That is a hidden folder named "datastore".

You can do

$dsHome = Get-Folder -Name datastore
New-Folder -Name MyFolder -Location $dsHome

Note that there is 1 "datastore" folder per datacenter.

If you have more than 1 datacenter in your vCenter, you will have to indicate which "datastore" folder you want by passing the datacenter.

$dc = Get-Datacenter -Name DC
$dsHome = Get-Folder -Name datastore -Location $dc
New-Folder -Name MyFolder -Location $dsHome


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

View solution in original post

0 Kudos
2 Replies
LucD
Leadership
Leadership
Jump to solution

That is a hidden folder named "datastore".

You can do

$dsHome = Get-Folder -Name datastore
New-Folder -Name MyFolder -Location $dsHome

Note that there is 1 "datastore" folder per datacenter.

If you have more than 1 datacenter in your vCenter, you will have to indicate which "datastore" folder you want by passing the datacenter.

$dc = Get-Datacenter -Name DC
$dsHome = Get-Folder -Name datastore -Location $dc
New-Folder -Name MyFolder -Location $dsHome


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

0 Kudos
Compton94
Contributor
Contributor
Jump to solution

LucD,

thanks for that, it was exactly what we were looking for.

Matt

0 Kudos