Functions/Copy-IAView.ps1
Function Copy-IAView{ Param( [Switch]$IncludeAll, [Parameter(Mandatory = $true, ParameterSetName = 'Interactive')] [Switch]$Interactive, [Switch]$PassThru, [Parameter(Mandatory = $true)] [String]$NewName, [Parameter(Mandatory = $true, ParameterSetName = 'NotInteractive')] $IAView, [Parameter(Mandatory = $true, ParameterSetName = 'NotInteractive')] $IACategory ) if($Interactive){ $IAView = Get-IAView -All | Out-GridView -PassThru $IACategory = Get-IACategory -All | Out-GridView -PassThru } $IAViewObject = $IAView | Select-Object -Property Name, Description, Order, ShowTopWidgetBar, ShowHeader, TenantId $IAViewObject | Add-Member -MemberType NoteProperty -Name 'CategoryId' -Value $IACategory.Id if($NewName){ $IAViewObject.Name = $NewName } $newIAView = New-IAView -IAView $IAViewObject -PassThru if($IncludeAll){ $IAGroups = Get-IAView -Id $IAView.Id -Expand | Select-Object -ExpandProperty Groups foreach($item in $IAGroups){ Copy-IAGroup -IAGroup $item -IAView $newIAView -IncludeAll } } if($PassThru){ return $newIAView } } |