Compton94
Contributor
Contributor

Creation of folders in the datastore view with powercli

Jump to solution

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

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

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
Compton94
Contributor
Contributor

LucD,

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

Matt

0 Kudos