Tuesday, July 19, 2016

How to: Change the size of the column in SharePoint list view

Do you know how SharePoint determines the size of the Multiline Text type column for the list view? I don’t think SharePoint knows that either.
In essence, Multiline text columns, if there are several of them, seem to get their size from the heading text, so if the text is just one small word – then the entire column and it’s content will be all bunched up in a tiny little column.

That’s not always convenient, so I thought it’d be cool to show you how you can control the size of the column using jQuery script.
Ensure you have a latest version of the jQuery file (in my case it’s jquery-1.10.2.js)
As always with these types of customizations, we will add a Content Editor Web Parton the top of the list view. The following is the code to be added to the web part.
<script src="/Shared%20Documents/jquery-1.10.2.js"></script>
<script language="javascript">
_spBodyOnLoadFunctionNames.push("AdjustColumnWidth");
function AdjustColumnWidth(){
$("div.ms-vh-div[DisplayName='BigColumn']").attr("style", "WIDTH: 550px");
$("div.ms-vh-div[DisplayName='Column1']").attr("style", "WIDTH: 550px");
$("div.ms-vh-div[DisplayName='Column2']").attr("style", "WIDTH: 550px");
}</script>
Above you will see three lines of code in the AdjustColumnWidth function:
$("div.ms-vh-div[DisplayName='Column2']").attr("style", "WIDTH: 550px");
See the part that has DisplayName=’Column2′, well change the “Column2” to whatever is the display name of your Multiline text column. You can also change the width to whatever is the pixel size that you need your column to be
Save the web part content and the page and that’s it!
The result speaks for itself:

Enjoy!

Ref: http://www.sharemuch.com/2014/03/18/how-to-change-the-size-of-the-column-in-sharepoint-list-view/

How to: Change the size of the column in SharePoint list view

Do you know how SharePoint determines the size of the Multiline Text type column for the list view? I don’t think SharePoint knows that either.
In essence, Multiline text columns, if there are several of them, seem to get their size from the heading text, so if the text is just one small word – then the entire column and it’s content will be all bunched up in a tiny little column.

SharePoint columns size is random
That’s not always convenient, so I thought it’d be cool to show you how you can control the size of the column using jQuery script.
Ensure you have a latest version of the jQuery file (in my case it’s jquery-1.10.2.js)
As always with these types of customizations, we will add a Content Editor Web Parton the top of the list view. The following is the code to be added to the web part.
<script src="/Shared%20Documents/jquery-1.10.2.js"></script>
<script language="javascript">
_spBodyOnLoadFunctionNames.push("AdjustColumnWidth");
function AdjustColumnWidth(){
$("div.ms-vh-div[DisplayName='BigColumn']").attr("style", "WIDTH: 550px");
$("div.ms-vh-div[DisplayName='Column1']").attr("style", "WIDTH: 550px");
$("div.ms-vh-div[DisplayName='Column2']").attr("style", "WIDTH: 550px");
}</script>
Above you will see three lines of code in the AdjustColumnWidth function:
$("div.ms-vh-div[DisplayName='Column2']").attr("style", "WIDTH: 550px");
See the part that has DisplayName=’Column2′, well change the “Column2” to whatever is the display name of your Multiline text column. You can also change the width to whatever is the pixel size that you need your column to be
Save the web part content and the page and that’s it!
The result speaks for itself:
SharePoint columns size changed
Enjoy!

Ref: http://www.sharemuch.com/2014/03/18/how-to-change-the-size-of-the-column-in-sharepoint-list-view/

Tuesday, June 21, 2016

Running PowerShell on MOSS 2007

Running PowerShell on MOSS 2007


  1. If you are running MOSS 2007 on Windows Server 2003 the you have to download and install PowerShell fromhttp://support.microsoft.com/kb/968930. Windows Server 2008  natively supports PowerShell.
  2. Set the  Execution Policy to ‘RemoteSigned’. You can check it by running ‘Get-ExecutionPolicy’ cmdlet 
    The default execution policy for PowerShell is “Restricted” (commands only, not scripts)
         
# All scripts running locally are allowed
Set-ExecutionPolicy RemoteSigned
This means downloaded scripts must be signed by a trusted publisher before they can be run.
     3. You need to load the SharePoint assemblies with the following command
#    Load the SharePoint assemblies
[Void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint")
A bunch of PowerShell scripts are available at http://www.powershell.nu/2009/09/08/moss-2007-script-collection

Ref: https://blogs.technet.microsoft.com/praveenh/2013/01/21/running-powershell-on-moss-2007/ 

Ex:1 Retrieve the list of Content Types in MOSS 2007 using PowerShell
MOSS 2007 
[void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint") | out-null
Write-host ".."
Write-host ".."
Write-host "Get a list of Content types"
$site = new-object Microsoft.SharePoint.SPSite("http://spweb/extend"); # specify url here
foreach ($web in $site.AllWebs) { 
  $ctypes = $web.ContentTypes
  foreach ($ctype in $ctypes) {
  $usages = [Microsoft.Sharepoint.SPContentTypeUsage]::GetUsages($ctype) 
    foreach ($usage in $usages) { 
    Write-Host $web.Name + "," + $ctype.Name + "," + $usage.Url 
    } 
  }
}

Ex:2 

MOSS 2007 – Find the default view url for all lists in a web app using PowerShell


param
(
    $url = $(Read-Host -Prompt "WebApp Url")
)
# Default View for lists in All Sites
# Lookup Web Application as specified in the command line parameter
$wa = [Microsoft.SharePoint.Administration.SPWebApplication]::Lookup($url) 
# Create an array 
$sites =@()
Write-Output("`nProcessing sites...`n") 
# Loop through all site collections in the web application
foreach($site in $wa.Sites)
{
    foreach ($s in $site)
    {
        $spWeb = $s.openweb()
            foreach($list in $spweb.lists)
            {
                Write-Host "list:", $list.defaultview.url
            }
    }
}