Per Prerequisites to track changes for finance and operations virtual tables in Dataverse, the virtual entity must be visible in Dataverse before change tracking can be enabled.
When calling Set-BapEnvironmentVirtualEntity -EnvironmentId $environmentId -Name $virtualEntitiesName -TrackingOn for an entity that is not visible, you get a cryptic error message.
Invoke-RestMethod: s:ClientCould not find an entity with name mserp_myentity and id 00000000-0000-0000-0000-000000000000
Set-BapEnvironmentVirtualEntity should check the visibility of the entity first when -TrackingOn is used. If the entity is not visible, the cmdlet should give the user an appropriate warning message.
In addition, Set-BapEnvironmentVirtualEntity should give a warning message for -VisibilityOff in combination with -TrackingOn. Currently, this only makes the entity invisible without any hint that tracking was not enabled.