Professional Documents
Culture Documents
强制删除受保护的hyperv服务器的注册
强制删除受保护的hyperv服务器的注册
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
$serviceName = "dra"
$service = Get-Service -Name $serviceName
if ($service.Status -eq "Running")
{
"Stopping the Azure Site Recovery service..."
net stop $serviceName
}
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
}