To check if a web application exists in SharePoint environment using PowerShell, use this script.
Add-PsSnapin Microsoft.SharePoint.PowerShell
[void][System.Reflection.Assembly]::LoadWithPartialName(“Microsoft.SharePoint”)
$WebAppName = "IntranetPortal80"
$sp = Get-SPWebApplication | Where {$_.DisplayName -eq $WebAppName}
if($sp -eq $null)
{
Write-host "Null"
}
else
{
write-host "No Null"
}
In, if-else block do what you want to do.
Nice script, I just need it for automatic deployment!
ReplyDeleteThanks for your effort.
Best Regards,
Mark