A. Enabling in all site collections
$webAppsFeatureId = $(Get-SPFeature -limit all | where {$_.displayname -eq "OfficeWebApps"}).Id
Get-SPSite -limit ALL |foreach{Disable-SPFeature $webAppsFeatureId -url $_.URL }
B. Disabling from all site collections
$ConfirmPreference = 'None'
$webAppsFeatureId = $(Get-SPFeature -limit all | where {$_.displayname -eq "OfficeWebApps"}).Id
Get-SPSite -limit ALL |foreach{Disable-SPFeature $webAppsFeatureId -url $_.URL }
C. Enabling in all site collection within MySite Web Apps
$webAppsFeatureId = $(Get-SPFeature -limit all | where {$_.displayname -eq "OfficeWebApps"}).Id
Get-SPSite -WebApplication <web app url> -limit all |foreach{Enable-SPFeature $webAppsFeatureId -url $_.URL }
D. Enabling in a single site collection
$webAppsFeatureId = $(Get-SPFeature -limit all | where {$_.displayname -eq "OfficeWebApps"}).Id
$singleSiteCollection = Get-SPSite -Identity <site coll url>
Enable-SPFeature $webAppsFeatureId -Url $singleSiteCollection.URL
E. List sites which doesn't have Office Web Apps activated
Get-SPFeature -Site <site coll url> | where {$_.DisplayName -eq "OfficeWebApps"}
$SiteColls = @(Get-SPSite -WebApplication <web app > -Limit ALL)
foreach ($site in $SiteColls)
{
$feature= Get-SPFeature -Site $site.URL | where {$_.DisplayName -eq "OfficeWebApps"}
if ($feature -eq $Null)
{
write-host "OfficeWebApps is not activated at " , $site.URL
}
}
While activating OWA (using scripts A or C), I got some error which says couldn't activate because exceeded quota. But none of the site collection has exceeded quota. And there was no easy way to identify which site collection was not activated with OWA. Hence, the code (E).
Showing posts with label Automation Scripts. Show all posts
Showing posts with label Automation Scripts. Show all posts
Wednesday, December 14, 2011
Thursday, November 10, 2011
Error while visual upgrade
After mounting MySites DB, we performed the visual upgrade using the commands below:
$webapp = Get-SPWebApplication <web apps url>
foreach ($s in $webapp.sites)
{$s.VisualUpgradeWebs() }
but encountered the below error
Exception calling "VisualUpgradeWebs" with "0" argument(s): "Access is denied.
(Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))"
At line:2 char:22
+ {$s.VisualUpgradeWebs <<<< () }
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : DotNetMethodException
This is because at least one or more of the site collections are in read-only.
To find out which ones, run the commands below
$webapp = Get-SPWebApplication <web apps url>
foreach ($s in $webapp.sites)
{$s | Get-SPSite | Where {$_.readonly -eq "true" }} ; readonly is the column name !!
We then need to unlock those sites
Set-SPSite -Identity <site collection url> -LockState unlock
$webapp = Get-SPWebApplication <web apps url>
foreach ($s in $webapp.sites)
{$s.VisualUpgradeWebs() }
but encountered the below error
Exception calling "VisualUpgradeWebs" with "0" argument(s): "Access is denied.
(Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))"
At line:2 char:22
+ {$s.VisualUpgradeWebs <<<< () }
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : DotNetMethodException
This is because at least one or more of the site collections are in read-only.
To find out which ones, run the commands below
$webapp = Get-SPWebApplication <web apps url>
foreach ($s in $webapp.sites)
{$s | Get-SPSite | Where {$_.readonly -eq "true" }} ; readonly is the column name !!
We then need to unlock those sites
Set-SPSite -Identity <site collection url> -LockState unlock
Tuesday, August 17, 2010
Visual Basic script to manipulate an element in DOCICON.XML file
'Purpose: To add/update/remove the element
'into DOCICON.XML file make the installation/uninstallation of Foxit PDF iFilter complete
blnRevert = false
strAction = ""
'*** Arguments Section ***
If wscript.arguments.count = 1 Then
if lcase(wscript.arguments(0)) = "-update" OR lcase(wscript.arguments(0)) = "/update" Then
strAction = "update"
elseif lcase(wscript.arguments(0)) = "-remove" OR lcase(wscript.arguments(0)) = "/remove" Then
strAction = "remove"
else
call OutPutUsage
wscript.quit
end if
else
call OutPutUsage
wscript.quit
end if
strFileName = "C:\Program Files\Common Files\Microsoft Shared\Web server extensions\12\Template\Xml\DOCICON.XML"
Set objXMLDoc = CreateObject("Microsoft.XMLDOM")
objXMLDoc.async = False
blnFileExists = objXMLDoc.load(strFileName)
if blnFileExists = 0 then
OutPut strFileName + " file not found."
OutPut "Script will terminate"
wscript.quit
end if
Dim objCurrNode, objNewNode, objNewText, xmlTmpNode
Set objCurrNode = objxmlDoc.selectSingleNode("/DocIcons/ByExtension")
Dim i, blnElementExist
i = 0
blnElementExist = 0
for each xmlTmpNode in objCurrNode.ChildNodes
' OutPut xmlTmpNode.xml
strAttValue = xmlTmpNode.getAttribute("Key")
if lcase(strAttValue) = "pdf" then
blnElementExist = 1
exit for
else i = i + 1
end if
next
if strAction = "remove" then
if blnElementExist = 0 then
OutPut "Key Not found. No changes will be made."
else
objCurrNode.removeChild objCurrNode.ChildNodes(i)
objXMLDoc.save(strFileName)
OutPut "Key=PDF has been removed."
end if
else
if blnElementExist = 1 then
strAttValue = ""
strAttValue = xmlTmpNode.getAttribute("Value")
if lcase(strAttValue) "icpdf.gif" then
Set objNewNode = objxmlDoc.createNode(1,"Mapping","")
objNewNode.setAttribute "Key","pdf"
objNewNode.setAttribute "Value","icpdf.gif"
objCurrNode.replaceChild objNewNode, objCurrNode.ChildNodes(i)
Set objCurrNode = objCurrNode.lastChild
objXMLDoc.save(strFileName)
OutPut "Value for Key=pdf updated to icpdf.gif"
else OutPut "Key with correct value already exists. No changes will be made"
end if
else
Set objNewNode = objxmlDoc.createNode(1,"Mapping","")
objNewNode.setAttribute "Key","pdf"
objNewNode.setAttribute "Value","icpdf.gif"
objCurrNode.appendChild(objNewNode)
Set objCurrNode = objCurrNode.lastChild
objXMLDoc.save(strFileName)
OutPut "New element created: "
end if
end if
'OutPut objXMLDoc.xml
SUB OutPutUsage
OutPut ""
OutPut " " & wscript.scriptname & " is used to update or remove into DOCICON.XML"
OutPut ""
OutPut " Usage:"
OutPut ""
Output " " & wscript.scriptname & " [-update | -remove]"
OutPut ""
END SUB
SUB OutPut(strStringToOutPut)
wscript.echo strStringToOutPut
END SUB
So, in your bat file you do this:-
cscript.exe //nologo MOSS_DOCICON_Setting.vbs /update
or
cscript.exe //nologo MOSS_DOCICON_Setting.vbs /remove
'into DOCICON.XML file make the installation/uninstallation of Foxit PDF iFilter complete
blnRevert = false
strAction = ""
'*** Arguments Section ***
If wscript.arguments.count = 1 Then
if lcase(wscript.arguments(0)) = "-update" OR lcase(wscript.arguments(0)) = "/update" Then
strAction = "update"
elseif lcase(wscript.arguments(0)) = "-remove" OR lcase(wscript.arguments(0)) = "/remove" Then
strAction = "remove"
else
call OutPutUsage
wscript.quit
end if
else
call OutPutUsage
wscript.quit
end if
strFileName = "C:\Program Files\Common Files\Microsoft Shared\Web server extensions\12\Template\Xml\DOCICON.XML"
Set objXMLDoc = CreateObject("Microsoft.XMLDOM")
objXMLDoc.async = False
blnFileExists = objXMLDoc.load(strFileName)
if blnFileExists = 0 then
OutPut strFileName + " file not found."
OutPut "Script will terminate"
wscript.quit
end if
Dim objCurrNode, objNewNode, objNewText, xmlTmpNode
Set objCurrNode = objxmlDoc.selectSingleNode("/DocIcons/ByExtension")
Dim i, blnElementExist
i = 0
blnElementExist = 0
for each xmlTmpNode in objCurrNode.ChildNodes
' OutPut xmlTmpNode.xml
strAttValue = xmlTmpNode.getAttribute("Key")
if lcase(strAttValue) = "pdf" then
blnElementExist = 1
exit for
else i = i + 1
end if
next
if strAction = "remove" then
if blnElementExist = 0 then
OutPut "Key Not found. No changes will be made."
else
objCurrNode.removeChild objCurrNode.ChildNodes(i)
objXMLDoc.save(strFileName)
OutPut "Key=PDF has been removed."
end if
else
if blnElementExist = 1 then
strAttValue = ""
strAttValue = xmlTmpNode.getAttribute("Value")
if lcase(strAttValue) "icpdf.gif" then
Set objNewNode = objxmlDoc.createNode(1,"Mapping","")
objNewNode.setAttribute "Key","pdf"
objNewNode.setAttribute "Value","icpdf.gif"
objCurrNode.replaceChild objNewNode, objCurrNode.ChildNodes(i)
Set objCurrNode = objCurrNode.lastChild
objXMLDoc.save(strFileName)
OutPut "Value for Key=pdf updated to icpdf.gif"
else OutPut "Key with correct value already exists. No changes will be made"
end if
else
Set objNewNode = objxmlDoc.createNode(1,"Mapping","")
objNewNode.setAttribute "Key","pdf"
objNewNode.setAttribute "Value","icpdf.gif"
objCurrNode.appendChild(objNewNode)
Set objCurrNode = objCurrNode.lastChild
objXMLDoc.save(strFileName)
OutPut "New element created: "
end if
end if
'OutPut objXMLDoc.xml
SUB OutPutUsage
OutPut ""
OutPut " " & wscript.scriptname & " is used to update or remove into DOCICON.XML"
OutPut ""
OutPut " Usage:"
OutPut ""
Output " " & wscript.scriptname & " [-update | -remove]"
OutPut ""
END SUB
SUB OutPut(strStringToOutPut)
wscript.echo strStringToOutPut
END SUB
So, in your bat file you do this:-
cscript.exe //nologo MOSS_DOCICON_Setting.vbs /update
or
cscript.exe //nologo MOSS_DOCICON_Setting.vbs /remove
Friday, August 6, 2010
Visual basic script to check the status of a MOSS 2007 solution
A simple VB script that I wrote about 2 years back to automate solution deployment.
dim strSolutions , intReturnValue
strSolutions = "There are no items matching the criteria specified."
intReturnValue = 2 'solution not installed
Set objShell = CreateObject("WScript.Shell")
Set objScriptExec = objShell.Exec("C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\12\BIN\stsadm -o enumsolutions")
strSolutions = objScriptExec.StdOut.ReadAll
strSolutions = Trim(strSolutions)
pos=InStr(1,strSolutions,"There are no items",1)
if pos = 0 then
Set objXMLDoc = CreateObject("Microsoft.XMLDOM")
objXMLDoc.async = False
objXMLDoc.loadXML(strSolutions)
Dim objCurrNode, strDeployStatus
Set objCurrNode = objxmlDoc.selectSingleNode("/Solutions")
for each xmlTmpNode in objCurrNode.ChildNodes
strAttValue = xmlTmpNode.getAttribute("Name")
if lcase(strAttValue) = "" then
set ElementsList= xmlTmpNode.getElementsByTagName("Deployed")
for each Elem In ElementsList
strDeployStatus = Elem.firstChild.nodeValue
if LCase(Trim(strDeployStatus)) = "true" then
intReturnValue = 4 'solution installed & deployed
else
intReturnValue = 3 'solution installed BUT NOT deployed
end if
next
exit for
end if
next
end if
Wscript.Quit(intReturnValue)
dim strSolutions , intReturnValue
strSolutions = "There are no items matching the criteria specified."
intReturnValue = 2 'solution not installed
Set objShell = CreateObject("WScript.Shell")
Set objScriptExec = objShell.Exec("C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\12\BIN\stsadm -o enumsolutions")
strSolutions = objScriptExec.StdOut.ReadAll
strSolutions = Trim(strSolutions)
pos=InStr(1,strSolutions,"There are no items",1)
if pos = 0 then
Set objXMLDoc = CreateObject("Microsoft.XMLDOM")
objXMLDoc.async = False
objXMLDoc.loadXML(strSolutions)
Dim objCurrNode, strDeployStatus
Set objCurrNode = objxmlDoc.selectSingleNode("/Solutions")
for each xmlTmpNode in objCurrNode.ChildNodes
strAttValue = xmlTmpNode.getAttribute("Name")
if lcase(strAttValue) = "" then
set ElementsList= xmlTmpNode.getElementsByTagName("Deployed")
for each Elem In ElementsList
strDeployStatus = Elem.firstChild.nodeValue
if LCase(Trim(strDeployStatus)) = "true" then
intReturnValue = 4 'solution installed & deployed
else
intReturnValue = 3 'solution installed BUT NOT deployed
end if
next
exit for
end if
next
end if
Wscript.Quit(intReturnValue)
Subscribe to:
Posts (Atom)