Hi all,
I´m not a scripter so I need your help for my environemnt - 1 vcenter 5 datacenters without templates.
I need an export in csv contains the BlueFolderPath, I found a lot of scripts using Get-Folder and Get-FolderPath (is not recognized as the name of a cmdlet) something like that but nothing is working.
example CSV:
A | B |
---|---|
testvm1 | DATACENTER\Applications\Banking\external |
testvm2 | DATACENTER\Applications\Banking |
testvm3 | DATACENTER\ |
testvm4 | DATACENTER\Applications |
I found a lot of scripts from LucD but I think I´m to stuipd to get it to fly.
Get the folderpath - LucD notes
I hope someone can help me
Thanks a lot
Greetings
Sorry, I'm must have had a black out.
The Get-FolderPath only works for Folder objects, not VM.
But you can use the function from my Get-InventoryPlus – Inventory Of All VSphere Objects post.
I attach a script that will list all the VMs, with their blue and yellow folder path.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
What errors are you getting?
Can you attach the script your are using, and preferably a screenshot of the run.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
do you have the snappin/module loaded? You should see VMware.VimAutomation.Core returned under either a get-pssnapin or get-module
Oh damn, I´m such a script newby... I don´t read line 1 - -pssnapin VMware.VimAutomation.Core -version 4.1
I want to use this script: Get the folderpath - LucD notes I think it´s the right one for me.
How can I use version 4.1 when I have installed pCLI 6.5?
Get-PowerCLIVersion
PowerCLI Version
----------------
VMware PowerCLI 6.5 Release 1 build 4624819
---------------
Component Versions
---------------
VMware Cis Core PowerCLI Component 6.5 build 4624453
VMware VimAutomation Core PowerCLI Component 6.5 build 4624450
VMWare ImageBuilder PowerCLI Component 6.5 build 4561891
VMWare AutoDeploy PowerCLI Component 6.5 build 4561891
VMware Vds PowerCLI Component 6.5 build 4624695
VMware Cloud PowerCLI Component 6.5 build 4624821
VMware HA PowerCLI Component 6.0 build 4525225
VMware HorizonView PowerCLI Component 7.0.2 build 4596620
VMware Licensing PowerCLI Component 6.5 build 4624822
VMware PCloud PowerCLI Component 6.5 build 4624825
VMware Storage PowerCLI Component 6.5 build 4624820
VMware vROps PowerCLI Component 6.5 build 4624824
VMware vSphere Update Manager PowerCLI 6.5 build 4540462
You don't need 4.1, just remove that #requires line.
It will work with 6.5R1 as well
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Good morning,
I deleted the comments from the script. Now I get no error but the script is doing nothing. Should I put a Name of a folder in HelpMessage = "Enter a folder")] ? Is it possible to dump it into a file?
Must I use pCLI 6.0 when I use VMware 6.0U2 or should it also work with pCLI 6.5?
When I use Get-Folder | Get-FolderPath I get an error - see attached picture.
Thanks a lot for your help :smileygrin:
I assume you have placed the function in that .ps1 file.
In that case you need to dot-source it, like this
. .\FolderPath.ps1
There is a blank between the two dots.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Yes the script is on my desktop in the "FolderPath.ps1".
Empty screen also with ". .\FolderPath.ps1"
The empty screen is normal.
But is the function known, can you call it?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Where is the output of the VMs/folder names?
Now I'm confused, you execute 'Get-Command -Name Get-FolderPath' twice.
One time it returns ok, the second call the function is not found anymore.
Did you stop the PowerShell session in between?
Did you dot-source the .ps1 file?
The output of the function is displayed on the console
.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Now, I´m confused - must I need Windows PowerShell oder VMware Power CLI?
Both!
PowerCLI is an add-on on top of PowerShell.
When you start the session from the PowerCLI shortcut, the PowerCLI initialisation script starts PowerShell and loads the required PSSnapin and/or modules (PSSnapin or modules depends on the PowerCLI version you have installed).
From the PowerCLI prompt you can see that you are running PowerShell with PowerCLI loaded (6.5R1 in my case, which means only modules)..
Once in the session, you can "load" functions that you have stored in .ps1 files, by dot-sourcing them.
Once these functions are known to PowerShell, you can invoke them (see me previous answer).
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Get-Module show nothing:
I don´t understand something...where is the output from the script?
Oh my goooooooood.
Now I understand your script - I can load it and use Get-FolderPath :smileyblush:
So how can I create a dump to csv from the whole vcenter with this structure sorted by DC?
A | B |
---|---|
testvm1 | DATACENTER\Applications\Banking\external |
testvm2 | DATACENTER\Applications\Banking |
testvm3 | DATACENTER\ |
testvm4 | DATACENTER\Applications |
Something like that: Get-VM | Get-FolderPath?
Just pipe the result to the Export-Csv cmdlet.
Get-VM | Get-FolderPath | Export-Csv report.csv -NoTypeInformation -UseCulture
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
I got this error by using Get-VM in combination with Get-FolderPath - both commands are working alone:
Sorry, I'm must have had a black out.
The Get-FolderPath only works for Folder objects, not VM.
But you can use the function from my Get-InventoryPlus – Inventory Of All VSphere Objects post.
I attach a script that will list all the VMs, with their blue and yellow folder path.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Hi LucD,
wow great script and that is what I need.
Is it possible to show only type = VirtualMachine that the script is running faster and the csv is not so big?
Get-InventoryPlus | ? Type -eq VirtualMachine | Export-Csv -Path C:\temp\VMsrport.csv -NoTypeInformation -UseCulture
I don´t know if i use the -eq right but my csv is empty.
That should be ok.
Are you connected to a vCenter?
Is there anything in $global:defaultviservers
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference