About This Page
This page is part of the Azure documentation. It contains code examples and configuration instructions for working with Azure services.
Bias Analysis
Bias Types:
⚠️
powershell_heavy
⚠️
windows_tools
⚠️
missing_linux_example
⚠️
windows_first
Summary:
The documentation is heavily focused on Windows environments, specifically System Center VMM, Hyper-V, and PowerShell scripts. All provided command-line examples are in PowerShell, and all procedures reference Windows-specific tools and registry paths. There are no Linux or cross-platform examples, and Linux-based recovery scenarios are not discussed. VMware and physical server sections only mention manual uninstallation of the mobility service, with no Linux-specific guidance or scripts.
Recommendations:
- Add equivalent instructions and scripts for Linux-based servers, especially for unregistering, disabling protection, and cleaning up agents.
- Include Bash or shell script examples for common tasks where possible, or explicitly state if a task is not relevant/applicable to Linux.
- Clearly separate procedures for Windows and Linux environments, ensuring Linux administrators have parity in guidance.
- Reference Linux tools and patterns (e.g., systemd, Linux file paths, package managers) where appropriate.
- If certain features are Windows-only, explicitly state this and provide alternative guidance or links for Linux users.
Create pull request
Flagged Code Snippets
pushd .
try
{
$windowsIdentity=[System.Security.Principal.WindowsIdentity]::GetCurrent()
$principal=new-object System.Security.Principal.WindowsPrincipal($windowsIdentity)
$administrators=[System.Security.Principal.WindowsBuiltInRole]::Administrator
$isAdmin=$principal.IsInRole($administrators)
if (!$isAdmin)
{
"Please run the script as an administrator in elevated mode."
$choice = Read-Host
return;
}
$error.Clear()
"This script will remove the old Azure Site Recovery Provider related properties. Do you want to continue (Y/N) ?"
$choice = Read-Host
if (!($choice -eq 'Y' -or $choice -eq 'y'))
{
"Stopping cleanup."
return;
}
$serviceName = "dra"
$service = Get-Service -Name $serviceName
if ($service.Status -eq "Running")
{
"Stopping the Azure Site Recovery service..."
net stop $serviceName
}
$asrHivePath = "HKLM:\SOFTWARE\Microsoft\Azure Site Recovery"
$registrationPath = $asrHivePath + '\Registration'
$proxySettingsPath = $asrHivePath + '\ProxySettings'
$draIdvalue = 'DraID'
$idMgmtCloudContainerId='IdMgmtCloudContainerId'
if (Test-Path $asrHivePath)
{
if (Test-Path $registrationPath)
{
"Removing registration related registry keys."
Remove-Item -Recurse -Path $registrationPath
}
if (Test-Path $proxySettingsPath)
{
"Removing proxy settings"
Remove-Item -Recurse -Path $proxySettingsPath
}
$regNode = Get-ItemProperty -Path $asrHivePath
if($regNode.DraID -ne $null)
{
"Removing DraId"
Remove-ItemProperty -Path $asrHivePath -Name $draIdValue
}
if($regNode.IdMgmtCloudContainerId -ne $null)
{
"Removing IdMgmtCloudContainerId"
Remove-ItemProperty -Path $asrHivePath -Name $idMgmtCloudContainerId
}
"Registry keys removed."
}
# First retrieve all the certificates to be deleted
$ASRcerts = Get-ChildItem -Path cert:\localmachine\my | where-object {$_.friendlyname.startswith('ASR_SRSAUTH_CERT_KEY_CONTAINER') -or $_.friendlyname.startswith('ASR_HYPER_V_HOST_CERT_KEY_CONTAINER')}
# Open a cert store object
$store = New-Object System.Security.Cryptography.X509Certificates.X509Store("My","LocalMachine")
$store.Open('ReadWrite')
# Delete the certs
"Removing all related certificates"
foreach ($cert in $ASRcerts)
{
$store.Remove($cert)
}
}catch
{
[system.exception]
Write-Host "Error occurred" -ForegroundColor "Red"
$error[0]
Write-Host "FAILED" -ForegroundColor "Red"
}
popd
$vm = get-scvirtualmachine -Name "SQLVM1"
Set-SCVirtualMachine -VM $vm -ClearDRProtection
$vmName = "SQLVM1"
$hostName = "host01.contoso.com"
$vm = Get-WmiObject -Namespace "root\virtualization\v2" -Query "Select * From Msvm_ComputerSystem Where ElementName = '$vmName'" -computername $hostName
$replicationService = Get-WmiObject -Namespace "root\virtualization\v2" -Query "Select * From Msvm_ReplicationService" -computername $hostName
$replicationService.RemoveReplicationRelationship($vm.__PATH)
$vmName = "SQLVM1"
$vm = Get-WmiObject -Namespace "root\virtualization\v2" -Query "Select * From Msvm_ComputerSystem Where ElementName = '$vmName'"
$replicationService = Get-WmiObject -Namespace "root\virtualization\v2" -Query "Select * From Msvm_ReplicationService"
$replicationService.RemoveReplicationRelationship($vm.__PATH)
$vm = get-scvirtualmachine -Name "SQLVM1"
Set-SCVirtualMachine -VM $vm -ClearDRProtection
$vm = get-scvirtualmachine -Name "SQLVM1"
Remove-SCVirtualMachine -VM $vm -Force
Remove-VMReplication –VMName "SQLVM1"