diff --git a/d365bap.tools/d365bap.tools.psd1 b/d365bap.tools/d365bap.tools.psd1
index ae9f86b..44d1d08 100644
--- a/d365bap.tools/d365bap.tools.psd1
+++ b/d365bap.tools/d365bap.tools.psd1
@@ -44,6 +44,7 @@
FunctionsToExport = @(
'Compare-BapEnvironmentD365App'
, 'Compare-BapEnvironmentUser'
+ , 'Compare-BapEnvironmentVirtualEntity'
, 'Confirm-BapEnvironmentIntegration'
@@ -57,6 +58,10 @@
, 'Get-BapEnvironmentVirtualEntity'
, 'Invoke-BapEnvironmentInstallD365App'
+
+ , 'Set-BapEnvironmentVirtualEntity'
+
+ , 'Update-BapEnvironmentVirtualEntityMetadata'
)
# Cmdlets to export from this module
diff --git a/d365bap.tools/functions/Compare-BapEnvironmentD365App.ps1 b/d365bap.tools/functions/Compare-BapEnvironmentD365App.ps1
index e0e88ac..3dc334d 100644
--- a/d365bap.tools/functions/Compare-BapEnvironmentD365App.ps1
+++ b/d365bap.tools/functions/Compare-BapEnvironmentD365App.ps1
@@ -4,7 +4,7 @@
Compare environment D365 Apps
.DESCRIPTION
- This enables the user to compare 2 x environments, with one as a source and the other as a destination
+ Enables the user to compare 2 x environments, with one as a source and the other as a destination
It will only look for installed D365 Apps on the source, and use this as a baseline against the destination
diff --git a/d365bap.tools/functions/Compare-BapEnvironmentUser.ps1 b/d365bap.tools/functions/Compare-BapEnvironmentUser.ps1
index cbe08e0..55c0a52 100644
--- a/d365bap.tools/functions/Compare-BapEnvironmentUser.ps1
+++ b/d365bap.tools/functions/Compare-BapEnvironmentUser.ps1
@@ -4,7 +4,7 @@
Compare the environment users
.DESCRIPTION
- This enables the user to compare 2 x environments, with one as a source and the other as a destination
+ Enables the user to compare 2 x environments, with one as a source and the other as a destination
It will only look for users on the source, and use this as a baseline against the destination
diff --git a/d365bap.tools/functions/Compare-BapEnvironmentVirtualEntity.ps1 b/d365bap.tools/functions/Compare-BapEnvironmentVirtualEntity.ps1
new file mode 100644
index 0000000..ba023cd
--- /dev/null
+++ b/d365bap.tools/functions/Compare-BapEnvironmentVirtualEntity.ps1
@@ -0,0 +1,147 @@
+
+<#
+ .SYNOPSIS
+ Compare environment Virtual Entities
+
+ .DESCRIPTION
+ Enables the user to compare 2 x environments, with one as a source and the other as a destination
+
+ It will only look for enabled / visible Virtual Entities on the source, and use this as a baseline against the destination
+
+ .PARAMETER SourceEnvironmentId
+ Environment Id of the source environment that you want to utilized as the baseline for the compare
+
+ .PARAMETER DestinationEnvironmentId
+ Environment Id of the destination environment that you want to validate against the baseline (source)
+
+ .PARAMETER ShowDiffOnly
+ Instruct the cmdlet to only output the differences that are not aligned between the source and destination
+
+ .PARAMETER AsExcelOutput
+ Instruct the cmdlet to output all details directly to an Excel file
+
+ This makes it easier to deep dive into all the details returned from the API, and makes it possible for the user to persist the current state
+
+ .EXAMPLE
+ PS C:\> Compare-BapEnvironmentVirtualEntity -SourceEnvironmentId eec2c11a-a4c7-4e1d-b8ed-f62acc9c74c6 -DestinationEnvironmentId 32c6b196-ef52-4c43-93cf-6ecba51e6aa1
+
+ This will get all enabled / visible Virtual Entities from the Source Environment.
+ It will iterate over all of them, and validate against the Destination Environment.
+
+ Sample output:
+ EntityName SourceIsVisible SourceChangeTrackingEnabled Destination DestinationChange
+ IsVisible TrackingEnabled
+ ---------- --------------- --------------------------- ----------- -----------------
+ AccountantEntity True False True False
+ CurrencyEntity True False False False
+ WMHEOutboundQueueEntity True False False False
+
+ .EXAMPLE
+ PS C:\> Compare-BapEnvironmentVirtualEntity -SourceEnvironmentId eec2c11a-a4c7-4e1d-b8ed-f62acc9c74c6 -DestinationEnvironmentId 32c6b196-ef52-4c43-93cf-6ecba51e6aa1 -ShowDiffOnly
+
+ This will get all enabled / visible Virtual Entities from the Source Environment.
+ It will iterate over all of them, and validate against the Destination Environment.
+ It will filter out results, to only include those where the Source is different from the Destination.
+
+ Sample output:
+ EntityName SourceIsVisible SourceChangeTrackingEnabled Destination DestinationChange
+ IsVisible TrackingEnabled
+ ---------- --------------- --------------------------- ----------- -----------------
+ CurrencyEntity True False False False
+ WMHEOutboundQueueEntity True False False False
+
+ .EXAMPLE
+ PS C:\> Compare-BapEnvironmentVirtualEntity -SourceEnvironmentId eec2c11a-a4c7-4e1d-b8ed-f62acc9c74c6 -DestinationEnvironmentId 32c6b196-ef52-4c43-93cf-6ecba51e6aa1
+
+ This will get all enabled / visible Virtual Entities from the Source Environment.
+ It will iterate over all of them, and validate against the Destination Environment.
+ Will output all details into an Excel file, that will auto open on your machine.
+
+ .NOTES
+ Author: Mötz Jensen (@Splaxi)
+#>
+function Compare-BapEnvironmentVirtualEntity {
+ [CmdletBinding()]
+ param (
+ [parameter (mandatory = $true)]
+ [string] $SourceEnvironmentId,
+
+ [parameter (mandatory = $true)]
+ [string] $DestinationEnvironmentId,
+
+ [switch] $ShowDiffOnly,
+
+ [switch] $AsExcelOutput
+ )
+
+ begin {
+ # Make sure all *BapEnvironment* cmdlets will validate that the environment exists prior running anything.
+ $envSourceObj = Get-BapEnvironment -EnvironmentId $SourceEnvironmentId | Select-Object -First 1
+
+ if ($null -eq $envSourceObj) {
+ $messageString = "The supplied SourceEnvironmentId: $SourceEnvironmentId didn't return any matching environment details. Please verify that the SourceEnvironmentId is correct - try running the Get-BapEnvironment cmdlet."
+ Write-PSFMessage -Level Host -Message $messageString
+ Stop-PSFFunction -Message "Stopping because environment was NOT found based on the id." -Exception $([System.Exception]::new($($messageString -replace '<[^>]+>', '')))
+ }
+
+ # Make sure all *BapEnvironment* cmdlets will validate that the environment exists prior running anything.
+ $envDestinationObj = Get-BapEnvironment -EnvironmentId $DestinationEnvironmentId | Select-Object -First 1
+
+ if ($null -eq $envDestinationObj) {
+ $messageString = "The supplied DestinationEnvironmentId: $DestinationEnvironmentId didn't return any matching environment details. Please verify that the DestinationEnvironmentId is correct - try running the Get-BapEnvironment cmdlet."
+ Write-PSFMessage -Level Host -Message $messageString
+ Stop-PSFFunction -Message "Stopping because environment was NOT found based on the id." -Exception $([System.Exception]::new($($messageString -replace '<[^>]+>', '')))
+ }
+
+ if (Test-PSFFunctionInterrupt) { return }
+
+ $entitiesSourceEnvironment = @(Get-BapEnvironmentVirtualEntity -EnvironmentId $SourceEnvironmentId -VisibleOnly)
+ $entitiesDestinationEnvironment = @(
+ foreach ($entName in $entitiesSourceEnvironment.EntityName) {
+ Get-BapEnvironmentVirtualEntity -EnvironmentId $DestinationEnvironmentId -Name $entName
+ }
+ )
+ }
+
+ process {
+ if (Test-PSFFunctionInterrupt) { return }
+
+ $resCol = @(foreach ($sourceEntity in $($entitiesSourceEnvironment | Sort-Object -Property EntityName )) {
+ $destinationEntity = $entitiesDestinationEnvironment | Where-Object EntityName -eq $sourceEntity.EntityName | Select-Object -First 1
+
+ $tmp = [Ordered]@{
+ EntityName = $sourceEntity.EntityName
+ SourceIsVisible = $sourceEntity.IsVisible
+ SourceChangeTrackingEnabled = $sourceEntity.ChangeTrackingEnabled
+ SourceEntityGuid = $sourceEntity.EntityGuid
+ DestinationIsVisible = ""
+ DestinationChangeTrackingEnabled = ""
+ DestinationEntityGuid = ""
+ }
+
+ if (-not ($null -eq $destinationEntity)) {
+ $tmp.DestinationIsVisible = $destinationEntity.IsVisible
+ $tmp.DestinationChangeTrackingEnabled = $destinationEntity.ChangeTrackingEnabled
+ $tmp.DestinationEntityGuid = $destinationEntity.EntityGuid
+ }
+
+ ([PSCustomObject]$tmp) | Select-PSFObject -TypeName "D365Bap.Tools.Compare.VirtualEntity"
+ }
+ )
+
+ if ($ShowDiffOnly) {
+ $resCol = $resCol | Where-Object { ($_.SourceIsVisible -ne $_.DestinationIsVisible) -or ($_.SourceChangeTrackingEnabled -ne $_.DestinationChangeTrackingEnabled) }
+ }
+
+ if ($AsExcelOutput) {
+ $resCol | Export-Excel -NoNumberConversion SourceVersion, DestinationVersion
+ return
+ }
+
+ $resCol
+ }
+
+ end {
+
+ }
+}
\ No newline at end of file
diff --git a/d365bap.tools/functions/Confirm-BapEnvironmentIntegration.ps1 b/d365bap.tools/functions/Confirm-BapEnvironmentIntegration.ps1
index bed50e0..27f7b48 100644
--- a/d365bap.tools/functions/Confirm-BapEnvironmentIntegration.ps1
+++ b/d365bap.tools/functions/Confirm-BapEnvironmentIntegration.ps1
@@ -68,6 +68,8 @@ function Confirm-BapEnvironmentIntegration {
}
process {
+ if (Test-PSFFunctionInterrupt) { return }
+
$resValidate = Invoke-RestMethod -Method Get -Uri $($baseUri + '/api/data/v9.2/RetrieveFinanceAndOperationsIntegrationDetails') -Headers $headersWebApi
$temp = $resValidate | Select-PSFObject -TypeName "D365Bap.Tools.Environment.Integration" -ExcludeProperty "@odata.context" -Property "Id as LinkedAppLcsEnvId",
diff --git a/d365bap.tools/functions/Get-BapEnvironment.ps1 b/d365bap.tools/functions/Get-BapEnvironment.ps1
index 0a2edb6..4ddaece 100644
--- a/d365bap.tools/functions/Get-BapEnvironment.ps1
+++ b/d365bap.tools/functions/Get-BapEnvironment.ps1
@@ -4,7 +4,7 @@
Get environment info
.DESCRIPTION
- This enables the user to query and validate all environments that are available from inside PPAC
+ Enables the user to query and validate all environments that are available from inside PPAC
It utilizes the "https://api.bap.microsoft.com" REST API
@@ -67,7 +67,6 @@ function Get-BapEnvironment {
}
process {
-
$resCol = @(
foreach ($envObj in $resEnvs) {
if (-not ($envObj.Name -like $EnvironmentId)) { continue }
@@ -104,6 +103,7 @@ function Get-BapEnvironment {
@{Name = "LinkedMetaPpacOrgId"; Expression = { $envObj.Properties.linkedEnvironmentMetadata.resourceId } },
@{Name = "LinkedMetaPpacUniqueId"; Expression = { $envObj.Properties.linkedEnvironmentMetadata.uniqueName } },
@{Name = "LinkedMetaPpacEnvUri"; Expression = { $envObj.Properties.linkedEnvironmentMetadata.instanceUrl -replace "com/", "com" } },
+ @{Name = "LinkedMetaPpacEnvApiUri"; Expression = { $envObj.Properties.linkedEnvironmentMetadata.instanceApiUrl -replace "com/", "com" } },
@{Name = "LinkedMetaPpacEnvLanguage"; Expression = { $envObj.Properties.linkedEnvironmentMetadata.baseLanguage } },
@{Name = "PpacClusterIsland"; Expression = { $envObj.Properties.cluster.uriSuffix } },
"*"
diff --git a/d365bap.tools/functions/Get-BapEnvironmentApplicationUser.ps1 b/d365bap.tools/functions/Get-BapEnvironmentApplicationUser.ps1
index 04740a2..d33f047 100644
--- a/d365bap.tools/functions/Get-BapEnvironmentApplicationUser.ps1
+++ b/d365bap.tools/functions/Get-BapEnvironmentApplicationUser.ps1
@@ -71,6 +71,8 @@ function Get-BapEnvironmentApplicationUser {
}
process {
+ if (Test-PSFFunctionInterrupt) { return }
+
$resAppUsers = Invoke-RestMethod -Method Get -Uri $($baseUri + '/api/data/v9.2/applicationusers') -Headers $headersWebApi
$resCol = @(
foreach ($appUsrObj in $($resAppUsers.value | Sort-Object -Property applicationname)) {
diff --git a/d365bap.tools/functions/Get-BapEnvironmentD365App.ps1 b/d365bap.tools/functions/Get-BapEnvironmentD365App.ps1
index 26bb77f..b7e26ad 100644
--- a/d365bap.tools/functions/Get-BapEnvironmentD365App.ps1
+++ b/d365bap.tools/functions/Get-BapEnvironmentD365App.ps1
@@ -4,7 +4,7 @@
Get D365 App from the environment
.DESCRIPTION
- This enables the user to analyze and validate the current D365 Apps and their state, on a given environment
+ Enables the user to analyze and validate the current D365 Apps and their state, on a given environment
It can show all available D365 Apps - including their InstallState
diff --git a/d365bap.tools/functions/Get-BapEnvironmentUser.ps1 b/d365bap.tools/functions/Get-BapEnvironmentUser.ps1
index 7a06e59..2e5e40b 100644
--- a/d365bap.tools/functions/Get-BapEnvironmentUser.ps1
+++ b/d365bap.tools/functions/Get-BapEnvironmentUser.ps1
@@ -94,6 +94,8 @@ function Get-BapEnvironmentUser {
}
process {
+ if (Test-PSFFunctionInterrupt) { return }
+
$resUsers = Invoke-RestMethod -Method Get -Uri $($baseUri + '/api/data/v9.2/systemusers?$select=fullname,internalemailaddress,applicationid&$expand=user_settings($select=uilanguageid)') -Headers $headersWebApi
$resCol = @(
diff --git a/d365bap.tools/functions/Get-BapEnvironmentVirtualEntity.ps1 b/d365bap.tools/functions/Get-BapEnvironmentVirtualEntity.ps1
index 29f0107..da1486b 100644
--- a/d365bap.tools/functions/Get-BapEnvironmentVirtualEntity.ps1
+++ b/d365bap.tools/functions/Get-BapEnvironmentVirtualEntity.ps1
@@ -1,12 +1,12 @@
<#
.SYNOPSIS
- Get Virutal Entity
+ Get Virtual Entity from environment
.DESCRIPTION
Enables the user to query against the Virtual Entities from the D365FO environment
- This will help determine which Virtual Entities are already enabled / visible and their state
+ This will help determine which Virtual Entities are already enabled / visible and their state, as they are seeing from the Dataverse environment
.PARAMETER EnvironmentId
The id of the environment that you want to work against
@@ -80,6 +80,16 @@
DimAttributeRetailTerminalEnt… False False 00002893-0000-0000-6e07-005001000000
EcoResRetailProductEntity False False 00002893-0000-0000-ae06-005001000000
+ .EXAMPLE
+ PS C:\> Get-BapEnvironmentVirtualEntity -EnvironmentId eec2c11a-a4c7-4e1d-b8ed-f62acc9c74c6 -Name AccountantEntity
+
+ This will fetch the specific virtual entity from the environment.
+
+ Sample output:
+ EntityName IsVisible ChangeTrackingEnabled EntityGuid
+ ---------- --------- --------------------- ----------
+ AccountantEntity False False 00002893-0000-0000-0003-005001000000
+
.NOTES
Author: Mötz Jensen (@Splaxi)
#>
@@ -124,6 +134,8 @@ function Get-BapEnvironmentVirtualEntity {
}
process {
+ if (Test-PSFFunctionInterrupt) { return }
+
$localUri = $($baseUri + '/api/data/v9.2/mserp_financeandoperationsentities')
[System.Collections.Generic.List[System.String]]$filters = @()
diff --git a/d365bap.tools/functions/Invoke-BapEnvironmentInstallD365App.ps1 b/d365bap.tools/functions/Invoke-BapEnvironmentInstallD365App.ps1
index 159051f..3e63a57 100644
--- a/d365bap.tools/functions/Invoke-BapEnvironmentInstallD365App.ps1
+++ b/d365bap.tools/functions/Invoke-BapEnvironmentInstallD365App.ps1
@@ -4,7 +4,7 @@
Invoke the installation of a D365 App in a given environment
.DESCRIPTION
- This enables the invocation of the installation process against the PowerPlatform API (https://api.powerplatform.com)
+ Enables the invocation of the installation process against the PowerPlatform API (https://api.powerplatform.com)
The cmdlet will keep requesting the status of all invoked installations, until they all have a NON "Running" state
diff --git a/d365bap.tools/functions/Set-BapEnvironmentVirtualEntity.ps1 b/d365bap.tools/functions/Set-BapEnvironmentVirtualEntity.ps1
new file mode 100644
index 0000000..c718105
--- /dev/null
+++ b/d365bap.tools/functions/Set-BapEnvironmentVirtualEntity.ps1
@@ -0,0 +1,220 @@
+
+<#
+ .SYNOPSIS
+ Set Virtual Entity configuration in environment
+
+ .DESCRIPTION
+ Enables the user to update the configuration for any given Virtual Entity in the environment
+
+ The configuration is done against the Dataverse environment, and allows the user to update the Visibility or TrackingChanges, for a given Virtual Entity
+
+ .PARAMETER EnvironmentId
+ The id of the environment that you want to work against
+
+ .PARAMETER Name
+ The name of the virtual entity that you are looking for
+
+ .PARAMETER VisibilityOn
+ Instructs the cmdlet to turn "ON" the Virtual Entity
+
+ Can be used in combination with TrackingOn / TrackingOff
+
+ .PARAMETER VisibilityOff
+ Instructs the cmdlet to turn "OFF" the Virtual Entity
+
+ Can be used in combination with TrackingOn / TrackingOff
+
+ .PARAMETER TrackingOn
+ Instructs the cmdlet to enable ChangeTracking on the Virtual Entity
+
+ Can be used in combination with VisibilityOn / VisibilityOff
+
+ .PARAMETER TrackingOff
+ Instructs the cmdlet to disable ChangeTracking on the Virtual Entity
+
+ Can be used in combination with VisibilityOn / VisibilityOff
+
+ .EXAMPLE
+ PS C:\> Set-BapEnvironmentVirtualEntity -EnvironmentId eec2c11a-a4c7-4e1d-b8ed-f62acc9c74c6 -Name AccountantEntity -VisibilityOn -TrackingOff
+
+ This will enable the Virtual Entity "AccountantEntity" on the environment.
+ It will turn off the ChangeTracking at the same time.
+
+ Sample output:
+ EntityName IsVisible ChangeTrackingEnabled EntityGuid
+ ---------- --------- --------------------- ----------
+ AccountantEntity True False 00002893-0000-0000-0003-005001000000
+
+ .EXAMPLE
+ PS C:\> Set-BapEnvironmentVirtualEntity -EnvironmentId eec2c11a-a4c7-4e1d-b8ed-f62acc9c74c6 -Name AccountantEntity -VisibilityOff
+
+ This will disable the Virtual Entity "AccountantEntity" on the environment.
+
+ Sample output:
+ EntityName IsVisible ChangeTrackingEnabled EntityGuid
+ ---------- --------- --------------------- ----------
+ AccountantEntity False False 00002893-0000-0000-0003-005001000000
+
+ .EXAMPLE
+ PS C:\> Set-BapEnvironmentVirtualEntity -EnvironmentId eec2c11a-a4c7-4e1d-b8ed-f62acc9c74c6 -Name AccountantEntity -TrackingOn
+
+ This will update the Virtual Entity "AccountantEntity" on the environment.
+ It will enable the ChangeTracking for the entity.
+
+ Sample output:
+ EntityName IsVisible ChangeTrackingEnabled EntityGuid
+ ---------- --------- --------------------- ----------
+ AccountantEntity True True 00002893-0000-0000-0003-005001000000
+
+ .NOTES
+ Author: Mötz Jensen (@Splaxi)
+#>
+function Set-BapEnvironmentVirtualEntity {
+ [Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSUseShouldProcessForStateChangingFunctions", "")]
+ [CmdletBinding()]
+ param (
+ [parameter (mandatory = $true)]
+ [string] $EnvironmentId,
+
+ [parameter (mandatory = $true)]
+ [string] $Name,
+
+ [switch] $VisibilityOn,
+
+ [switch] $VisibilityOff,
+
+ [switch] $TrackingOn,
+
+ [switch] $TrackingOff
+ )
+
+ begin {
+ if (-not($VisibilityOn -or $VisibilityOff -or $TrackingOn -or $TrackingOff)) {
+ $messageString = "You need to select atleast one of the ParameterSets: You have to use either -VisibilityOn / -VisibilityOff or -TrackingOn / -TrackingOff."
+ Write-PSFMessage -Level Host -Message $messageString
+ Stop-PSFFunction -Message "Stopping because intent of the operation is NOT clear." -Exception $([System.Exception]::new($($messageString -replace '<[^>]+>', '')))
+ }
+
+ if ($VisibilityOn -and $VisibilityOff) {
+ $messageString = "The supplied parameter combination is not valid. You have to use either -VisibilityOn or -VisibilityOff."
+ Write-PSFMessage -Level Host -Message $messageString
+ Stop-PSFFunction -Message "Stopping because intent of the operation is NOT clear." -Exception $([System.Exception]::new($($messageString -replace '<[^>]+>', '')))
+ }
+
+ if ($TrackingOn -and $TrackingOff) {
+ $messageString = "The supplied parameter combination is not valid. You have to use either -TrackingOn or -TrackingOff."
+ Write-PSFMessage -Level Host -Message $messageString
+ Stop-PSFFunction -Message "Stopping because intent of the operation is NOT clear." -Exception $([System.Exception]::new($($messageString -replace '<[^>]+>', '')))
+ }
+
+ if (Test-PSFFunctionInterrupt) { return }
+
+ # Make sure all *BapEnvironment* cmdlets will validate that the environment exists prior running anything.
+ $envObj = Get-BapEnvironment -EnvironmentId $EnvironmentId | Select-Object -First 1
+
+ if ($null -eq $envObj) {
+ $messageString = "The supplied EnvironmentId: $EnvironmentId didn't return any matching environment details. Please verify that the EnvironmentId is correct - try running the Get-BapEnvironment cmdlet."
+ Write-PSFMessage -Level Host -Message $messageString
+ Stop-PSFFunction -Message "Stopping because environment was NOT found based on the id." -Exception $([System.Exception]::new($($messageString -replace '<[^>]+>', '')))
+ }
+
+ if (Test-PSFFunctionInterrupt) { return }
+
+ $baseUri = $envObj.LinkedMetaPpacEnvApiUri
+ $tokenWebApi = Get-AzAccessToken -ResourceUrl $baseUri
+ $headersWebApi = @{
+ "Authorization" = "Bearer $($tokenWebApi.Token)"
+ }
+
+ $entities = @(Get-BapEnvironmentVirtualEntity -EnvironmentId $EnvironmentId -Name $Name)
+
+ if ($entities.Count -ne 1) {
+ $messageString = "The supplied EnvironmentId: $EnvironmentId didn't return any matching environment details. Please verify that the EnvironmentId is correct - try running the Get-BapEnvironment cmdlet."
+ Write-PSFMessage -Level Host -Message $messageString
+ Stop-PSFFunction -Message "Stopping because environment was NOT found based on the id." -Exception $([System.Exception]::new($($messageString -replace '<[^>]+>', '')))
+ }
+
+ if (Test-PSFFunctionInterrupt) { return }
+
+ $entity = $entities[0]
+ }
+
+ process {
+ if (Test-PSFFunctionInterrupt) { return }
+
+ $localUri = $($baseUri + '/XRMServices/2011/Organization.svc/web?SDKClientVersion=9.2.49.3165' -f $entity.EntityGuid)
+
+ # Base payload for updating the virtual entity configuration
+ $body = @'
+
+
+ CrmUser
+ 9.2.49.3165
+ {0}
+
+
+
+
+
+
+ Target
+
+
+##INPUT##
+
+
+
+ {1}
+
+ mserp_financeandoperationsentity
+
+
+
+
+
+ {0}
+ Update
+
+
+
+
+'@ -f $([System.Guid]::NewGuid().Guid), $entity.EntityGuid
+
+
+ if ($VisibilityOn -or $VisibilityOff) {
+ # We need to set the Visibility configuration for the virtual entity
+ $visibility = @'
+
+ mserp_hasbeengenerated
+ {0}
+
+'@ -f $(if ($VisibilityOn) { "true" }else { "false" })
+ }
+
+
+ if ($TrackingOn -or $TrackingOff) {
+ # We need to set the Tracking configuration for the virtual entity
+ $tracking = @'
+
+ mserp_changetrackingenabled
+ {0}
+
+'@ -f $(if ($TrackingOn) { "true" }else { "false" })
+ }
+
+ $body = $body -replace $("##INPUT##", "$visibility`r`n$tracking")
+
+ $headersWebApi."Content-Type" = "text/xml; charset=utf-8"
+ $headersWebApi.SOAPAction = "http://schemas.microsoft.com/xrm/2011/Contracts/Services/IOrganizationService/Execute"
+ Invoke-RestMethod -Method Post -Uri $localUri -Headers $headersWebApi -Body $body -ContentType "text/xml; charset=utf-8" > $null
+
+ # We are asking to fast for the meta data to be updated
+ Start-Sleep -Seconds 10
+
+ Get-BapEnvironmentVirtualEntity -EnvironmentId $EnvironmentId -Name $Name
+ }
+
+ end {
+
+ }
+}
\ No newline at end of file
diff --git a/d365bap.tools/functions/Update-BapEnvironmentVirtualEntityMetadata.ps1 b/d365bap.tools/functions/Update-BapEnvironmentVirtualEntityMetadata.ps1
new file mode 100644
index 0000000..abbad18
--- /dev/null
+++ b/d365bap.tools/functions/Update-BapEnvironmentVirtualEntityMetadata.ps1
@@ -0,0 +1,120 @@
+
+<#
+ .SYNOPSIS
+ Update the meta data for an Virtual Entity in an environment
+
+ .DESCRIPTION
+ Enables the user to update the metadata for any given Virtual Entity in the environment
+
+ This is useful when there has been schema changes on the Virtual Entity inside the D365FO environment, after it was made visible / enabled
+
+ .PARAMETER EnvironmentId
+ The id of the environment that you want to work against
+
+ .PARAMETER Name
+ The name of the virtual entity that you are looking for
+
+ .EXAMPLE
+ PS C:\> Update-BapEnvironmentVirtualEntityMetadata -EnvironmentId eec2c11a-a4c7-4e1d-b8ed-f62acc9c74c6 -Name AccountantEntity
+
+ This will execute the internal mechanism inside the Dataverse environment.
+ It will halt/stall as long as the operation is running.
+
+ .NOTES
+ Author: Mötz Jensen (@Splaxi)
+#>
+function Update-BapEnvironmentVirtualEntityMetadata {
+ [Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSUseShouldProcessForStateChangingFunctions", "")]
+ [CmdletBinding()]
+ param (
+ [parameter (mandatory = $true)]
+ [string] $EnvironmentId,
+
+ [parameter (mandatory = $true)]
+ [string] $Name
+ )
+
+ begin {
+ # Make sure all *BapEnvironment* cmdlets will validate that the environment exists prior running anything.
+ $envObj = Get-BapEnvironment -EnvironmentId $EnvironmentId | Select-Object -First 1
+
+ if ($null -eq $envObj) {
+ $messageString = "The supplied EnvironmentId: $EnvironmentId didn't return any matching environment details. Please verify that the EnvironmentId is correct - try running the Get-BapEnvironment cmdlet."
+ Write-PSFMessage -Level Host -Message $messageString
+ Stop-PSFFunction -Message "Stopping because environment was NOT found based on the id." -Exception $([System.Exception]::new($($messageString -replace '<[^>]+>', '')))
+ }
+
+ if (Test-PSFFunctionInterrupt) { return }
+
+ $baseUri = $envObj.LinkedMetaPpacEnvApiUri
+ $tokenWebApi = Get-AzAccessToken -ResourceUrl $baseUri
+ $headersWebApi = @{
+ "Authorization" = "Bearer $($tokenWebApi.Token)"
+ }
+
+ $entities = @(Get-BapEnvironmentVirtualEntity -EnvironmentId $EnvironmentId -Name $Name)
+
+ if ($entities.Count -ne 1) {
+ $messageString = "The supplied EnvironmentId: $EnvironmentId didn't return any matching environment details. Please verify that the EnvironmentId is correct - try running the Get-BapEnvironment cmdlet."
+ Write-PSFMessage -Level Host -Message $messageString
+ Stop-PSFFunction -Message "Stopping because environment was NOT found based on the id." -Exception $([System.Exception]::new($($messageString -replace '<[^>]+>', '')))
+ }
+
+ if (Test-PSFFunctionInterrupt) { return }
+
+ $entity = $entities[0]
+ }
+
+ process {
+ if (Test-PSFFunctionInterrupt) { return }
+
+ $localUri = $($baseUri + '/XRMServices/2011/Organization.svc/web?SDKClientVersion=9.2.49.3165' -f $entity.EntityGuid)
+
+ # Base payload for updating the virtual entity configuration
+ $body = @'
+
+
+ CrmUser
+ 9.2.49.3165
+ {0}
+
+
+
+
+
+
+ Target
+
+
+
+ mserp_refresh
+ true
+
+
+
+
+ {1}
+
+ mserp_financeandoperationsentity
+
+
+
+
+
+ {0}
+ Update
+
+
+
+
+'@ -f $([System.Guid]::NewGuid().Guid), $entity.EntityGuid
+
+ $headersWebApi."Content-Type" = "text/xml; charset=utf-8"
+ $headersWebApi.SOAPAction = "http://schemas.microsoft.com/xrm/2011/Contracts/Services/IOrganizationService/Execute"
+ Invoke-RestMethod -Method Post -Uri $localUri -Headers $headersWebApi -Body $body -ContentType "text/xml; charset=utf-8" > $null
+ }
+
+ end {
+
+ }
+}
\ No newline at end of file
diff --git a/d365bap.tools/tests/functions/Compare-BapEnvironmentVirtualEntity.Tests.ps1 b/d365bap.tools/tests/functions/Compare-BapEnvironmentVirtualEntity.Tests.ps1
new file mode 100644
index 0000000..9563770
--- /dev/null
+++ b/d365bap.tools/tests/functions/Compare-BapEnvironmentVirtualEntity.Tests.ps1
@@ -0,0 +1,75 @@
+Describe "Compare-BapEnvironmentVirtualEntity Unit Tests" -Tag "Unit" {
+ BeforeAll {
+ # Place here all things needed to prepare for the tests
+ }
+ AfterAll {
+ # Here is where all the cleanup tasks go
+ }
+
+ Describe "Ensuring unchanged command signature" {
+ It "should have the expected parameter sets" {
+ (Get-Command Compare-BapEnvironmentVirtualEntity).ParameterSets.Name | Should -Be '__AllParameterSets'
+ }
+
+ It 'Should have the expected parameter SourceEnvironmentId' {
+ $parameter = (Get-Command Compare-BapEnvironmentVirtualEntity).Parameters['SourceEnvironmentId']
+ $parameter.Name | Should -Be 'SourceEnvironmentId'
+ $parameter.ParameterType.ToString() | Should -Be System.String
+ $parameter.IsDynamic | Should -Be $False
+ $parameter.ParameterSets.Keys | Should -Be '__AllParameterSets'
+ $parameter.ParameterSets.Keys | Should -Contain '__AllParameterSets'
+ $parameter.ParameterSets['__AllParameterSets'].IsMandatory | Should -Be $True
+ $parameter.ParameterSets['__AllParameterSets'].Position | Should -Be 0
+ $parameter.ParameterSets['__AllParameterSets'].ValueFromPipeline | Should -Be $False
+ $parameter.ParameterSets['__AllParameterSets'].ValueFromPipelineByPropertyName | Should -Be $False
+ $parameter.ParameterSets['__AllParameterSets'].ValueFromRemainingArguments | Should -Be $False
+ }
+ It 'Should have the expected parameter DestinationEnvironmentId' {
+ $parameter = (Get-Command Compare-BapEnvironmentVirtualEntity).Parameters['DestinationEnvironmentId']
+ $parameter.Name | Should -Be 'DestinationEnvironmentId'
+ $parameter.ParameterType.ToString() | Should -Be System.String
+ $parameter.IsDynamic | Should -Be $False
+ $parameter.ParameterSets.Keys | Should -Be '__AllParameterSets'
+ $parameter.ParameterSets.Keys | Should -Contain '__AllParameterSets'
+ $parameter.ParameterSets['__AllParameterSets'].IsMandatory | Should -Be $True
+ $parameter.ParameterSets['__AllParameterSets'].Position | Should -Be 1
+ $parameter.ParameterSets['__AllParameterSets'].ValueFromPipeline | Should -Be $False
+ $parameter.ParameterSets['__AllParameterSets'].ValueFromPipelineByPropertyName | Should -Be $False
+ $parameter.ParameterSets['__AllParameterSets'].ValueFromRemainingArguments | Should -Be $False
+ }
+ It 'Should have the expected parameter ShowDiffOnly' {
+ $parameter = (Get-Command Compare-BapEnvironmentVirtualEntity).Parameters['ShowDiffOnly']
+ $parameter.Name | Should -Be 'ShowDiffOnly'
+ $parameter.ParameterType.ToString() | Should -Be System.Management.Automation.SwitchParameter
+ $parameter.IsDynamic | Should -Be $False
+ $parameter.ParameterSets.Keys | Should -Be '__AllParameterSets'
+ $parameter.ParameterSets.Keys | Should -Contain '__AllParameterSets'
+ $parameter.ParameterSets['__AllParameterSets'].IsMandatory | Should -Be $False
+ $parameter.ParameterSets['__AllParameterSets'].Position | Should -Be -2147483648
+ $parameter.ParameterSets['__AllParameterSets'].ValueFromPipeline | Should -Be $False
+ $parameter.ParameterSets['__AllParameterSets'].ValueFromPipelineByPropertyName | Should -Be $False
+ $parameter.ParameterSets['__AllParameterSets'].ValueFromRemainingArguments | Should -Be $False
+ }
+ It 'Should have the expected parameter AsExcelOutput' {
+ $parameter = (Get-Command Compare-BapEnvironmentVirtualEntity).Parameters['AsExcelOutput']
+ $parameter.Name | Should -Be 'AsExcelOutput'
+ $parameter.ParameterType.ToString() | Should -Be System.Management.Automation.SwitchParameter
+ $parameter.IsDynamic | Should -Be $False
+ $parameter.ParameterSets.Keys | Should -Be '__AllParameterSets'
+ $parameter.ParameterSets.Keys | Should -Contain '__AllParameterSets'
+ $parameter.ParameterSets['__AllParameterSets'].IsMandatory | Should -Be $False
+ $parameter.ParameterSets['__AllParameterSets'].Position | Should -Be -2147483648
+ $parameter.ParameterSets['__AllParameterSets'].ValueFromPipeline | Should -Be $False
+ $parameter.ParameterSets['__AllParameterSets'].ValueFromPipelineByPropertyName | Should -Be $False
+ $parameter.ParameterSets['__AllParameterSets'].ValueFromRemainingArguments | Should -Be $False
+ }
+ }
+
+ Describe "Testing parameterset __AllParameterSets" {
+ <#
+ __AllParameterSets -SourceEnvironmentId -DestinationEnvironmentId
+ __AllParameterSets -SourceEnvironmentId -DestinationEnvironmentId -ShowDiffOnly -AsExcelOutput
+ #>
+ }
+
+}
\ No newline at end of file
diff --git a/d365bap.tools/tests/functions/Set-BapEnvironmentVirtualEntity.Tests.ps1 b/d365bap.tools/tests/functions/Set-BapEnvironmentVirtualEntity.Tests.ps1
new file mode 100644
index 0000000..1506ec6
--- /dev/null
+++ b/d365bap.tools/tests/functions/Set-BapEnvironmentVirtualEntity.Tests.ps1
@@ -0,0 +1,101 @@
+Describe "Set-BapEnvironmentVirtualEntity Unit Tests" -Tag "Unit" {
+ BeforeAll {
+ # Place here all things needed to prepare for the tests
+ }
+ AfterAll {
+ # Here is where all the cleanup tasks go
+ }
+
+ Describe "Ensuring unchanged command signature" {
+ It "should have the expected parameter sets" {
+ (Get-Command Set-BapEnvironmentVirtualEntity).ParameterSets.Name | Should -Be '__AllParameterSets'
+ }
+
+ It 'Should have the expected parameter EnvironmentId' {
+ $parameter = (Get-Command Set-BapEnvironmentVirtualEntity).Parameters['EnvironmentId']
+ $parameter.Name | Should -Be 'EnvironmentId'
+ $parameter.ParameterType.ToString() | Should -Be System.String
+ $parameter.IsDynamic | Should -Be $False
+ $parameter.ParameterSets.Keys | Should -Be '__AllParameterSets'
+ $parameter.ParameterSets.Keys | Should -Contain '__AllParameterSets'
+ $parameter.ParameterSets['__AllParameterSets'].IsMandatory | Should -Be $True
+ $parameter.ParameterSets['__AllParameterSets'].Position | Should -Be 0
+ $parameter.ParameterSets['__AllParameterSets'].ValueFromPipeline | Should -Be $False
+ $parameter.ParameterSets['__AllParameterSets'].ValueFromPipelineByPropertyName | Should -Be $False
+ $parameter.ParameterSets['__AllParameterSets'].ValueFromRemainingArguments | Should -Be $False
+ }
+ It 'Should have the expected parameter Name' {
+ $parameter = (Get-Command Set-BapEnvironmentVirtualEntity).Parameters['Name']
+ $parameter.Name | Should -Be 'Name'
+ $parameter.ParameterType.ToString() | Should -Be System.String
+ $parameter.IsDynamic | Should -Be $False
+ $parameter.ParameterSets.Keys | Should -Be '__AllParameterSets'
+ $parameter.ParameterSets.Keys | Should -Contain '__AllParameterSets'
+ $parameter.ParameterSets['__AllParameterSets'].IsMandatory | Should -Be $True
+ $parameter.ParameterSets['__AllParameterSets'].Position | Should -Be 1
+ $parameter.ParameterSets['__AllParameterSets'].ValueFromPipeline | Should -Be $False
+ $parameter.ParameterSets['__AllParameterSets'].ValueFromPipelineByPropertyName | Should -Be $False
+ $parameter.ParameterSets['__AllParameterSets'].ValueFromRemainingArguments | Should -Be $False
+ }
+ It 'Should have the expected parameter VisibilityOn' {
+ $parameter = (Get-Command Set-BapEnvironmentVirtualEntity).Parameters['VisibilityOn']
+ $parameter.Name | Should -Be 'VisibilityOn'
+ $parameter.ParameterType.ToString() | Should -Be System.Management.Automation.SwitchParameter
+ $parameter.IsDynamic | Should -Be $False
+ $parameter.ParameterSets.Keys | Should -Be '__AllParameterSets'
+ $parameter.ParameterSets.Keys | Should -Contain '__AllParameterSets'
+ $parameter.ParameterSets['__AllParameterSets'].IsMandatory | Should -Be $False
+ $parameter.ParameterSets['__AllParameterSets'].Position | Should -Be -2147483648
+ $parameter.ParameterSets['__AllParameterSets'].ValueFromPipeline | Should -Be $False
+ $parameter.ParameterSets['__AllParameterSets'].ValueFromPipelineByPropertyName | Should -Be $False
+ $parameter.ParameterSets['__AllParameterSets'].ValueFromRemainingArguments | Should -Be $False
+ }
+ It 'Should have the expected parameter VisibilityOff' {
+ $parameter = (Get-Command Set-BapEnvironmentVirtualEntity).Parameters['VisibilityOff']
+ $parameter.Name | Should -Be 'VisibilityOff'
+ $parameter.ParameterType.ToString() | Should -Be System.Management.Automation.SwitchParameter
+ $parameter.IsDynamic | Should -Be $False
+ $parameter.ParameterSets.Keys | Should -Be '__AllParameterSets'
+ $parameter.ParameterSets.Keys | Should -Contain '__AllParameterSets'
+ $parameter.ParameterSets['__AllParameterSets'].IsMandatory | Should -Be $False
+ $parameter.ParameterSets['__AllParameterSets'].Position | Should -Be -2147483648
+ $parameter.ParameterSets['__AllParameterSets'].ValueFromPipeline | Should -Be $False
+ $parameter.ParameterSets['__AllParameterSets'].ValueFromPipelineByPropertyName | Should -Be $False
+ $parameter.ParameterSets['__AllParameterSets'].ValueFromRemainingArguments | Should -Be $False
+ }
+ It 'Should have the expected parameter TrackingOn' {
+ $parameter = (Get-Command Set-BapEnvironmentVirtualEntity).Parameters['TrackingOn']
+ $parameter.Name | Should -Be 'TrackingOn'
+ $parameter.ParameterType.ToString() | Should -Be System.Management.Automation.SwitchParameter
+ $parameter.IsDynamic | Should -Be $False
+ $parameter.ParameterSets.Keys | Should -Be '__AllParameterSets'
+ $parameter.ParameterSets.Keys | Should -Contain '__AllParameterSets'
+ $parameter.ParameterSets['__AllParameterSets'].IsMandatory | Should -Be $False
+ $parameter.ParameterSets['__AllParameterSets'].Position | Should -Be -2147483648
+ $parameter.ParameterSets['__AllParameterSets'].ValueFromPipeline | Should -Be $False
+ $parameter.ParameterSets['__AllParameterSets'].ValueFromPipelineByPropertyName | Should -Be $False
+ $parameter.ParameterSets['__AllParameterSets'].ValueFromRemainingArguments | Should -Be $False
+ }
+ It 'Should have the expected parameter TrackingOff' {
+ $parameter = (Get-Command Set-BapEnvironmentVirtualEntity).Parameters['TrackingOff']
+ $parameter.Name | Should -Be 'TrackingOff'
+ $parameter.ParameterType.ToString() | Should -Be System.Management.Automation.SwitchParameter
+ $parameter.IsDynamic | Should -Be $False
+ $parameter.ParameterSets.Keys | Should -Be '__AllParameterSets'
+ $parameter.ParameterSets.Keys | Should -Contain '__AllParameterSets'
+ $parameter.ParameterSets['__AllParameterSets'].IsMandatory | Should -Be $False
+ $parameter.ParameterSets['__AllParameterSets'].Position | Should -Be -2147483648
+ $parameter.ParameterSets['__AllParameterSets'].ValueFromPipeline | Should -Be $False
+ $parameter.ParameterSets['__AllParameterSets'].ValueFromPipelineByPropertyName | Should -Be $False
+ $parameter.ParameterSets['__AllParameterSets'].ValueFromRemainingArguments | Should -Be $False
+ }
+ }
+
+ Describe "Testing parameterset __AllParameterSets" {
+ <#
+ __AllParameterSets -EnvironmentId -Name
+ __AllParameterSets -EnvironmentId -Name -VisibilityOn -VisibilityOff -TrackingOn -TrackingOff
+ #>
+ }
+
+}
\ No newline at end of file
diff --git a/d365bap.tools/tests/functions/Update-BapEnvironmentVirtualEntityMetadata.Tests.ps1 b/d365bap.tools/tests/functions/Update-BapEnvironmentVirtualEntityMetadata.Tests.ps1
new file mode 100644
index 0000000..777447a
--- /dev/null
+++ b/d365bap.tools/tests/functions/Update-BapEnvironmentVirtualEntityMetadata.Tests.ps1
@@ -0,0 +1,49 @@
+Describe "Update-BapEnvironmentVirtualEntityMetadata Unit Tests" -Tag "Unit" {
+ BeforeAll {
+ # Place here all things needed to prepare for the tests
+ }
+ AfterAll {
+ # Here is where all the cleanup tasks go
+ }
+
+ Describe "Ensuring unchanged command signature" {
+ It "should have the expected parameter sets" {
+ (Get-Command Update-BapEnvironmentVirtualEntityMetadata).ParameterSets.Name | Should -Be '__AllParameterSets'
+ }
+
+ It 'Should have the expected parameter EnvironmentId' {
+ $parameter = (Get-Command Update-BapEnvironmentVirtualEntityMetadata).Parameters['EnvironmentId']
+ $parameter.Name | Should -Be 'EnvironmentId'
+ $parameter.ParameterType.ToString() | Should -Be System.String
+ $parameter.IsDynamic | Should -Be $False
+ $parameter.ParameterSets.Keys | Should -Be '__AllParameterSets'
+ $parameter.ParameterSets.Keys | Should -Contain '__AllParameterSets'
+ $parameter.ParameterSets['__AllParameterSets'].IsMandatory | Should -Be $True
+ $parameter.ParameterSets['__AllParameterSets'].Position | Should -Be 0
+ $parameter.ParameterSets['__AllParameterSets'].ValueFromPipeline | Should -Be $False
+ $parameter.ParameterSets['__AllParameterSets'].ValueFromPipelineByPropertyName | Should -Be $False
+ $parameter.ParameterSets['__AllParameterSets'].ValueFromRemainingArguments | Should -Be $False
+ }
+ It 'Should have the expected parameter Name' {
+ $parameter = (Get-Command Update-BapEnvironmentVirtualEntityMetadata).Parameters['Name']
+ $parameter.Name | Should -Be 'Name'
+ $parameter.ParameterType.ToString() | Should -Be System.String
+ $parameter.IsDynamic | Should -Be $False
+ $parameter.ParameterSets.Keys | Should -Be '__AllParameterSets'
+ $parameter.ParameterSets.Keys | Should -Contain '__AllParameterSets'
+ $parameter.ParameterSets['__AllParameterSets'].IsMandatory | Should -Be $True
+ $parameter.ParameterSets['__AllParameterSets'].Position | Should -Be 1
+ $parameter.ParameterSets['__AllParameterSets'].ValueFromPipeline | Should -Be $False
+ $parameter.ParameterSets['__AllParameterSets'].ValueFromPipelineByPropertyName | Should -Be $False
+ $parameter.ParameterSets['__AllParameterSets'].ValueFromRemainingArguments | Should -Be $False
+ }
+ }
+
+ Describe "Testing parameterset __AllParameterSets" {
+ <#
+ __AllParameterSets -EnvironmentId -Name
+ __AllParameterSets -EnvironmentId -Name
+ #>
+ }
+
+}
\ No newline at end of file
diff --git a/d365bap.tools/xml/d365bap.tools.Format.ps1xml b/d365bap.tools/xml/d365bap.tools.Format.ps1xml
index 8754695..c295cc9 100644
--- a/d365bap.tools/xml/d365bap.tools.Format.ps1xml
+++ b/d365bap.tools/xml/d365bap.tools.Format.ps1xml
@@ -389,5 +389,51 @@
+
+ D365Bap.Tools.Compare.VirtualEntity
+
+ D365Bap.Tools.Compare.VirtualEntity
+
+
+
+
+ 30
+
+
+ 15
+
+
+ 27
+
+
+ 11
+
+
+ 17
+
+
+
+
+
+
+ EntityName
+
+
+ SourceIsVisible
+
+
+ SourceChangeTrackingEnabled
+
+
+ DestinationIsVisible
+
+
+ DestinationChangeTrackingEnabled
+
+
+
+
+
+
\ No newline at end of file
diff --git a/docs/Compare-BapEnvironmentD365App.md b/docs/Compare-BapEnvironmentD365App.md
index 19a7e2d..9d1a25d 100644
--- a/docs/Compare-BapEnvironmentD365App.md
+++ b/docs/Compare-BapEnvironmentD365App.md
@@ -18,7 +18,7 @@ Compare-BapEnvironmentD365App [-SourceEnvironmentId] [-DestinationEnvir
```
## DESCRIPTION
-This enables the user to compare 2 x environments, with one as a source and the other as a destination
+Enables the user to compare 2 x environments, with one as a source and the other as a destination
It will only look for installed D365 Apps on the source, and use this as a baseline against the destination
diff --git a/docs/Compare-BapEnvironmentUser.md b/docs/Compare-BapEnvironmentUser.md
index 69e094e..a4dd44e 100644
--- a/docs/Compare-BapEnvironmentUser.md
+++ b/docs/Compare-BapEnvironmentUser.md
@@ -18,7 +18,7 @@ Compare-BapEnvironmentUser [-SourceEnvironmentId] [-DestinationEnvironm
```
## DESCRIPTION
-This enables the user to compare 2 x environments, with one as a source and the other as a destination
+Enables the user to compare 2 x environments, with one as a source and the other as a destination
It will only look for users on the source, and use this as a baseline against the destination
diff --git a/docs/Compare-BapEnvironmentVirtualEntity.md b/docs/Compare-BapEnvironmentVirtualEntity.md
new file mode 100644
index 0000000..87ae018
--- /dev/null
+++ b/docs/Compare-BapEnvironmentVirtualEntity.md
@@ -0,0 +1,142 @@
+---
+external help file: d365bap.tools-help.xml
+Module Name: d365bap.tools
+online version:
+schema: 2.0.0
+---
+
+# Compare-BapEnvironmentVirtualEntity
+
+## SYNOPSIS
+Compare environment Virtual Entities
+
+## SYNTAX
+
+```
+Compare-BapEnvironmentVirtualEntity [-SourceEnvironmentId] [-DestinationEnvironmentId]
+ [-ShowDiffOnly] [-AsExcelOutput] []
+```
+
+## DESCRIPTION
+Enables the user to compare 2 x environments, with one as a source and the other as a destination
+
+It will only look for enabled / visible Virtual Entities on the source, and use this as a baseline against the destination
+
+## EXAMPLES
+
+### EXAMPLE 1
+```
+Compare-BapEnvironmentVirtualEntity -SourceEnvironmentId eec2c11a-a4c7-4e1d-b8ed-f62acc9c74c6 -DestinationEnvironmentId 32c6b196-ef52-4c43-93cf-6ecba51e6aa1
+```
+
+This will get all enabled / visible Virtual Entities from the Source Environment.
+It will iterate over all of them, and validate against the Destination Environment.
+
+Sample output:
+EntityName SourceIsVisible SourceChangeTrackingEnabled Destination DestinationChange
+IsVisible TrackingEnabled
+---------- --------------- --------------------------- ----------- -----------------
+AccountantEntity True False True False
+CurrencyEntity True False False False
+WMHEOutboundQueueEntity True False False False
+
+### EXAMPLE 2
+```
+Compare-BapEnvironmentVirtualEntity -SourceEnvironmentId eec2c11a-a4c7-4e1d-b8ed-f62acc9c74c6 -DestinationEnvironmentId 32c6b196-ef52-4c43-93cf-6ecba51e6aa1 -ShowDiffOnly
+```
+
+This will get all enabled / visible Virtual Entities from the Source Environment.
+It will iterate over all of them, and validate against the Destination Environment.
+It will filter out results, to only include those where the Source is different from the Destination.
+
+Sample output:
+EntityName SourceIsVisible SourceChangeTrackingEnabled Destination DestinationChange
+IsVisible TrackingEnabled
+---------- --------------- --------------------------- ----------- -----------------
+CurrencyEntity True False False False
+WMHEOutboundQueueEntity True False False False
+
+### EXAMPLE 3
+```
+Compare-BapEnvironmentVirtualEntity -SourceEnvironmentId eec2c11a-a4c7-4e1d-b8ed-f62acc9c74c6 -DestinationEnvironmentId 32c6b196-ef52-4c43-93cf-6ecba51e6aa1
+```
+
+This will get all enabled / visible Virtual Entities from the Source Environment.
+It will iterate over all of them, and validate against the Destination Environment.
+Will output all details into an Excel file, that will auto open on your machine.
+
+## PARAMETERS
+
+### -SourceEnvironmentId
+Environment Id of the source environment that you want to utilized as the baseline for the compare
+
+```yaml
+Type: String
+Parameter Sets: (All)
+Aliases:
+
+Required: True
+Position: 1
+Default value: None
+Accept pipeline input: False
+Accept wildcard characters: False
+```
+
+### -DestinationEnvironmentId
+Environment Id of the destination environment that you want to validate against the baseline (source)
+
+```yaml
+Type: String
+Parameter Sets: (All)
+Aliases:
+
+Required: True
+Position: 2
+Default value: None
+Accept pipeline input: False
+Accept wildcard characters: False
+```
+
+### -ShowDiffOnly
+Instruct the cmdlet to only output the differences that are not aligned between the source and destination
+
+```yaml
+Type: SwitchParameter
+Parameter Sets: (All)
+Aliases:
+
+Required: False
+Position: Named
+Default value: False
+Accept pipeline input: False
+Accept wildcard characters: False
+```
+
+### -AsExcelOutput
+Instruct the cmdlet to output all details directly to an Excel file
+
+This makes it easier to deep dive into all the details returned from the API, and makes it possible for the user to persist the current state
+
+```yaml
+Type: SwitchParameter
+Parameter Sets: (All)
+Aliases:
+
+Required: False
+Position: Named
+Default value: False
+Accept pipeline input: False
+Accept wildcard characters: False
+```
+
+### CommonParameters
+This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216).
+
+## INPUTS
+
+## OUTPUTS
+
+## NOTES
+Author: Mötz Jensen (@Splaxi)
+
+## RELATED LINKS
diff --git a/docs/Get-BapEnvironment.md b/docs/Get-BapEnvironment.md
index f9378e3..8e4ee3e 100644
--- a/docs/Get-BapEnvironment.md
+++ b/docs/Get-BapEnvironment.md
@@ -17,7 +17,7 @@ Get-BapEnvironment [[-EnvironmentId] ] [-AsExcelOutput] [ [[-Name] ] [[-Instal
```
## DESCRIPTION
-This enables the user to analyze and validate the current D365 Apps and their state, on a given environment
+Enables the user to analyze and validate the current D365 Apps and their state, on a given environment
It can show all available D365 Apps - including their InstallState
diff --git a/docs/Get-BapEnvironmentVirtualEntity.md b/docs/Get-BapEnvironmentVirtualEntity.md
index 5024e1b..8f80b77 100644
--- a/docs/Get-BapEnvironmentVirtualEntity.md
+++ b/docs/Get-BapEnvironmentVirtualEntity.md
@@ -8,7 +8,7 @@ schema: 2.0.0
# Get-BapEnvironmentVirtualEntity
## SYNOPSIS
-Get Virutal Entity
+Get Virtual Entity from environment
## SYNTAX
@@ -20,7 +20,7 @@ Get-BapEnvironmentVirtualEntity [-EnvironmentId] [[-Name] ] [-V
## DESCRIPTION
Enables the user to query against the Virtual Entities from the D365FO environment
-This will help determine which Virtual Entities are already enabled / visible and their state
+This will help determine which Virtual Entities are already enabled / visible and their state, as they are seeing from the Dataverse environment
## EXAMPLES
@@ -77,6 +77,18 @@ DimAttributeRetailStoreEntity False False 00002893-0000-000
DimAttributeRetailTerminalEnt… False False 00002893-0000-0000-6e07-005001000000
EcoResRetailProductEntity False False 00002893-0000-0000-ae06-005001000000
+### EXAMPLE 5
+```
+Get-BapEnvironmentVirtualEntity -EnvironmentId eec2c11a-a4c7-4e1d-b8ed-f62acc9c74c6 -Name AccountantEntity
+```
+
+This will fetch the specific virtual entity from the environment.
+
+Sample output:
+EntityName IsVisible ChangeTrackingEnabled EntityGuid
+---------- --------- --------------------- ----------
+AccountantEntity False False 00002893-0000-0000-0003-005001000000
+
## PARAMETERS
### -EnvironmentId
@@ -167,6 +179,7 @@ This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable
## OUTPUTS
+### System.Object[]
## NOTES
Author: Mötz Jensen (@Splaxi)
diff --git a/docs/Invoke-BapEnvironmentInstallD365App.md b/docs/Invoke-BapEnvironmentInstallD365App.md
index d159818..a81f781 100644
--- a/docs/Invoke-BapEnvironmentInstallD365App.md
+++ b/docs/Invoke-BapEnvironmentInstallD365App.md
@@ -17,7 +17,7 @@ Invoke-BapEnvironmentInstallD365App [-EnvironmentId] [-PackageId] [-Name] [-VisibilityOn] [-VisibilityOff]
+ [-TrackingOn] [-TrackingOff] []
+```
+
+## DESCRIPTION
+Enables the user to update the configuration for any given Virtual Entity in the environment
+
+The configuration is done against the Dataverse environment, and allows the user to update the Visibility or TrackingChanges, for a given Virtual Entity
+
+## EXAMPLES
+
+### EXAMPLE 1
+```
+Set-BapEnvironmentVirtualEntity -EnvironmentId eec2c11a-a4c7-4e1d-b8ed-f62acc9c74c6 -Name AccountantEntity -VisibilityOn -TrackingOff
+```
+
+This will enable the Virtual Entity "AccountantEntity" on the environment.
+It will turn off the ChangeTracking at the same time.
+
+Sample output:
+EntityName IsVisible ChangeTrackingEnabled EntityGuid
+---------- --------- --------------------- ----------
+AccountantEntity True False 00002893-0000-0000-0003-005001000000
+
+### EXAMPLE 2
+```
+Set-BapEnvironmentVirtualEntity -EnvironmentId eec2c11a-a4c7-4e1d-b8ed-f62acc9c74c6 -Name AccountantEntity -VisibilityOff
+```
+
+This will disable the Virtual Entity "AccountantEntity" on the environment.
+
+Sample output:
+EntityName IsVisible ChangeTrackingEnabled EntityGuid
+---------- --------- --------------------- ----------
+AccountantEntity False False 00002893-0000-0000-0003-005001000000
+
+### EXAMPLE 3
+```
+Set-BapEnvironmentVirtualEntity -EnvironmentId eec2c11a-a4c7-4e1d-b8ed-f62acc9c74c6 -Name AccountantEntity -TrackingOn
+```
+
+This will update the Virtual Entity "AccountantEntity" on the environment.
+It will enable the ChangeTracking for the entity.
+
+Sample output:
+EntityName IsVisible ChangeTrackingEnabled EntityGuid
+---------- --------- --------------------- ----------
+AccountantEntity True True 00002893-0000-0000-0003-005001000000
+
+## PARAMETERS
+
+### -EnvironmentId
+The id of the environment that you want to work against
+
+```yaml
+Type: String
+Parameter Sets: (All)
+Aliases:
+
+Required: True
+Position: 1
+Default value: None
+Accept pipeline input: False
+Accept wildcard characters: False
+```
+
+### -Name
+The name of the virtual entity that you are looking for
+
+```yaml
+Type: String
+Parameter Sets: (All)
+Aliases:
+
+Required: True
+Position: 2
+Default value: None
+Accept pipeline input: False
+Accept wildcard characters: False
+```
+
+### -VisibilityOn
+Instructs the cmdlet to turn "ON" the Virtual Entity
+
+Can be used in combination with TrackingOn / TrackingOff
+
+```yaml
+Type: SwitchParameter
+Parameter Sets: (All)
+Aliases:
+
+Required: False
+Position: Named
+Default value: False
+Accept pipeline input: False
+Accept wildcard characters: False
+```
+
+### -VisibilityOff
+Instructs the cmdlet to turn "OFF" the Virtual Entity
+
+Can be used in combination with TrackingOn / TrackingOff
+
+```yaml
+Type: SwitchParameter
+Parameter Sets: (All)
+Aliases:
+
+Required: False
+Position: Named
+Default value: False
+Accept pipeline input: False
+Accept wildcard characters: False
+```
+
+### -TrackingOn
+Instructs the cmdlet to enable ChangeTracking on the Virtual Entity
+
+Can be used in combination with VisibilityOn / VisibilityOff
+
+```yaml
+Type: SwitchParameter
+Parameter Sets: (All)
+Aliases:
+
+Required: False
+Position: Named
+Default value: False
+Accept pipeline input: False
+Accept wildcard characters: False
+```
+
+### -TrackingOff
+Instructs the cmdlet to disable ChangeTracking on the Virtual Entity
+
+Can be used in combination with VisibilityOn / VisibilityOff
+
+```yaml
+Type: SwitchParameter
+Parameter Sets: (All)
+Aliases:
+
+Required: False
+Position: Named
+Default value: False
+Accept pipeline input: False
+Accept wildcard characters: False
+```
+
+### CommonParameters
+This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216).
+
+## INPUTS
+
+## OUTPUTS
+
+## NOTES
+Author: Mötz Jensen (@Splaxi)
+
+## RELATED LINKS
diff --git a/docs/Update-BapEnvironmentVirtualEntityMetadata.md b/docs/Update-BapEnvironmentVirtualEntityMetadata.md
new file mode 100644
index 0000000..98ad31f
--- /dev/null
+++ b/docs/Update-BapEnvironmentVirtualEntityMetadata.md
@@ -0,0 +1,76 @@
+---
+external help file: d365bap.tools-help.xml
+Module Name: d365bap.tools
+online version:
+schema: 2.0.0
+---
+
+# Update-BapEnvironmentVirtualEntityMetadata
+
+## SYNOPSIS
+Update the meta data for an Virtual Entity in an environment
+
+## SYNTAX
+
+```
+Update-BapEnvironmentVirtualEntityMetadata [-EnvironmentId] [-Name] []
+```
+
+## DESCRIPTION
+Enables the user to update the metadata for any given Virtual Entity in the environment
+
+This is useful when there has been schema changes on the Virtual Entity inside the D365FO environment, after it was made visible / enabled
+
+## EXAMPLES
+
+### EXAMPLE 1
+```
+Update-BapEnvironmentVirtualEntityMetadata -EnvironmentId eec2c11a-a4c7-4e1d-b8ed-f62acc9c74c6 -Name AccountantEntity
+```
+
+This will execute the internal mechanism inside the Dataverse environment.
+It will halt/stall as long as the operation is running.
+
+## PARAMETERS
+
+### -EnvironmentId
+The id of the environment that you want to work against
+
+```yaml
+Type: String
+Parameter Sets: (All)
+Aliases:
+
+Required: True
+Position: 1
+Default value: None
+Accept pipeline input: False
+Accept wildcard characters: False
+```
+
+### -Name
+The name of the virtual entity that you are looking for
+
+```yaml
+Type: String
+Parameter Sets: (All)
+Aliases:
+
+Required: True
+Position: 2
+Default value: None
+Accept pipeline input: False
+Accept wildcard characters: False
+```
+
+### CommonParameters
+This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216).
+
+## INPUTS
+
+## OUTPUTS
+
+## NOTES
+Author: Mötz Jensen (@Splaxi)
+
+## RELATED LINKS