From d9fdfff287ac8e6e9dbe8a2d3719e61e2da9b188 Mon Sep 17 00:00:00 2001 From: basvinken Date: Tue, 11 Sep 2018 18:55:21 +0200 Subject: [PATCH 01/10] Update PowervRA.psd1 Add Set-vRATenantDirectorySync.ps1 --- src/PowervRA.psd1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/PowervRA.psd1 b/src/PowervRA.psd1 index 5b85b4f1..fc34b6de 100644 --- a/src/PowervRA.psd1 +++ b/src/PowervRA.psd1 @@ -69,7 +69,7 @@ PowerShellVersion = '5.1' # NestedModules = @() # Functions to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no functions to export. -FunctionsToExport = @('Add-vRAPrincipalToTenantRole','Add-vRAReservationNetwork','Add-vRAReservationStorage','Connect-vRAServer','Disconnect-vRAServer','Export-vRAIcon','Export-vRAPackage','Get-vRAApplianceServiceStatus','Get-vRAAuthorizationRole','Get-vRABlueprint','Get-vRABusinessGroup','Get-vRACatalogItem','Get-vRACatalogItemRequestTemplate','Get-vRACatalogPrincipal','Get-vRAComponentRegistryService','Get-vRAComponentRegistryServiceEndpoint','Get-vRAComponentRegistryServiceStatus','Get-vRAContent','Get-vRAContentData','Get-vRAContentType','Get-vRAEntitledCatalogItem','Get-vRAEntitledService','Get-vRAEntitlement','Get-vRAExternalNetworkProfile','Get-vRAGroupPrincipal','Get-vRAIcon','Get-vRANATNetworkProfile','Get-vRANetworkProfileIPAddressList','Get-vRANetworkProfileIPRangeSummary','Get-vRAPackage','Get-vRAPackageContent','Get-vRAPropertyDefinition','Get-vRARequest','Get-vRARequestDetail','Get-vRAReservation','Get-vRAReservationComputeResource','Get-vRAReservationComputeResourceMemory','Get-vRAReservationComputeResourceNetwork','Get-vRAReservationComputeResourceResourcePool','Get-vRAReservationComputeResourceStorage','Get-vRAReservationPolicy','Get-vRAReservationTemplate','Get-vRAReservationType','Get-vRAResource','Get-vRAResourceAction','Get-vRAResourceActionRequestTemplate','Get-vRAResourceMetric','Get-vRAResourceOperation','Get-vRAResourceType','Get-vRARoutedNetworkProfile','Get-vRAService','Get-vRAServiceBlueprint','Get-vRASourceMachine','Get-vRAStorageReservationPolicy','Get-vRATenant','Get-vRATenantDirectory','Get-vRATenantDirectoryStatus','Get-vRATenantRole','Get-vRAUserPrincipal','Get-vRAUserPrincipalGroupMembership','Get-vRAVersion','Import-vRAIcon','Import-vRAPackage','Invoke-vRADataCollection','Invoke-vRARestMethod','New-vRABusinessGroup','New-vRAEntitlement','New-vRAExternalNetworkProfile','New-vRAGroupPrincipal','New-vRANATNetworkProfile','New-vRANetworkProfileIPRangeDefinition','New-vRAPackage','New-vRAPropertyDefinition','New-vRAReservation','New-vRAReservationNetworkDefinition','New-vRAReservationPolicy','New-vRAReservationStorageDefinition','New-vRARoutedNetworkProfile','New-vRAService','New-vRAStorageReservationPolicy','New-vRATenant','New-vRATenantDirectory','New-vRAUserPrincipal','Remove-vRABusinessGroup','Remove-vRAExternalNetworkProfile','Remove-vRAGroupPrincipal','Remove-vRAIcon','Remove-vRANATNetworkProfile','Remove-vRAPackage','Remove-vRAPrincipalFromTenantRole','Remove-vRAPropertyDefinition','Remove-vRAReservation','Remove-vRAReservationNetwork','Remove-vRAReservationPolicy','Remove-vRAReservationStorage','Remove-vRARoutedNetworkProfile','Remove-vRAService','Remove-vRAStorageReservationPolicy','Remove-vRATenant','Remove-vRATenantDirectory','Remove-vRAUserPrincipal','Request-vRACatalogItem','Request-vRAResourceAction','Set-vRABusinessGroup','Set-vRACatalogItem','Set-vRAEntitlement','Set-vRAExternalNetworkProfile','Set-vRANATNetworkProfile','Set-vRAReservation','Set-vRAReservationNetwork','Set-vRAReservationPolicy','Set-vRAReservationStorage','Set-vRARoutedNetworkProfile','Set-vRAService','Set-vRAStorageReservationPolicy','Set-vRATenant','Set-vRATenantDirectory','Set-vRAUserPrincipal','Test-vRAPackage') +FunctionsToExport = @('Add-vRAPrincipalToTenantRole','Add-vRAReservationNetwork','Add-vRAReservationStorage','Connect-vRAServer','Disconnect-vRAServer','Export-vRAIcon','Export-vRAPackage','Get-vRAApplianceServiceStatus','Get-vRAAuthorizationRole','Get-vRABlueprint','Get-vRABusinessGroup','Get-vRACatalogItem','Get-vRACatalogItemRequestTemplate','Get-vRACatalogPrincipal','Get-vRAComponentRegistryService','Get-vRAComponentRegistryServiceEndpoint','Get-vRAComponentRegistryServiceStatus','Get-vRAContent','Get-vRAContentData','Get-vRAContentType','Get-vRAEntitledCatalogItem','Get-vRAEntitledService','Get-vRAEntitlement','Get-vRAExternalNetworkProfile','Get-vRAGroupPrincipal','Get-vRAIcon','Get-vRANATNetworkProfile','Get-vRANetworkProfileIPAddressList','Get-vRANetworkProfileIPRangeSummary','Get-vRAPackage','Get-vRAPackageContent','Get-vRAPropertyDefinition','Get-vRARequest','Get-vRARequestDetail','Get-vRAReservation','Get-vRAReservationComputeResource','Get-vRAReservationComputeResourceMemory','Get-vRAReservationComputeResourceNetwork','Get-vRAReservationComputeResourceResourcePool','Get-vRAReservationComputeResourceStorage','Get-vRAReservationPolicy','Get-vRAReservationTemplate','Get-vRAReservationType','Get-vRAResource','Get-vRAResourceAction','Get-vRAResourceActionRequestTemplate','Get-vRAResourceMetric','Get-vRAResourceOperation','Get-vRAResourceType','Get-vRARoutedNetworkProfile','Get-vRAService','Get-vRAServiceBlueprint','Get-vRASourceMachine','Get-vRAStorageReservationPolicy','Get-vRATenant','Get-vRATenantDirectory','Get-vRATenantDirectoryStatus','Get-vRATenantRole','Get-vRAUserPrincipal','Get-vRAUserPrincipalGroupMembership','Get-vRAVersion','Import-vRAIcon','Import-vRAPackage','Invoke-vRADataCollection','Invoke-vRARestMethod','New-vRABusinessGroup','New-vRAEntitlement','New-vRAExternalNetworkProfile','New-vRAGroupPrincipal','New-vRANATNetworkProfile','New-vRANetworkProfileIPRangeDefinition','New-vRAPackage','New-vRAPropertyDefinition','New-vRAReservation','New-vRAReservationNetworkDefinition','New-vRAReservationPolicy','New-vRAReservationStorageDefinition','New-vRARoutedNetworkProfile','New-vRAService','New-vRAStorageReservationPolicy','New-vRATenant','New-vRATenantDirectory','New-vRAUserPrincipal','Remove-vRABusinessGroup','Remove-vRAExternalNetworkProfile','Remove-vRAGroupPrincipal','Remove-vRAIcon','Remove-vRANATNetworkProfile','Remove-vRAPackage','Remove-vRAPrincipalFromTenantRole','Remove-vRAPropertyDefinition','Remove-vRAReservation','Remove-vRAReservationNetwork','Remove-vRAReservationPolicy','Remove-vRAReservationStorage','Remove-vRARoutedNetworkProfile','Remove-vRAService','Remove-vRAStorageReservationPolicy','Remove-vRATenant','Remove-vRATenantDirectory','Remove-vRAUserPrincipal','Request-vRACatalogItem','Request-vRAResourceAction','Set-vRABusinessGroup','Set-vRACatalogItem','Set-vRAEntitlement','Set-vRAExternalNetworkProfile','Set-vRANATNetworkProfile','Set-vRAReservation','Set-vRAReservationNetwork','Set-vRAReservationPolicy','Set-vRAReservationStorage','Set-vRARoutedNetworkProfile','Set-vRAService','Set-vRAStorageReservationPolicy','Set-vRATenant','Set-vRATenantDirectory','Set-vRATenantDirectorySync','Set-vRAUserPrincipal','Test-vRAPackage') # Cmdlets to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no cmdlets to export. CmdletsToExport = @() From b814d0c9792f4742ecab7b3ba69a955f507e8d7c Mon Sep 17 00:00:00 2001 From: basvinken Date: Tue, 11 Sep 2018 18:58:31 +0200 Subject: [PATCH 02/10] Add files via upload --- .../identity/Set-vRATenantDirectorySync.ps1 | 60 +++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 src/Functions/Public/identity/Set-vRATenantDirectorySync.ps1 diff --git a/src/Functions/Public/identity/Set-vRATenantDirectorySync.ps1 b/src/Functions/Public/identity/Set-vRATenantDirectorySync.ps1 new file mode 100644 index 00000000..c95c5392 --- /dev/null +++ b/src/Functions/Public/identity/Set-vRATenantDirectorySync.ps1 @@ -0,0 +1,60 @@ +function Set-vRATenantDirectorySync { +<# + .SYNOPSIS + Sync an identity store + + .DESCRIPTION + Sync an identity store + + .PARAMETER Id + Specify the ID of a Tenant + + .PARAMETER Domain + Specify the Domain of a Tenant Directory + + .INPUTS + System.String + + .OUTPUTS + System.Management.Automation.PSObject. + + .EXAMPLE + Set-vRATenantDirectorySync -Id Tenant01 -Domain vrademo.local + + .EXAMPLE + Set-vRATenantDirectorySync -Id Tenant01 -Domain vrademo.local,test.local +#> +[CmdletBinding()][OutputType('System.Management.Automation.PSObject')] + + Param ( + + [parameter(Mandatory=$true)] + [ValidateNotNullOrEmpty()] + [String]$Id, + + [parameter(Mandatory=$false)] + [ValidateNotNullOrEmpty()] + [String[]]$Domain + ) + + # --- Test for vRA API version + xRequires -Version 7.0 + +try { + + foreach ($TenantDomain in $Domain){ + + $URI = "/identity/api/tenants/$($Id)/directories/$($TenantDomain)/sync " + + # --- Run vRA REST Request + Invoke-vRARestMethod -Method POST -URI $URI + + Get-vRATenantDirectoryStatus -Id $Id -Domain $Domain + + } +} +catch [Exception]{ + + throw +} +} \ No newline at end of file From 854aebe25c91aacbeaec08515e1ccf565f6bd68b Mon Sep 17 00:00:00 2001 From: basvinken Date: Tue, 11 Sep 2018 19:01:16 +0200 Subject: [PATCH 03/10] Update Set-vRAEntitlement.ps1 Add Allusers parameter --- .../catalog-service/Set-vRAEntitlement.ps1 | 22 ++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/src/Functions/Public/catalog-service/Set-vRAEntitlement.ps1 b/src/Functions/Public/catalog-service/Set-vRAEntitlement.ps1 index 094e2374..6a5bcdcb 100644 --- a/src/Functions/Public/catalog-service/Set-vRAEntitlement.ps1 +++ b/src/Functions/Public/catalog-service/Set-vRAEntitlement.ps1 @@ -1,4 +1,4 @@ -function Set-vRAEntitlement { +function Set-vRAEntitlement { <# .SYNOPSIS Update an existing entitlement @@ -46,6 +46,9 @@ .EXAMPLE Set-vRAEntitlement -Id "e5cd1c84-3b76-4ae9-9f2e-35114da6cfd2" -Name "Updated Name" -Description "Updated Description" -Principals "user@vsphere.local" -EntitledCatalogItems "Centos" -EntitledServices "A service" -EntitledResourceOperations "Infrastructure.Machine.Action.PowerOff" -Status ACTIVE + .EXAMPLE + Set-vRAEntitlement -Id "e5cd1c84-3b76-4ae9-9f2e-35114da6cfd2" -Name "Updated Name" -Description "Updated Description" -AllUsers:$true + .EXAMPLE Get-vRAEntitlement -Name "Entitlement 1" | Set-vRAEntitlement -Description "Updated description!" @@ -88,7 +91,11 @@ [Parameter(Mandatory=$false)] [ValidateNotNullOrEmpty()] - [bool]$LocalScopeForActions + [bool]$LocalScopeForActions, + + [Parameter(Mandatory=$false)] + [ValidateNotNullOrEmpty()] + [bool]$AllUsers ) @@ -246,6 +253,15 @@ $Entitlement.localScopeForActions = $LocalScopeForActions } + + # --- Update AllUsers + if ($PSBoundParameters.ContainsKey("AllUsers")) { + + Write-Verbose -Message "Updating AllUsers: $($Entitlement.AllUsers) >> $($AllUsers)" + $Entitlement.AllUsers = $AllUsers + + } + # --- Convert the modified entitlement to json $Body = $Entitlement | ConvertTo-Json -Depth 50 -Compress @@ -273,4 +289,4 @@ } -} \ No newline at end of file +} From ab79b4428a357e97af59c2523389f3b806c1f23d Mon Sep 17 00:00:00 2001 From: basvinken Date: Tue, 11 Sep 2018 19:02:37 +0200 Subject: [PATCH 04/10] Update Set-vRAEntitlement.ps1 --- src/Functions/Public/catalog-service/Set-vRAEntitlement.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Functions/Public/catalog-service/Set-vRAEntitlement.ps1 b/src/Functions/Public/catalog-service/Set-vRAEntitlement.ps1 index 6a5bcdcb..86edac22 100644 --- a/src/Functions/Public/catalog-service/Set-vRAEntitlement.ps1 +++ b/src/Functions/Public/catalog-service/Set-vRAEntitlement.ps1 @@ -254,7 +254,7 @@ function Set-vRAEntitlement { } - # --- Update AllUsers + # --- Update AllUsers if ($PSBoundParameters.ContainsKey("AllUsers")) { Write-Verbose -Message "Updating AllUsers: $($Entitlement.AllUsers) >> $($AllUsers)" From 2f599af1e17aeed19f8e4551136bba0d33118f44 Mon Sep 17 00:00:00 2001 From: Jonathan Medd Date: Tue, 8 Jan 2019 13:34:29 +0100 Subject: [PATCH 05/10] Update src/Functions/Public/catalog-service/Set-vRAEntitlement.ps1 Co-Authored-By: basvinken --- src/Functions/Public/catalog-service/Set-vRAEntitlement.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Functions/Public/catalog-service/Set-vRAEntitlement.ps1 b/src/Functions/Public/catalog-service/Set-vRAEntitlement.ps1 index 86edac22..75a871ff 100644 --- a/src/Functions/Public/catalog-service/Set-vRAEntitlement.ps1 +++ b/src/Functions/Public/catalog-service/Set-vRAEntitlement.ps1 @@ -93,7 +93,7 @@ function Set-vRAEntitlement { [ValidateNotNullOrEmpty()] [bool]$LocalScopeForActions, - [Parameter(Mandatory=$false)] + [Parameter(Mandatory=$false, ParameterSetName='AllUsers')] [ValidateNotNullOrEmpty()] [bool]$AllUsers From 3cc6068d93340e99d32bf4bd8c94b62fb8d2dc93 Mon Sep 17 00:00:00 2001 From: Jonathan Medd Date: Tue, 8 Jan 2019 13:34:41 +0100 Subject: [PATCH 06/10] Update src/Functions/Public/identity/Set-vRATenantDirectorySync.ps1 Co-Authored-By: basvinken --- src/Functions/Public/identity/Set-vRATenantDirectorySync.ps1 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Functions/Public/identity/Set-vRATenantDirectorySync.ps1 b/src/Functions/Public/identity/Set-vRATenantDirectorySync.ps1 index c95c5392..38728446 100644 --- a/src/Functions/Public/identity/Set-vRATenantDirectorySync.ps1 +++ b/src/Functions/Public/identity/Set-vRATenantDirectorySync.ps1 @@ -1,4 +1,4 @@ -function Set-vRATenantDirectorySync { +function Invoke-vRATenantDirectorySync { <# .SYNOPSIS Sync an identity store @@ -57,4 +57,4 @@ catch [Exception]{ throw } -} \ No newline at end of file +} From 28654761f05cf9ea6c11f9640ee25d039ce3fc00 Mon Sep 17 00:00:00 2001 From: Jonathan Medd Date: Tue, 8 Jan 2019 13:34:49 +0100 Subject: [PATCH 07/10] Update src/Functions/Public/identity/Set-vRATenantDirectorySync.ps1 Co-Authored-By: basvinken --- src/Functions/Public/identity/Set-vRATenantDirectorySync.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Functions/Public/identity/Set-vRATenantDirectorySync.ps1 b/src/Functions/Public/identity/Set-vRATenantDirectorySync.ps1 index 38728446..07d9a51a 100644 --- a/src/Functions/Public/identity/Set-vRATenantDirectorySync.ps1 +++ b/src/Functions/Public/identity/Set-vRATenantDirectorySync.ps1 @@ -38,7 +38,7 @@ function Invoke-vRATenantDirectorySync { ) # --- Test for vRA API version - xRequires -Version 7.0 + xRequires -Version 7.4 try { From 07b83b204812d95b7e9377b464fb96505c09b866 Mon Sep 17 00:00:00 2001 From: Jonathan Medd Date: Tue, 8 Jan 2019 13:35:01 +0100 Subject: [PATCH 08/10] Update src/Functions/Public/identity/Set-vRATenantDirectorySync.ps1 Co-Authored-By: basvinken --- .../Public/identity/Set-vRATenantDirectorySync.ps1 | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/Functions/Public/identity/Set-vRATenantDirectorySync.ps1 b/src/Functions/Public/identity/Set-vRATenantDirectorySync.ps1 index 07d9a51a..38e66f83 100644 --- a/src/Functions/Public/identity/Set-vRATenantDirectorySync.ps1 +++ b/src/Functions/Public/identity/Set-vRATenantDirectorySync.ps1 @@ -45,7 +45,13 @@ try { foreach ($TenantDomain in $Domain){ $URI = "/identity/api/tenants/$($Id)/directories/$($TenantDomain)/sync " + if ($PSCmdlet.ShouldProcess($Id)){ + # --- Run vRA REST Request + Invoke-vRARestMethod -Method POST -URI $URI + + Get-vRATenantDirectoryStatus -Id $Id -Domain $Domain + } # --- Run vRA REST Request Invoke-vRARestMethod -Method POST -URI $URI From 27d4475873396467b7adce1b9dd31ca04ee1377e Mon Sep 17 00:00:00 2001 From: Jonathan Medd Date: Tue, 8 Jan 2019 13:36:08 +0100 Subject: [PATCH 09/10] Update src/Functions/Public/identity/Set-vRATenantDirectorySync.ps1 Co-Authored-By: basvinken --- src/Functions/Public/identity/Set-vRATenantDirectorySync.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Functions/Public/identity/Set-vRATenantDirectorySync.ps1 b/src/Functions/Public/identity/Set-vRATenantDirectorySync.ps1 index 38e66f83..b4a671a2 100644 --- a/src/Functions/Public/identity/Set-vRATenantDirectorySync.ps1 +++ b/src/Functions/Public/identity/Set-vRATenantDirectorySync.ps1 @@ -24,7 +24,7 @@ function Invoke-vRATenantDirectorySync { .EXAMPLE Set-vRATenantDirectorySync -Id Tenant01 -Domain vrademo.local,test.local #> -[CmdletBinding()][OutputType('System.Management.Automation.PSObject')] +[CmdletBinding(SupportsShouldProcess,ConfirmImpact="High")][OutputType('System.Management.Automation.PSObject')] Param ( From 10b10ad249ac5e9cf202e28299a1a258552b01fd Mon Sep 17 00:00:00 2001 From: basvinken Date: Thu, 10 Jan 2019 09:48:17 +0100 Subject: [PATCH 10/10] Update and rename Set-vRATenantDirectorySync.ps1 to Invoke-vRATenantDirectorySync.ps1 --- ...antDirectorySync.ps1 => Invoke-vRATenantDirectorySync.ps1} | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) rename src/Functions/Public/identity/{Set-vRATenantDirectorySync.ps1 => Invoke-vRATenantDirectorySync.ps1} (89%) diff --git a/src/Functions/Public/identity/Set-vRATenantDirectorySync.ps1 b/src/Functions/Public/identity/Invoke-vRATenantDirectorySync.ps1 similarity index 89% rename from src/Functions/Public/identity/Set-vRATenantDirectorySync.ps1 rename to src/Functions/Public/identity/Invoke-vRATenantDirectorySync.ps1 index b4a671a2..b41100d0 100644 --- a/src/Functions/Public/identity/Set-vRATenantDirectorySync.ps1 +++ b/src/Functions/Public/identity/Invoke-vRATenantDirectorySync.ps1 @@ -19,10 +19,10 @@ function Invoke-vRATenantDirectorySync { System.Management.Automation.PSObject. .EXAMPLE - Set-vRATenantDirectorySync -Id Tenant01 -Domain vrademo.local + Invoke-vRATenantDirectorySync -Id Tenant01 -Domain vrademo.local .EXAMPLE - Set-vRATenantDirectorySync -Id Tenant01 -Domain vrademo.local,test.local + Invoke-vRATenantDirectorySync -Id Tenant01 -Domain vrademo.local,test.local #> [CmdletBinding(SupportsShouldProcess,ConfirmImpact="High")][OutputType('System.Management.Automation.PSObject')]