Skip to main content

Posts

Showing posts from September, 2013

SharePoint Training @ Pyxle

Audience : 15 Members

Format Text Out as a Table (Format-Table) in Power Shell

Format-Table in a powerful command that you can use to format your output. output can be a console or a file out. Format-Table working with object or a object collection. For an example If you have a object collection from your code you can out put as a table. Get-SPSite -Limit All | Format-Table –AutoSize -AutoSize will be use to format columns with depending of screen size. But if you are working with long width tables you better use Out-String -Width 4000 with output pipe. (4000 is a character count in horizontal, You can mention any suitable value ) Ex:- Get-SPSite -Limit All| Format-Table –AutoSize | Out-String -Width 4000 You can use Format-Table with a single object as well. Ex:- With all columns   $objAverage = New-Object System.Object $objAverage | Add-Member -type NoteProperty -name Col1 -value "saman" $objAverage | Add-Member -type NoteProperty -Name Col2 -Value 23423   $objAverage | Format-Table –AutoSize Ex:- With mentioned columns $objAverage = New-Obje...

Get SharePoint Feature by Name and Execute for all site collections

This is a simple script for day today works :) This script will find a feature that contains name like “OpenIn” and activate for entire site collections. Enable Feature for All Site Collections $feature = Get -SPFeature | where { $_.DisplayName - like "*OpenIn*" }   $featureId = $feature.Id Get -SPSite -limit ALL |foreach{ Enable-SPFeature $featureId -url $_.URL -confirm:$ false } This script will find a feature that contains name like “OpenIn” and deactivate for entire site collections. Disable Feature for All Site Collections $feature = Get -SPFeature | where { $_.DisplayName - like "*OpenIn*" }   $featureId = $feature.Id Get -SPSite -limit ALL |foreach{ Disable-SPFeature $featureId -url $_.URL -confirm:$ false }