TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
C# Corner
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
PowerShell Snippet to Check Whether WebApplication Level Feature is Activated or not if not then Activate the Feature
Prasham Sabadra
May 22
2015
Code
1.6
k
0
0
facebook
twitter
linkedIn
Reddit
WhatsApp
Email
Bookmark
expand
<
#
.SYNOPSIS
Activating WebApplication level features if not already activated
.PARAMETER Url
The URL of the web application
.PARAMETER featureID
ID of feature which need to be activated
#
>
param
(
[parameter(
Mandatory
=$true)][string]$Url,
[parameter(
Mandatory
=$true)][string]$featureID
)
#Activate web application Feature
#----------------------------------------------------
$
webApplication
=
Get
-SPWebApplication -Identity $Url
#Check whether Feature to be activated is already activated
$
feature
=
Get
-SPFeature -WebApplication $webApplication | where {$_.Id -eq $fatureID}
if ($feature)
{
Write-Host "feature with ID" $fatureID "is already activated"
}
else
{
Enable-SPFeature -Identity $fatureID -Url $webApplication.url
Write-Host "feature with ID" $fatureID "has been activated at :" $webApplication.url
}