Skip to content

Instantly share code, notes, and snippets.

@mjendza
Created May 13, 2016 09:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mjendza/fd60c4d4ccaa58e0ab9b96f36cf755d8 to your computer and use it in GitHub Desktop.
Save mjendza/fd60c4d4ccaa58e0ab9b96f36cf755d8 to your computer and use it in GitHub Desktop.
function Read-Onet{
param (
[string] $path
)
asnp *sharepoint*
$file = "C:\Program Files\Common Files\microsoft shared\Web Server Extensions\15\" + "TEMPLATE\" + $path+"\xml\onet.xml";
write-host $file
if (Test-Path $file) {
[xml]$onet = Get-Content $($file)
# write-host $onet
$onet.Project.Configurations.Configuration.SiteFeatures|% {
$feature = $_;
#write-host $feature.Feature.ID
try{
Get-SPFeature -Identity [string]$feature.Feature.ID
}
catch{
Write-Error $_ -ErrorAction Continue
}
}
$onet.Project.Configurations.Configuration.WebFeatures|% {
$feature = $_;
#write-host $feature.Feature.ID
try{
Get-SPFeature -Identity [string]$feature.Feature.ID
}
catch{
Write-Error $_ -ErrorAction Continue
}
}
}
}
function Get-InstalledSiteDefinitions {
param (
[int] $lang = 1045
)
if ($lang -eq $NULL) { $lang = 1045; }
#C:\Program Files\Common Files\microsoft shared\Web Server Extensions\15\TEMPLATE\1045\XML
$path = "C:\Program Files\Common Files\microsoft shared\Web Server Extensions\15\" + "TEMPLATE\" + $lang + "\XML\WEBTEMP*.xml";
if (Test-Path $path) {
write-host $path
Select-String -Path $path -Pattern '(?:<Template[^>]+SetupPath="(?<SetupPath>[^"]+)"[^>]*>)' -AllMatches | ForEach-Object { Read-Onet -path $_.Matches[0].Groups[1].Value } | Sort-Object
}
}
Get-InstalledSiteDefinitions $args[0]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment