How to create a 'Link to a Document' Item in a SharePoint Document Library using power shell?

Hi,
I have a document library with "Link to a document" content type. And, I have to add some links into that library using powershell. I have searched enough regarding approachs for adding a link into the library in powershell but i did not get anything yet.
Please provide some approaches and code samples to solve this problem.
Thanks,
Lalit Kumar Mishra 

Adding Site Columns To Content Types Using PowerShell
Adding Site Columns To Content Types Using PowerShell
The below PowerShell script will allow you to add a metadata field that is either contained at the Site Collection level, Site level, or library level, to the specified Content Type.
It also contains some optional lines that you might choose to include or exclude, such as
Setting the visibility of the column in the edit form to hidden
Setting the status of the column to require values
01
function Add-SPContentTypeField
02
03
    <#
04
        .Synopsis
05
            This function will allow you to add a library field to a Content
Type
06
        .Description
07
            This function will add the nominated site column/ library column to a nominated Content
Type within all of the 'Document Libraries'
in the given Site Collection
08
        .Example
09
            C:\PS>Add-SPContentTypeField
–SiteUrl “http://yourdomain.com/sites/Finance –FieldName
"myField" -CTypeAddedTo "myContentType"
10
        .Notes
11
            Name: Add-SPContentTypeField
12
            Author: Petro Margaritis
13
            Last Edit: 19/07/2012
14
            Keywords: Fields, Site Columns, Content Types
15
        .Link
16
            http://thesharepointproject.com/
17
    #>
