þÿparam( [string] $url = "", [string] $ListName = "" ) $sharepoint = [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint") $site=[Microsoft.Sharepoint.SPSite]($url); $web=$site.openweb(); $list= $web.lists[$ListName]; $schema =@" <Field ID="{E2ABF8D3-6435-4773-A3D6-67508FEB7CF5}" ReadOnly="TRUE" Type="Computed" Name="KRItemLinkTitleDropdown" DisplayName="Title" DisplayNameSrcField="Title" AuthoringInfo="(dropdown displaying the title field)" EnableLookup="TRUE" SourceID="http://schemas.microsoft.com/sharepoint/v3" StaticName="KRItemLinkTitleDropdown" FromBaseType="TRUE" ClassInfo="Menu"> <FieldRefs> <FieldRef Name="Title" /> <FieldRef Name="LinkTitleNoMenu" /> <FieldRef Name="FSObjType" /> </FieldRefs> <DisplayPattern> <Field Name="_EditMenuTableStart" /> <HTML> <![CDATA[<A onfocus="OnLink(this)" HREF="]]></HTML> <IfEqual> <Expr1> <LookupColumn Name="FSObjType" /> </Expr1> <Expr2>1</Expr2> <Then> <FieldSwitch> <Expr> <GetVar Name="RecursiveView" /> </Expr> <Case Value="1"> <LookupColumn Name="FileLeafRef" HTMLEncode="TRUE" /> </Case> <Default> <SetVar Name="UnencodedFilterLink"> <SetVar Name="RootFolder"><HTML>/</HTML> <LookupColumn Name="FileRef" /> </SetVar> <SetVar Name="FolderCTID"> <FieldSwitch> <Expr> <ListProperty Select="EnableContentTypes" /> </Expr> <Case Value="1"> <Column Name="ContentTypeId" /> </Case> </FieldSwitch> </SetVar> <FilterLink Default="" Paged="FALSE" /> </SetVar> <GetVar Name="UnencodedFilterLink" HTMLEncode="TRUE" /> </Default> </FieldSwitch> </Then> <Else> <Field Name="ServerUrl" URLEncodeAsURL="TRUE" /> </Else> </IfEqual> <HTML><![CDATA[" onclick="return DispEx(this,event,']]></HTML> <ScriptQuote NotAddingQuote="TRUE"> <ServerProperty Select="HtmlTransform" /> </ScriptQuote><HTML><![CDATA[',']]></HTML> <ScriptQuote NotAddingQuote="TRUE"> <ServerProperty Select="HtmlTrAcceptType"> <Column Name="File_x0020_Type" /> </ServerProperty> </ScriptQuote><HTML><![CDATA[',']]></HTML> <ScriptQuote NotAddingQuote="TRUE"> <ServerProperty Select="HtmlTrHandleUrl"> <Column Name="File_x0020_Type" /> </ServerProperty> </ScriptQuote><HTML><![CDATA[',']]></HTML> <ScriptQuote NotAddingQuote="TRUE"> <ServerProperty Select="HtmlTrProgId"> <Column Name="File_x0020_Type" /> </ServerProperty> </ScriptQuote><HTML><![CDATA[',']]></HTML> <ScriptQuote NotAddingQuote="TRUE"> <ListProperty Select="DefaultItemOpen" /> </ScriptQuote><HTML><![CDATA[',']]></HTML> <ScriptQuote NotAddingQuote="TRUE"> <MapToControl> <Column Name="HTML_x0020_File_x0020_Type" /><HTML>|</HTML> <Column Name="File_x0020_Type" /> </MapToControl> </ScriptQuote><HTML><![CDATA[',']]></HTML> <ScriptQuote NotAddingQuote="TRUE"> <Column Name="HTML_x0020_File_x0020_Type" /> </ScriptQuote><HTML><![CDATA[',']]></HTML> <ScriptQuote NotAddingQuote="TRUE"> <ServerProperty Select="GetServerFileRedirect"> <Field Name="ServerUrl" /><HTML>|</HTML> <Column Name="HTML_x0020_File_x0020_Type" /> </ServerProperty> </ScriptQuote><HTML><![CDATA[',']]></HTML> <ScriptQuote NotAddingQuote="TRUE"> <Column Name="CheckoutUser" /> </ScriptQuote><HTML><![CDATA[',']]></HTML> <ScriptQuote NotAddingQuote="TRUE"> <UserID AllowAnonymous="TRUE" /> </ScriptQuote><HTML><![CDATA[',']]></HTML> <ScriptQuote NotAddingQuote="TRUE"> <ListProperty Select="ForceCheckout" /> </ScriptQuote><HTML><![CDATA[',']]></HTML> <ScriptQuote NotAddingQuote="TRUE"> <Field Name="IsCheckedoutToLocal" /> </ScriptQuote><HTML><![CDATA[',']]></HTML> <ScriptQuote NotAddingQuote="TRUE"> <Field Name="PermMask" /> </ScriptQuote><HTML><![CDATA[')">]]></HTML> <UrlBaseName HTMLEncode="TRUE"> </UrlBaseName> <IfEqual> <Expr1> <LookupColumn Name="Title" /> </Expr1> <Expr2></Expr2> <Then> <Field Name="FileLeafRef" /> </Then> <Else> <Column HTMLEncode="FALSE" Name="Title" Default="(no title)" /> </Else> </IfEqual> <IfEqual> <Expr1> <GetVar Name="ShowAccessibleIcon" /> </Expr1> <Expr2>1</Expr2> <Then><HTML><![CDATA[<img src="/_layouts/images/blank.gif" class="ms-hidden" border=0 width=1 height=1>]]></HTML> </Then> </IfEqual><HTML><![CDATA[</A>]]></HTML> <IfNew Name="Created_x0020_Date"><HTML><![CDATA[<IMG SRC="/_layouts/1033/images/new.gif" alt="New!">]]></HTML> </IfNew> <Field Name="_EditMenuTableEnd" /> </DisplayPattern> </Field> "@ $fieldname = $list.fields.AddFieldAsXml($schema); $list.update();