You will not be able to use PowerShell or CLI to query Azure AD DS unlike Azure AD. You need to have access to any VM which is domain joined to Azure AD DS and you can perform AD commands to perform your query.
OK, so we have automated the removal of some VMs in Azure DevOps when they are no longer needed. How would you go about automating the removal of the VM from Azure AD DS? or would this need to be a manual step?
You need to come up with a logic to run a script in the VM which is joined to AD DS from DevOps. You need to use RAST tool to delete the computer object using a PS command which needs to be executed from the VM which is domain joined