我想知道如何在不使用PowerShell确认的情况下删除集中管理Web应用程序?我正在使用的脚本(现在所有的Web应用程序都被删除而没有任何限制,只有中央管理Web应用程序请求它)。提前谢谢。
function RemoveWebApplications()
{
WriteFuncInfo "Removing all web applications..."
$applications = Get-SPWebApplication -IncludeCentralAdministration
if($applications -eq $null)
{
WriteFuncInfo "No web applications found."
return
}
WriteFuncInfo "Removing web applications $($applications.Count):"
foreach($application in $applications)
{
WriteFuncInfo "$($application.Name) with database and iis site"
Remove-SPWebApplication $application -DeleteIISSite -RemoveContentDatabases -Confirm:$false
}
}
答案 0 :(得分:3)
我找到了解决方案,我现在正在使用的方法:
function RemoveCentralAdministration()
{
WriteFuncInfo "Removing central administrations:"
$applications = Get-SPWebApplication -IncludeCentralAdministration | where-object {$_.IsAdministrationWebApplication -eq $true }
if($applications -eq $null)
{
WriteFuncInfo "No central administrations found."
return
}
foreach($application in $applications)
{
WriteFuncInfo "$($application.Url)"
# for central administration web application Remove-SPWebApplication cmdlet requests confiramtion
# even if parameter '-Confirm:$false' is used
# Remove-SPWebApplication $application -DeleteIISSite -RemoveContentDatabases -Confirm:$false
WriteFuncInfo "`t removing iis site"
$application.UnprovisionGlobally($true);
WriteFuncInfo "`t removing databases"
foreach ($contentDb in $application.ContentDatabases)
{
$contentDb.Unprovision();
}
$application.Delete();
}
}
此解决方案基于“Remove-SPWebApplication”cmdlet中的原始代码。它可以在 Microsoft.SharePoint.PowerShell.dll SPCmdletRemoveSPWebApplication 中创建。