Wednesday, November 2, 2011

Display all SharePoint portal list and Library on Powershell Console.

Leave a Comment
Execute following script in power shell and you will get list of all lists and libraries in SPWeb

PS> $site = Get-SPSite("Site URL");
        $web = $site.OpenWeb();
        $lists = $web.Lists;
        $lists | ForEach-Object { Write-Host $_.Title -Foregoundcolor red };

 // Foregoundcolor red : To show output in red.

Get User Name from User Information List using PowerShell

Leave a Comment
Execute following script in Power Shell and get value of Name Field from User Information List

PS > $site = Get-SPSite("Site URL");
         $web = $site.OpenWeb( );
         $list =  $web.Lists["User Information List"]

          // Here i am getting item by id but we can also use SPQuery object to get item from user information list and get SPListItem object.

         $listitem = $list.GetItemByID(1);
         Write-Host  $listitem["Name"];