18
19
    Param (
20
           [parameter(Mandatory=$true)][string]$SiteUrl,
21
           [parameter(Mandatory=$true)][string]$FieldName,
22
           [parameter(Mandatory=$true)][string]$CTypeAddedTo
23
24
25
    $site = Get-SPSite
$SiteUrl
26
27
    # Walk through each site in the site collection
28
    $site | Get-SPWeb
-Limit all | ForEach-Object {
29
30
        write-host
"Checking site:"$_.Title -Foregroundcolor
Green
31
32
        # Go through each document library in the site
33
        foreach
($list in $_.Lists | where
{ $_.BaseTemplate -eq "DocumentLibrary" })
34
35
36
            # Check to see if the library contains the content type we are looking for
37
            if (($list.ContentTypes |
where { $_.Name -eq $CTypeAddedTo
}) -eq $null)
38
39
                Write-Host
"The Content:" $CTypeAddedTo "does not exist in the library:"
$list.Title -Foregroundcolor Red
40
41
            else
42
43
                # Check to see if the library contains the field we are looking for
44
                if (($list.Fields |
where { $_.Title -eq $FieldName
}) -ne $null)
45
46
                    # Get the content type you want to add the field to
47
                    $ct
= $list.ContentTypes[$CTypeAddedTo]
48
                    # Get the column you want to copy
49
                    $field
= $list.Fields[$FieldName]
50
                    # Add the column to the content type
51
                    $ct.Fieldlinks.Add($field)
52
                    $ct.update()
53
54
                    # Add additional column settings
55
                    $ctFieldLinks
= $ct.FieldLinks | Where
{$_.Name -eq $field.Title}
56
                    # OPTIONAL: This will set the column to hidden so that it is not viewable in the edit form
57
                    $ctFieldLinks.Hidden =
$true
58
                    # Set Field to require value
59
                    $ctFieldLinks.Required =
$true
60
                    $ct.Update()
61
                    Write-Host
"The Field:" $field.Title "has been successfully added to the library:"
$list.Title -Foregroundcolor Cyan
62
63
                else
64
65
                    Write-Host
"The Field:" $FieldName "does not exist in the library:"
$list.Title -Foregroundcolor Yellow
66
67
68
69
70
    # Dispose of the site object
71
    $site.Dispose()
72
Simply copy and paste the above into Notepad and save it as a PowerShell file with the name
Add-SPContentTypeField.ps1
view sourceprint?
1
# To run the above function you'll need to do the following - go into the saved location
2
Cd C:\scripts\
3
# Then call it using the dot prefix - note that there is a space between the dots, ..\
4
. .\Add-SPContentTypeField.ps1
5
# Now we can happily run the script like so
6
Add-SPContentTypeField –SiteUrl “http://yourdomain.com/sites/Finance –FieldName
"myField" -CTypeAddedTo "myContentType"

Similar Messages

  • How to create a link to web page (URL) to a billing document

    Hi,
    I have an urgent requirement of creating a link to web page (URL) to a billing document.
    I call the function module "GOS_EXECUTE_SERVICE" with :
    ip_service = 'URL_CREA'
    is_object-objkey = no billing document
    is_object-objtype = 'VBRK'
    is_object-logsys = 'BO'
    ip_rwmode = 'E'
    Then, I enter the title and the address.
    And, I have the message : "The attachment was successfully created".
    But when there's nothing in the attachment list of the billing document.
    (Tha table SOOD contains the record )
    If any one has some idea about his , how to achieve this functionality, can you please help me.
    Thanks
    Virginie
    geoge bush
    Posts: 6
    Questions: 0
    Points: 6
    Registered: 7/9/04
    Re: Attaching a file to a purchase Order from EP6 to R/3 4.6C
    Posted: Jul 13, 2004 2:46 AM      Reply      E-mail this post 
    Hi Somaraju,
    I am also looking for A CODE EXAMPLE TO ATTACH A DOCUMENT TO A AN sap OBJECT E.G. BUS222 AND ISUACCOUNT.
    IF YOU'VE AN Example code that you can email me . it would be great.
    thanks for the help.
    geoge.

    Hey,
    If you are using Portal (not Framework), the below tag will do the trick
    <wcdc:userProfile id="profileUserLink" immediate="false" text="#{security.userDisplayName}" shortDesc="#{security.userDisplayName}"  xmlns:wcdc="http://xmlns.oracle.com/webcenter/spaces/taglib"/>
    -K

  • Set the column order in document library using power shell

    hi all,
     am looking for a power shell script which set the column order in the document  library, when i try to upload a  document.
     ie; i am  uploading a  doc to the doc lib. which has the below columns:
     columnA -   [choice field  - mandatory ]
     columnB -   [lookup field  - mandatory ]
     columnC -   [single line of text  - optional ]
     columnD -   [choice field  - optional ]
     columnE -   [choice field  - mandatory ]
    now when  the end user uploads a   document in my doc lib, i would like to see the mandatory columns takes up the top order and then optional fields.
     columnA
     columnB
     columnE
     columnC
     columnD
    so, is there any script, through which i can set the mandatory columns which will be coming in top and the optional fields as next order

    This is sample PowerShell code to reorder fields in a content type of a list.
    $web = Get-SPWeb http://aissp2013/sites/TestSite
    $list = $web.Lists["MyList"]
    $contentType = $list.ContentTypes | where {$_.Name –eq "MyTestCT"}
    $ctArray = "Title","ColumnA","ColumnB","ColumnD","ColumnC"
    $contentType.FieldLinks.Reorder($ctArray)
    $contentType.Update()
    Blog | SharePoint Learnings CodePlex Tools |
    Export Version History To Excel |
    Autocomplete Lookup Field

  • How to create a link to a dropbox file in an InDesign document?

    I have an InDesign document where I have successfully inserted links to a homepage, but I would also link a file which I keep in my Dropbox. I.e. when people click on the icon/text in the InDesign document, I would like them to be taken to the download page in Dropbox.
    Simply marking the text and >add new hyperlink and copying the download link into the appropriate field hasn't worked so far.
    Thanks a lot for any help!
    Best,
    Marvis

    I just typed my email address in InDesign, and chose Create Hyperlink from the Hyperlink panel menu. Chose Email Address as the type. Added a Subject Line. It shows the email link in the hyperlink list.
    Exported the same way. Works fine in Acrobat. Clicking launches my email application:

  • How to Create a Link to a Discoverer Workbook in Apps11i?-[solved]

    I tried to create a link to a disco workbook in apps 11i using metalink document 278095.1. It seems to be working ok for discoverer which is installed on the same machine as the apps11i is on(because when I clicked on the link which I have created in apps11i, I see a default disco4i welcome page which got installed out of the box with apps11i). But we are using discoverer version 10g which is on a different server. Does anyone has ideas on how to create a link for a disco workbook which is on a different server other than apps11i.
    Discoverer version is 10g
    Apps version is 11.5.10.2
    Thanks in advance

    hi Rod,
    I did as you said and it seems to be connecting to the right server. But I have one more problem. In metalink document it says I have to enter the following in the Parameters text field of Function form in apps:
    workbook=<(workbook identifier from step2) &PARAMETERS=param_parameter name One~Parameter One Value*param_parameter name Two~Parameter Two Value*
    But I dont understand what should I have in place of param_parameter name One~Parameter One Value. Is it the name of the parameter given in discoverer, if so can you give me an example of how to write it. Because when I typed the name of the parameter like &PARAMETERS=Client Id, where client Id is the name of the parameter, it is giving me the following error
    ORA-06502: PL/SQL: numeric or value error
    Thanks for your help

  • Hi, I have Adobe Acrobat Professional.  I need to know how to create multi-links on 300 page docs

    I need to know how to create multi-links on a 300 page document, showing "return to main Menu".  Ideally placed on the bottom right of each page. I have adobe acrobat Professional. 

    Import a picture to be a button, place it, activate HYPERLINK tool, draw a rectangle around the whole button, in the window popping up select the link behaviour, submit with OK.
    Then copy & paste the button object to every page. I don't know whether pasting it on every of the 300 pages can be automated, but if not, it is still done quite fastly.

  • XML Forms: how to create download link

    Hi,
    can anybody tell me, how i can create a download link to a document rid
    in an XML form?
    I can create a link which will open the referenced document, but "right klick
    link | save target as..." will produce an error, since the link is a javascript call.
    Thanks for any help,
    bye,
    Markus Steinberg

    Hi Markus Steinberg,
         i need to create the Download attachement Option In XML Form..
         U got the solution for that above thread..
         If so please tell me how to create? and then how to create multiple Link ?
    Regards
    Thillai J

  • How to create a link to Bar Graph......?

    Hi,
    Can any body tell me how to create a link to a bar graph such that on clicking, it should navigate to specified page in the same application or different application.
    I've written the following Region Source for creating link on Graph. Correct if it is wrong.
    function onDynamicaBarGraphClick(e)
    // Read point name
         name=e.data.Name;
    // Read point value
         value=e.data.YValue;
    // You can add onclick even here using the values name and value
    link='f?p=&APP_ID.:4:'||:app_session||'::::::';
    Thanks in Advance....
    Regards,
    Manoj
    Edited by: user12873839 on Apr 12, 2010 12:11 AM

    I have replied to you in another post. Help Needed : Changing the Color of Bar Graph Dynamically
    Please don't open multiple posts for the same question. Thanks.
    --Manish                                                                                                                                                                                                                                                                                                                                                                                                       

  • How To:  Create a link to gatewayed content (e.g. in email)

    I apologize if this is too basic of a question but I can't find any results after looking for several hours.
    I would like to generate a URL in an email that points to the portal and a specific portlet in the portal. The portlet has limited access rights so the URL should cause the portal to go through the login page and then redirect to the portlet. Can anyone point me to the documentation that describes this or give me an example?
    Thanks in advance!
    Mike

    Using the PTARGS might also solve another difficulty I've encountered passing (dynamic) querystring parms to portlets through the gateway. Your example seems to work great for portlets, but now trying to access a Community page containing a portlet to retain branding elements.
    For portal pages, should the ObjectID be the pageID (i.e PageID=0 for the default page) or is the ObjectID for a community page some other value (where in PlumDB is this stored) ? I changed the ClassIDView to 514 which should indicate a Community Page but it's still not loading my page. Adding to my confusion, the PTCOMMPAGES table stores the PageID as a negative value.
    Here's my example:
    http://portalserver/portal/server.pt/gateway/PTARGS_0_0_0_201_0_514/http%3B/portletserver/ApplicationName/default.aspx?querystring=value
    Any thoughts?
    re: How To: Create a link to gatewayed content (e.g. in email) Posted by Mike Beniston 5/5/05 9:45:40 AM It turned out that I was pretty close.
    If anyone else is interested, here is one way that works.
    The PTARGS are _0_userid(leave at 0)_objectid(of portlet)_communityID(if any)_0_ClassIDView(43 = view for portlet)
    "http://portalserver/portal/server.pt/gateway/PTARGS_0_0_348_208_0_43/http://portletserver/ApplicationName/pagename?querystring arguments.

  • How to create a link between 2 cells in different spreadsheets?

    when using numbers on MacBook Pro/IOS X - how to create a link between 2 cells in different spreadsheets?

    In the cell where you want the duplicate data to appear from another sheet/table do the following:
    type the equal sign ("=") then click the cell you in the sheet table while contents you want to appear in the cell where you just typed the equal sign"
    it reads "The cell I click equals the result of the formula or the contents of the next cell I click"

  • How to create a link to multiple links in pdf file

    how to create a link to multiple links or a button to multiple links in pdf file. this links is goto diferent pages, no web. sorry for my english.

    You can print to PDF from the Print Module .
    Do you have Adobe Acrobat?
    Otherwise install (free) Bullzip Free PDF printer.
    http://www.bullzip.com/

  • How to create a linked server to SQL in Oracle?

    I am able to create a linked server to Oracle in SQL.. But I do not know the steps to create a linked server too SQL in Oracle.
    How to create a linked server to SQL in Oracle? After creating the linked server to SQL, I would like to create triggers in Oracle DB to insert records into SQL DB.

    There are 2 products in Oracle you can use to link to a MS SQl Server. The first one is for free and it is called Database Gateway for ODBC. With a suitable 3rd party ODBC driver you can connect to any foreign database. The second gateway is our commercial gateway and it is called Oracle Database Gateway for MS SQL Server. It is designed for MS SQl Server connections and more powerful then Dg4ODBC. It know how to map a lot of Oracle functions to SQL Server equivalents and you can also use it to directly call SQL Server procedures or functions. This dedicated SQL server gateway is also able to participate in distributed transactions.
    But again, this is a commercial gateway and you have to purchase a license for that second gateway, the Database Gateway for MS SQl Server.
    - Klaus

  • How to create database link between oracle and SQL Server

    Hello Everyone,
    Here i have Oracle Database 9i and SQL Server 2005 databases.
    I have some tables in sql server db and i want to access from Oracle.
    How to create a database link between these two servers
    Thanks,

    Thanks for Everyone,
    I was struggle with this almost 10 days....
    I created Database link from Oracle to SQL Server
    Now it is fine.........
    Here i am giving my servers configuration and proceedure how i created the db link...@
    Using Generic Connectivity (HSODBC) we can create db link between Oracle and SQL server.
    Machine (1)
    DB Version : Oracle 9.2.0.7.0
    Operating System : HP-UX Itanuim 64 11.23
    IP : 192.168.0.31
    Host : abcdbt
    Machine (2)
    Version : SQL Server 2005
    Operating System : Windows server 2003 x86
    IP : 192.168.0.175
    Host : SQLDEV1
    User/PW : sa/abc@123! (Connect to database)
    Database : SQLTEST (exsisting)
    Table : T (“ T “ is the table existing in SQLTEST database with 10 rows)
    Prerequisites in Machine (2):
    a)     Oracle 10g software
    b)     User account to access SQL Server database (sa/abc@123!)
    c)     Existing SQL Server Database (SQLTEST)
    d) Tables (testing purpose) (T)
    Steps:
    1)     Install Oracle 10.2.0.1 (Only SW,No need of database) *(Machine 2)*
    2)     Create a DSN where your windows Oracle 10g SW resides *(Machine 2)*
    Control panel >> Administrative Tools >> Data Source (ODBC) >> System DSN ADD
    You can follow this link also.....
    http://www.databasejournal.com/features/oracle/article.php/3442661/Making-a-Connection-from-Oracle-to-SQL-Server.htm
    I created DSN as
    DSN name : SQLTEST
    User : SA/abc@123! (Existing user account)
    Host : 192.168.0.175 (machine 2)
    Already I have 1 database in SQL Server with the name SQLTEST
    You can create DSN with different name also (not same as db name also)
    3)     Create a hsodbc init file in $ORACLE_HOME\hs\admin *(Machine 2)*
    Create init<DSN NAME> file
    Ex: initSQLTEST
    Copy inithsodbc to initSQLTEST
    And edit
    initSQLTEST file
    HS_FDS_CONNECT_INFO = SQLTEST    <DSN NAME>*
    HS_FDS_TRACE_LEVEL = OFF*
    save the file....@
    4)     Configure Listener.ora *(Machine 2)*
    LISTENER_NEW =
    (DESCRIPTION_LIST =
    (DESCRIPTION =
    (ADDRESS_LIST =
    (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.0.175)(PORT = 1525))
    SID_LIST_LISTENER_NEW =
    (SID_LIST =
    (SID_DESC =
    (SID_NAME = SQLTEST) *+< Here SQLTEST is DSN NAME >+*
    (ORACLE_HOME = G:\oracle 10g\oracle\product\10.2.0\db_1)
    (PROGRAM = hsodbc))
    (SID_DESC =
    (SID_NAME = PLSExtProc)
    (ORACLE_HOME = G:\oracle 10g\oracle\product\10.2.0\db_1)
    (PROGRAM = extproc) )
    :> lsnrctl start LISTENER_NEW
    5)     Configure tnsname.ora *(Machine 2)*
    SQLTEST11 =
    (DESCRIPTION =
    (ADDRESS_LIST =
    (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.0.175)(PORT = 1525))
    (CONNECT_DATA =
    (SERVER = DEDICATED)
    (SERVICE_NAME = SQLTEST))
    (HS=OK)
    :> tnsping SQLTEST11
    If No errors then conti….
    6)     Configure a file *(Machine 1)*
    Cd $TNS_ADMIN ($ORACLE_HOME/network/admin)
    Create a file
    $ vi TEST_abcdbt_ifile.ora
    something=
    (DESCRIPTION=
    (ADDRESS=(PROTOCOL=tcp)(HOST =192.168.0.175) (PORT=1525))
    (CONNECT_DATA=
    (SID=SQLTEST))
    (HS=OK)
    $ tnsping something
    $ sqlplus system/manager
    Your connected to Oracle database *(machine 1)*
    create database link xyz connect to “sa” identified by “abc@123!” using ‘SOMETHING’;
    select * from t@xyz;10 rows selected.
    Thanks,
    Edited by: ram5424 on Feb 10, 2010 7:24 PM

  • How to create database link from oracle to sql server

    Please help with how to create database link from oracle to sql server
    Best regards,
    Vishal

    Please help with how to create database link from oracle to sql server
    Best regards,
    Vishal
    Hi Vishal,
    I found a lof of information regarding how to create a database link from Oracle to SQL Server, please see:
    https://www.google.co.in/?gws_rd=cr&ei=vd3XUvGFO8TgkAXqlYCADg#q=how+to+create+database+link+from+oracle+to+sql+server
    We discuss SQL Server related issue in this forum. If you have any more question regarding Oracle, please post it in Oracle communities forum for better support.
    Regards,
    Elvis Long
    TechNet Community Support

  • How to create database link between oracle9i database and oracle10g

    How to create database link between oracle9i database and oracle10g
    oracle9i database name "Prod" windows server 2003 ( 172.x.x.x)
    oracle10g database name "TEST" sun solaris 9 (165.x.x.x.x)
    Please help me on this

    For connections between 10.2 and 9.2 the 9.2 end MUST be at 9.2.0.4 or higher. Connections between 10.2 and 9.2.0.1, 9.2.0.2 or 9.2.0.3 are not supported.
    Connections between 10.2 and 9.0.1 was never been supported.
    Cheers !!!!
    Bhupinder

Maybe you are looking for

  • "Load files into Photoshop layers" fails to complete CS6

    Hi all, Hoping someone can help with the folling problem with Photoshop & Bridge CS6 When in Bridge, after selecting 6 images (CR2) using the command TOOLS>LOAD FILES INTO PHOTOSHOP LAYERS the first file will load into Photoshop, Photoshop will then

  • Facebook notifications on taskbar

    I cannot seem to clear my facebook notifications from my taskbar once I have looked at them in facebook.  The icon still stays on the taskbar, just without the astrick next to it.  Please help!

  • Save as excel in numbers 3.0?

    I can't save a copy of a numbers spreadsheet as an Excel spreadsheet.  I was able to before 3.0 update.  Anyone have this issue also? Help!

  • Acrobat X and Word 2010 missing text

    Has anyone found a solution yet to dropping text box text when converting a Word 2010 document via the PDF print driver? There are various posts on this topic but no real solution. Most resolve by using the "Save as Adobe PDF", which works but doesn'

  • OS 10.2.1 upgrade and bluebooth issues

    Since the recent upgrade the bluetooth connection to my car audio keeps falling out. Also when it reconnects the audio works but the data on the song, artist etc is not displayed on the car media screen. Has anyone else encountered this problem?