VMware Cloud Community
mario_981
Enthusiast
Enthusiast
Jump to solution

New Folder

Hi ,

I am trying to create lots of folders of type 'Datacenter' and their corresponding permissions under a newly built vCenter.

All the inputs are fed from csv.

I want to know the working syntax of New-Folder and New-VIPermission for the same-

#Values like $folder,$vCenter,$fRole, $Principal  and are fed from csv through a loop

#loop begins

#create folders of type datacenter under vCenter

New-Folder -Name $folder -Server $vCenter  ( How could I create a folder of type datacenter, get-folder has a type parameter but i saw new-folder doesnt have one )

#create permissions for those folders

New-VIPermission -Role $fRole -Principal $Principal -Entity $folder

#loop ends

Tags (2)
0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

Sure

Get-Folder -Name Datacenters | New-Folder -Name Test


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

View solution in original post

0 Kudos
4 Replies
LucD
Leadership
Leadership
Jump to solution

A folder under a datacenter does not offer the type Datacenter. Only under the vCenter can you have a folder of type Datacenter.

You can only have VM, HostandCLuster, Network and Datastore under a datacenter.

The New-Folder does indeed not yet offer the Type parameter, but you can use the hidden folders.

For example, if you want to create folders of type VM under a datacenter, you can do

$newFolder = Get-Datacenter -Name $dcName  -Server $vCenter |

   Get-Folder -Name vm  -Server $vCenter |

   New-Folder -Name $folder -Server $vCenter


New-VIPermission -Role $fRole -Principal $Principal -Entity $newFolder


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

0 Kudos
mario_981
Enthusiast
Enthusiast
Jump to solution

Thanks - I could understand that i cannot create a folder of type datacenter under an existing datacenter.

But I am trying to create Folder of type ' Datacenter ' under vCenter - do we have a cmdlet for it.

0 Kudos
LucD
Leadership
Leadership
Jump to solution

Sure

Get-Folder -Name Datacenters | New-Folder -Name Test


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

0 Kudos
mario_981
Enthusiast
Enthusiast
Jump to solution

Thanks. Thats perfect !

0 Kudos