Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set-vRATenantDirectorySync #187

Merged
merged 10 commits into from
Jan 10, 2019
22 changes: 19 additions & 3 deletions src/Functions/Public/catalog-service/Set-vRAEntitlement.ps1
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
function Set-vRAEntitlement {
function Set-vRAEntitlement {
<#
.SYNOPSIS
Update an existing entitlement
Expand Down Expand Up @@ -46,6 +46,9 @@
.EXAMPLE
Set-vRAEntitlement -Id "e5cd1c84-3b76-4ae9-9f2e-35114da6cfd2" -Name "Updated Name" -Description "Updated Description" -Principals "[email protected]" -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!"

Expand Down Expand Up @@ -88,7 +91,11 @@

[Parameter(Mandatory=$false)]
[ValidateNotNullOrEmpty()]
[bool]$LocalScopeForActions
[bool]$LocalScopeForActions,

[Parameter(Mandatory=$false, ParameterSetName='AllUsers')]
[ValidateNotNullOrEmpty()]
[bool]$AllUsers

)

Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -273,4 +289,4 @@

}

}
}
66 changes: 66 additions & 0 deletions src/Functions/Public/identity/Invoke-vRATenantDirectorySync.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
function Invoke-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
Invoke-vRATenantDirectorySync -Id Tenant01 -Domain vrademo.local

.EXAMPLE
Invoke-vRATenantDirectorySync -Id Tenant01 -Domain vrademo.local,test.local
#>
[CmdletBinding(SupportsShouldProcess,ConfirmImpact="High")][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.4

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

Get-vRATenantDirectoryStatus -Id $Id -Domain $Domain

}
}
catch [Exception]{

throw
}
}
2 changes: 1 addition & 1 deletion src/PowervRA.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -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 = @()
Expand Down