Greetings,
I am trying to create folders [as I had done via the fat client] under the view VMs and Templates > Datacenter "x" and [these are blue folders] with VMs.
Yet, when use the PowerCLi command: Get-Datacenter "x" | New-Folder -Name "testing" [ these are yellow color ]
It will ONLY create the folder under the View Hosts and Clusters $toplevel.
Which command ( if possible ) would allow me to create folders under the same Datacenter, yet VIEW of VMs and Templates.??
I can elaborate if necessary.
But you should use the hidden folder called "vm" (like in my code).
Then your new blue folder will be created directly under the datacenter.
The code you found is doing exactly the same (that vmfolder is in fact the hidden "vm" folder I mentioned), but it goes the long way round of following pointers
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
The blue folders start under the hidden "vm" folder.
So you could do
$location = Get-Datacenter -Name MyDC | get-folder -Name vm
New-folder -Name MyBlueFolder -Location $location
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Thanks lucD.. but ALMOST..
So, what you provided was how to create a subfolder under a "blue" folder which already exists. That worked.
How does one create the top level "blue folder" under that Datacenter..
_ because as per get-help from new-folder, this will result in creating a “yellow” host and cluster folder.
Not sure what you mean, the code I gave will create a blue folder directly under datacenter MyDC, in VMs and Templates.
Do you mean the "vm" folder when you say "... a "blue" folder which already exists"
The hidden "vm" folder is always there directly under each datacenter.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Your command only creates a folder under an already created "blue folder". It does not create a new folder directly under the Datacenter when the you are in view - VMs and Templates.
Example > $location = Get-Datacenter -Name CHI | get-folder -Name test
This would mean there is already a folder name "test"
I want to be able to create the folder named "test".
Because as per get-help from new-folder, this will result in creating a “yellow” host and cluster folder. I'm finding online that in order to create a vm folder i have to use method CreateFolder(string)
Found this..
(get-view (get-view -ViewType datacenter -Filter @{"name"="myDC"}).VmFolder).CreateFolder("myTopLevelFolder")
But you should use the hidden folder called "vm" (like in my code).
Then your new blue folder will be created directly under the datacenter.
The code you found is doing exactly the same (that vmfolder is in fact the hidden "vm" folder I mentioned), but it goes the long way round of following pointers
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Would your command be dependant on which vCenter version I am trying to use it against? I have both 5.0 and 5.5
Ah! It worked. I must not have copied your cmd correctly.
So, It's odd that -Name vm is considered a hidden folder.. I guess I'm confused, but regardless..
Many thanks.!!
The hidden folder "vm" has been there since quite some time.
Btw, there a couple of other interesting folders like host,datastore and network.
I assume you can guess to which root they each point :smileygrin:
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
