Does anyone have a script to apply a role to just Linux VM's in your environment or Windows VM's?
Thanks,
Pete
With a Where-clause you can filter out the Linux VMs from a Get-VM.
Then it is just a matter of using the New-VIPermssion cmdlet on those VMs.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
In case you need a little help:
$linuxvms = Get-VM | where{$_.ExtensionData.Config.GuestFullname -match "Red Hat Enterprise Linux"}
Foreach ($linuxvm in $linuxvms)
{
New-VIPermission -role "Role Name" -principal "AD Group Name" -Entity $linuxvm
}
With a Where-clause you can filter out the Linux VMs from a Get-VM.
Then it is just a matter of using the New-VIPermssion cmdlet on those VMs.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Luc,
This is what I have.
$linuxvms = Get-VM | where{$_.ExtensionData.Config.GuestFullname -match "Red Hat Enterprise Linux"}
New-VIPermission -role "Role Name" -principal "AD Group Name" -Entity $linuxvms
Got this error.
New-VIPermission : Cannot process argument transformation on parameter 'Entity'. This parameter no longer accepts an array. As an alternative you may pass multiple values by pipeline (if supported by the
parameter).
That indicates that more than 1 VM is returned (passed the Where-clause).
You can pipe the result to a Foreach loop, and handle the VMs one-by-one inside that loop.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
In case you need a little help:
$linuxvms = Get-VM | where{$_.ExtensionData.Config.GuestFullname -match "Red Hat Enterprise Linux"}
Foreach ($linuxvm in $linuxvms)
{
New-VIPermission -role "Role Name" -principal "AD Group Name" -Entity $linuxvm
}