Posts

Showing posts with the label Document Library

PowerShell code for looking up document properties

If you want to use the SPWeb.Files.Add() method that allows you to pass in a HashTable of metadata for the document, you will need to use the internal name of the metadata field, not the display name.   Here's a PowerShell script to get that for you quickly: $web = Get-SPWeb http://intranet.sharepointdev.com $list = $web.Lists["Shared Documents"] foreach($item in $list.Items) {     $file = $item.File     #output all the SPFile property names     foreach($key in $file.Properties.Keys)     {         write-host("File Key: " + $key)     }         #output the associated item's fields     foreach($field in $item.Fields)     {         write-host("Item Field: " + $field.InternalName)     }     break; }

Turn on versioning on a site's Document Libraries.

We had a lot of sites that needed to have versioning turned on, here's a simple console app I wrote to do this, you just pass the url of the web as an argument: using System; using System.Collections.Generic; using System.Linq; using System.Text; using Microsoft.SharePoint; namespace Mirant.Utilities.SiteVersioningActivator {     class Program     {         static void Main(string[] args)         {             if (args.Length != 1)                 throw new Exception("URL of the site is required as a parameter");             string webUrl = args[0];             using (SPSite site = new SPSite(webUrl))             {                 using (SPWeb web = site.OpenWeb())  ...

Map a drive letter to a SharePoint document library

This is a cool trick that I hadn't thought of...