Welcome,
Guest.
Please
Login
or
Register
.
News:
Home
Help
Search
Calendar
Register
Login
Vmware Scripting Forum
»
Scripts!
»
Powershell Scripts
»
Reporting Scripts
»
Custom Column names
Pages: [
1
]
« previous
next »
Print
Author
Topic: Custom Column names (Read 1137 times)
aflora
Newbie
Posts: 16
Custom Column names
«
on:
September 27, 2009, 06:28:23 PM »
Hi
I'm trying to customise the columns to closely resemble the permissions tab in the VIC but I'm having some trouble populating the Virtual Machine column.
Here's the code:
Variables
$report = @()
$inherited = $true
$htmlfile = "d:\Vm_perms.htm"
$authMgr = Get-View AuthorizationManager
$roles = @{}
foreach($role in $authMgr.RoleList){
$roleshttp://$role.RoleId = $role.Name
}
Get-View -Viewtype VirtualMachine | % {
$exist = Get-VIObjectByVIView -MORef $_.MoRef -ErrorAction SilentlyContinue
if($exist -ne $null){
$current = Get-View $_.Parent
$path = $_.Name
do {
$parent = $current
if($parent.Name -ne "vm"){$path = $parent.Name + "\" + $path}
$current = Get-View $current.Parent
} while ($current.Parent -ne $null)
$permissions = $authMgr.RetrieveEntityPermissions($_.MoRef, $inherited)
if($permissions.Length -ne 0){
foreach($perm in $permissions){
$report += $perm | Select @{Name = "Virtual Machine" ; Expression = {}},
@{Name = "User/Group" ; Expression = {$perm.Principal}} , @{Name = "Role" ; Expression = {$roleshttp://$perm.RoleId}} ,
@{Name = "Path" ; Expression = {$path}}
}
}
else{
$report += $perm | Select @{Name = "Virtual Machine" ; Expression = {$Path.name}},
@{Name = "User/Group" ; Expression = {$perm.Principal}} ,
@{Name = "Role" ; Expression = {$roleshttp://$perm.RoleId}}
}
}
}
$report | ConvertTo-HTML -head $a -body "<H2>Virtual Machine Permissions</H2>" | Out-File $htmlfile
What would be the variable for the VM name that goes in the brackets below?
@{Name = "Virtual Machine" ; Expression = {}}
I've tried a few things but can't get the VIrtual Machine column to populate with the VM names.
Thanks
Logged
esarakaitis
Administrator
Sr. Member
Posts: 256
Re: Custom Column names
«
Reply #1 on:
September 27, 2009, 07:49:20 PM »
try $parent.Name
Logged
aflora
Newbie
Posts: 16
Re: Custom Column names
«
Reply #2 on:
October 02, 2009, 01:52:38 PM »
This works {(Get-View -Id $perm.Entity).Name}}
Thanks anyway
Logged
Pages: [
1
]
Print
« previous
next »
Jump to:
Please select a destination:
-----------------------------
General Discussion
-----------------------------
=> Suggestion Area
-----------------------------
VMware Scripting!
-----------------------------
=> General Discussion
=> VMware Scripting Links
-----------------------------
Scripts!
-----------------------------
=> Powershell Scripts
===> Guest Scripts
===> Host Scripts
===> Networking Scripts
===> Reporting Scripts
===> Cluster Scripts
===> Datastore/Disk Scripts
=> Orchestrator Workflow's
=> .NET (C#/VB.NET)
=> RCLI
=> Bash Scripts
=> Perl Scripts
=> Vprobes
=> Python
-----------------------------
Scripting Language Resources
-----------------------------
=> Bash
=> PowerShell
=> Python
=> Perl
Loading...