Automation

 View Only
  • 1.  All blue folders do not show in report

    Posted Nov 10, 2009 06:09 PM
      |   view attached

    Hi

    For some reason or another when I run a report against one of my datacenters 2 blue folders do not show up in the report that are listed under this datacenter.

    I'm attaching the code becasue this forum doesn't like brackets.

    Thanks

    Attachment(s)

    ps1
    Perms.ps1   1 KB 1 version


  • 2.  RE: All blue folders do not show in report

    Posted Nov 10, 2009 09:10 PM
      |   view attached

    Your attached script starts from the permissions.

    If a folder is not listed that could mean that there are no explicit permissions on that folder.

    Is that perhaps the case for the two missing folders ?

    You could go for a script that lists all the folders and then shows the permissions (implicit and/or inherited) for that folder.

    Something like the attached script.

    With the $inherited variable you can define if inherited permissions should be reported or not.

    Note that the script will not list permissions that are assigned on other entities (like for example guests).

    Attachment(s)

    ps1
    Folder-Permissions.ps1   1 KB 1 version


  • 3.  RE: All blue folders do not show in report

    Posted Nov 12, 2009 08:52 PM

    The permissions are inherited. They ae defined in the Vcenter server. Is there a way to modify this script to report on only one datacenter?

    Thanks



  • 4.  RE: All blue folders do not show in report

    Posted Nov 12, 2009 10:20 PM

    Try replacing this line (at the end of my script)

    Get-Folder -Name "Datacenters" | Get-View | %{Get-Children $_ "" $inherited}
    

    by this line

    Get-Datacenter -Name "MyDatacenter" | Get-View | %{Get-View $_.VmFolder} | %{Get-Children $_ "MyDatacenter" $inherited}
    

    You have to replace "MyDatacenter" with your datacentername twice.



  • 5.  RE: All blue folders do not show in report

    Posted Nov 16, 2009 05:25 PM

    Luc

    The permissions are propigated down from an ESX server. Could we add a Defined In column?

    Thanks



  • 6.  RE: All blue folders do not show in report
    Best Answer

    Posted Nov 16, 2009 06:08 PM
      |   view attached

    Yes, that's possible. Try the attached script.

    Attachment(s)

    ps1
    Folder-Permissions2.ps1   1 KB 1 version


  • 7.  RE: All blue folders do not show in report

    Posted Nov 16, 2009 07:12 PM

    Works great!

    I have 2 questions:

    1. How come in the report it says Defined In "datacenter" instead of the actual server name?

    2. How come when I use $Report instead of $global:report I get a bank csv file?



  • 8.  RE: All blue folders do not show in report

    Posted Nov 16, 2009 09:58 PM

    1) Because internally the permissions defined at the top are assigned to the "hidden" folder called Datacenters and not to an individual ESX server in that datacenter. If you define a permission on an ESX server it will show the server.

    2) That is due to the scope of PS variables. In the script I needed a variable that was visible inside the function and also in the outer level.

    By adding the $global: prefix you make a variable visible in all the scope levels.

    See Tobias's explanation (which is much better than mine) in Scope of Variables



  • 9.  RE: All blue folders do not show in report

    Posted Nov 17, 2009 01:25 AM

    Thanks Luc... You're the best!