VMware Cloud Community
ganapa2000
Hot Shot
Hot Shot
Jump to solution

Unable to Import Permissions to Datastore and Network

Hi, 

I am trying to import the permission from excel file which as the contents as below and I am unable to import and getting error.

The Principal are AD Groups and Users

Please help!!

Import-excel -Path $reportName -WorksheetName Permissions -PipelineVariable row |
Foreach-Object -process {
$sPerm = @{
Entity = Get-Inventory -Name $row.Entity
Role = Get-VIRole -name $row.Role
Principal = $row.Principal
Propagate = $row.Propagate
Confirm = $false
}
New-Vipermission @Sperm
}

Excel File

ganapa2000_1-1661407314870.png

 

Error

Get-Inventory : 8/25/2022 12:29:58 AM Get-Inventory Inventory with name '192.168.1.x_3010' was not found using the specified filter(s).
At D:\Import_Permissions.ps1:6 char:18
+ Entity = Get-Inventory -Name $row.Entity
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (:) [Get-Inventory], VimException
+ FullyQualifiedErrorId : Core_OutputHelper_WriteNotFoundError,VMware.VimAutomation.ViCore.Cmdlets.Commands.GetInventory

Foreach-Object : Cannot bind parameter 'Entity'. Cannot convert the "" value of type "System.Management.Automation.PSCustomObject" to type "VMware.VimAutomation.Sdk.Types.V1.VIObject".
At D:\Import_Permissions.ps1:4 char:1
+ Foreach-Object -process {
+ ~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [ForEach-Object], ParameterBindingException
+ FullyQualifiedErrorId : CannotConvertArgumentNoMessage,Microsoft.PowerShell.Commands.ForEachObjectCommand

 

Get-Inventory : 8/25/2022 12:23:23 AM Get-Inventory Inventory with name 'MyNim-DS01' was not found using the specified filter(s).
At D:\Import_Permissions.ps1:6 char:18
+ Entity = Get-Inventory -Name $row.Entity
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (:) [Get-Inventory], VimException
+ FullyQualifiedErrorId : Core_OutputHelper_WriteNotFoundError,VMware.VimAutomation.ViCore.Cmdlets.Commands.GetInventory

Foreach-Object : Cannot bind parameter 'Entity'. Cannot convert the "" value of type "System.Management.Automation.PSCustomObject" to type "VMware.VimAutomation.Sdk.Types.V1.VIObject".
At D:\Import_Permissions.ps1:4 char:1
+ Foreach-Object -process {
+ ~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [ForEach-Object], ParameterBindingException
+ FullyQualifiedErrorId : CannotConvertArgumentNoMessage,Microsoft.PowerShell.Commands.ForEachObjectCommand

Reply
0 Kudos
20 Replies
ganapa2000
Hot Shot
Hot Shot
Jump to solution

Perfect... that worked. Thank you very much LucD.

Reply
0 Kudos