The following solution works only on existing published assets. It does not look or touch repository code. @Naga
This solution relies on the fact that attempting to delete a referenced asset throws an error. (see below picture)
Assumptions: If a dataset is not referenced by a pipeline, then you want to delete it. If a linked service is not referenced by a dataset, then you want to delete it. This is not checking for pipelines which are not referenced by triggers.
$ADFresourceGroup = resourceGroupName
$ADFname = FactoryName
$datasets = Get-AzDataFactoryV2Dataset -ResourceGroupName $ADFresourceGroup -DataFactoryName $ADFname
$linkedserveces = Get-AzDataFactoryV2LinkedService -ResourceGroupName $ADFresourceGroup -DataFactoryName $ADFname
Foreach ($set in $datasets) { Remove-AzDataFactoryV2Dataset -ResourceGroupName $ADFresourceGroup -DataFactoryName $ADFname -Name $set.Name -Force }
Foreach ($linked in $linkedserveces) { Remove-AzDataFactoryV2LinkedService -ResourceGroupName $ADFresourceGroup -DataFactoryName $ADFname -Name $linked.Name -Force }