Get_file_list to list content of UNIX directory

Hi all
I am trying to list the files in a UNIX directory using the get_file_list action. Not getting anything back, but action is not reporting error.
In the folder configuration box i have used all combinations of \ and / but none do anything. I can list files on our Mii server using
server\share but this is a windows machine.
I think i have a couple of options
1. get FTP set up on UNIX server and use the FTP_get_file_list action and move files to Mii server for processing.
2. get something like SAMBA set up on UNIX to allow windows style file sharing.
Any other ideas out there?

Hi Les,
Set the "Get_File_List_0" with the following parameters:
Folder: "web://PROJECT"
Mask: "*" for list all files
http://wbhelp.sap.com/manufacturing/xmii_120/en/44/7108DF9EA03ABEE10000000A155369/content.htm (for more details)
Or use a XMLQuery
server://XMII/Catalog?Mode=ListFolders&Folder=[Param.1]&Content-type=text/xml
[Param.1] = PROJECT
Hope this help.
Danilo Santos

Similar Messages

  • List contents of a directory of the J2EE engine

    Hello,
    I have a requirement to list the contents of a directory of the J2EE engine of the portal. For example let's assume that there are five files in directory /user/sap/<SID>/JC02/j2ee/cluster/server0/some_directory_name. I want to be able to list the names of the five files that are stored in this directory. I have written some java code that will list the entries in a given directory and that is not the problem. The problem is that when I run this on the portal j2ee I get the message back: "You are not authorized to view the content of the requested directory. Details: Directory listing is not allowed on this server".
    I know I could store these files in KM and it would be very simple to do this but due to security concerns I am told by the project management here that KM is not an option for this application.
    Any suggestions or help would be greatly appreciated.
    Thanks,
    Bert

    Hi,
    Are you testing this application which has super admin rigths?
    You can integrate this file system in KM and write a simple java webdynpro code with KM apis which would display the file name. I dont think there could be security problem with this option.
    Regards,
    Jigar Oza

  • FM to GET file listing of a UNIX directory.

    Hello everyone,
    Please can anyone provide me a function module that can return to me ALL the files found inside a UNIX directory. I have tried FM EPS_GET_DIRECTORY_LISTING but I can't seem to provide the correct parameter.

    Ryan,
    check this program,
    REPORT ZFTPSAP LINE-SIZE 132.
    DATA: BEGIN OF MTAB_DATA OCCURS 0,
    LINE(132) TYPE C,
    END OF MTAB_DATA.
    DATA: MC_PASSWORD(20) TYPE C,
    MI_KEY TYPE I VALUE 26101957,
    MI_PWD_LEN TYPE I,
    MI_HANDLE TYPE I.
    START-OF-SELECTION.
    *-- Your SAP-UNIX FTP password (case sensitive)
    MC_PASSWORD = 'password'.
    DESCRIBE FIELD MC_PASSWORD LENGTH MI_PWD_LEN.
    *-- FTP_CONNECT requires an encrypted password to work
    CALL 'AB_RFC_X_SCRAMBLE_STRING'
         ID 'SOURCE' FIELD MC_PASSWORD ID 'KEY' FIELD MI_KEY
         ID 'SCR' FIELD 'X' ID 'DESTINATION' FIELD MC_PASSWORD
         ID 'DSTLEN' FIELD MI_PWD_LEN.
    CALL FUNCTION 'FTP_CONNECT'
         EXPORTING
    *-- Your SAP-UNIX FTP user name (case sensitive)
           USER            = 'userid'
           PASSWORD        = MC_PASSWORD
    *-- Your SAP-UNIX server host name (case sensitive)
           HOST            = 'unix-host'
           RFC_DESTINATION = 'SAPFTP'
         IMPORTING
           HANDLE          = MI_HANDLE
         EXCEPTIONS
           NOT_CONNECTED   = 1
           OTHERS          = 2.
    CHECK SY-SUBRC = 0.
    CALL FUNCTION 'FTP_COMMAND'
         EXPORTING
           HANDLE = MI_HANDLE
           COMMAND = 'dir'
         TABLES
           DATA = MTAB_DATA
         EXCEPTIONS
           TCPIP_ERROR = 1
           COMMAND_ERROR = 2
           DATA_ERROR = 3
           OTHERS = 4.
    IF SY-SUBRC = 0.
      LOOP AT MTAB_DATA.
        WRITE: / MTAB_DATA.
      ENDLOOP.
    ELSE.
    do some error checking.
      WRITE: / 'Error in FTP Command'.
    ENDIF.
    CALL FUNCTION 'FTP_DISCONNECT'
         EXPORTING
           HANDLE = MI_HANDLE
         EXCEPTIONS
           OTHERS = 1.  
    DATA:
    l_pcfile LIKE sapb-sappfad, "Desktop file & path
    l_serfil LIKE sapb-sappfad. "Server File & path
    l_pcfile = 'D:\Data\temp\input.txt'.
    l_serfil = '/tmp/output.txt' .
    CALL FUNCTION 'ARCHIVFILE_CLIENT_TO_SERVER'
    EXPORTING
    path = l_pcfile
    targetpath = l_serfil
    EXCEPTIONS
    error_file = 1
    OTHERS = 2.
    Don't forget to reward if useful.....

  • Getting list of files from Unix directory inclding files frm sub-directries

    Hi All,
            I am trying to use Fm 'SUBST_GET_FILE_LIST'  and
    'RZL_READ_DIR_LOCAL' for getting a list of all files in a Unix directory including files from sub-directories.
    In the first case I am getting an Exception called 'Access Error'
    and when I use the 2nd FM, I am not getting any output.
    Is there a special way to use these FMs.
    Kindly help.
    Regds,
    Shweta

    [url http://java.sun.com/developer/JDCTechTips/2003/tt0122.html#1]READING FILES FROM JAVA ARCHIVES (JARS)

  • I can't open a certain website, it says "Directory Listing Denied This Virtual Directory does not allow contents to be listed." how can i solve my problem, please help me guys...

    "Directory Listing Denied
    This Virtual Directory does not allow contents to be listed."

    URL of that website?

  • Information Broadcast Email File - Where is the file in Unix directory?

    Hi,
    I am using Information Broadcasting to email the BI report.   We use Unix as the application server.
    In transaction SOSV, I can get detailed information on the file (attachment) and the send status.  There is a requirement to encrypt the file in Unix server.   Does anyone know where the file resides in Unix when the report is generated from Information Broadcasting?   What's the Unix directory?
    Any information would be appreciated.
    Thank you.
    Rebecca

    I added the path of the servlet.jar to the CLASSPATH. Now my modified
    file content is as follows:
    WINDOWS 2000 Environmental variable changes:(CLASSPATH)
    C:\Program Files\PhotoDeluxe BE 1.1\AdobeConnectables;%JAVA_HOME%\bin;%JAVA_HOME%\jre\bin;C:\jakarta-tomcat-4.1.12\common\lib\servlet.jar
    AUTOEXEC.BAT:
    set path=%path%;c:\onnet32
    SET PATH=C:\jdk1.3.1\bin;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;
    SET JAVA_HOME=C:\jdk1.3.1
    SET CATALINA_HOME=C:\jakarta-tomcat-4.1.12
    SET CLASSPATH=.;%JAVA_HOME%\bin;%JAVA_HOME%\jre\bin;C:\jakarta-tomcat-4.1.12\common\lib\servlet.jar
    With this I am executing the command: javac test.java. However, it is still giving lot of error messages
    All the messages are 'cannot resolve symbol' associated with the Servlet class, Servlet Request, Server Exception etc. In the very first error message it states that: 'package javax.servlet does not exist'.
    I would appreciate any help. Thanks in advance.

  • How to show direcotry content in Unix

    Hey
    Greeting,have a simple question for Java Gurus,I am using Tomcat and servlets for my projects running on NT platform connecting to Oracle/Sybase servers on Unix boxes my problem is I want to show directory contents on unix box.. show directory name , filesize, date etc on browser to select file and load into database.
    Please help me with code and ideas, partly or fully.
    Thanks in advance guys.

    If your servlet container is running on NT, the only way to show something on the remote unix is to telneting that unix box. You can look on the telnet task of Ant tool for examples. http://jakarta.apache.org/

  • CF scripts not consistently listing contents of folder

    Hello.
    I upload multiple types of files to the server. Sometimes
    they are folders, word docs, ppts, pdfs or xls files. There is a
    script that runs that is supposed to list everything that I have
    uploaded into a directory. The problem is, it does not work
    consistently. Sometimes it will display all files, subdirectories,
    files within, sometimes it will say that nothing is there. I am not
    sure why it will work with some files/folders, and won't with
    others. Some folders work great, some don't. It may be a
    permissions problem, I'm not sure...
    Here's an example - I have a folder and a word document in
    the "root" files directory. When viewing in the browser, it
    displays "No Files Found". Then if I move a ppt back a directory -
    to the root, all 3 items (word doc, folder and ppt) will then show
    in the browser. For some reason the ppt triggers everything to
    suddenly show. This "magical" ppt does not work for every directory
    though. Some items just won't show no matter what.
    Here's a sample script that lists the contents of the
    directory:
    <cfinclude template="../usercheck.cfm">
    <cfparam name="URL.module" default="">
    <cfparam name="URL.file" default="">
    <cfparam name="URL.action" default="">
    <HTML>
    <HEAD>
    <TITLE>Title</TITLE>
    <META HTTP-EQUIV="Content-Type" CONTENT="text/html;
    charset=iso-8859-1">
    <link href="../links.css" rel="stylesheet"
    type="text/css">
    <!-- End Preload Script -->
    <style type="text/css">
    <!--
    .style3 {color: #FFFFFF; font-weight: bold; }
    .style6 {font-size: 10px}
    -->
    </style>
    </HEAD>
    <BODY BGCOLOR=#FFFFFF LEFTMARGIN=0 TOPMARGIN=0
    MARGINWIDTH=0 MARGINHEIGHT=0 ONLOAD="preloadImages();">
    <a href="/index.html"><img src="/Images/graphic.gif"
    width="169" height="84" border="0"></a>
    <br>
    <cfset pathn =
    "#getDirectoryFromPath(cgi.PATH_TRANSLATED)#files">
    <CFIF (URL.file IS NOT '')>
    <CFDIRECTORY ACTION="LIST"
    DIRECTORY="#pathn##urldecode(url.module)#"
    NAME="FileCheck"
    FILTER="#URL.file#">
    <cfif URL.action eq "Delete">
    <CFIF FileCheck.RecordCount GT 0>
    <cffile file="#pathn##urldecode(url.module)##URL.file#"
    action="delete">
    <cflocation
    url="module.cfm?module=#URLEncodedFormat(url.module)#">
    </CFIF>
    <cfelse>
    <CFIF FileCheck.RecordCount GT 0>
    <!--- <cfhttp
    method="Get"
    url="#getdirectoryfrompath(pathn)##URL.file#"
    path="#pathn#"
    file="#URL.file#"> --->
    <CFHEADER
    NAME="content-disposition"
    VALUE="attachment; filename=#URL.file#">
    <CFCONTENT type="application/unknown"
    file="#pathn##URLdecode(url.module)##URL.file#"
    DeleteFile="No"></CFCONTENT>
    </CFIF>
    </cfif>
    <cfelse>
    <CFDIRECTORY ACTION="LIST"
    DIRECTORY="#pathn##urldecode(url.module)#"
    NAME="dirlist">
    <table width="487" border="0" align="center">
    <tr bgcolor="#004B8D">
    <td width="479" height="36"><span
    class="style3"> Physician Modules
    </span></td>
    <td></td>
    </tr>
    <cfif #dirlist.recordcount# gt 2>
    <CFOUTPUT QUERY="dirlist">
    <CFIF type IS 'File'>
    <tr bordercolor="##D5EBFF" bgcolor="##D5EBFF">
    <td width="479" bordercolor="##D5EBFF" bgcolor="##F4FAFF"
    class="links">
    <span class="style6"><a
    href="#cgi.SCRIPT_NAME#?module=#URLEncodedFormat(url.module)#&file=#name#"> #left(name,le n(name)-4)#</a></span>
    </td>
    <td width="50" bgcolor="##FFFFFF">
    <cfswitch expression="#right(name,3)#">
    <cfcase value="xls">
    <cfset imagesrc="/Images/excel.gif">
    </cfcase>
    <cfcase value="pdf">
    <cfset imagesrc="/Images/pdf.gif">
    </cfcase>
    <cfcase value="doc">
    <cfset imagesrc="/Images/word.gif">
    </cfcase>
    <cfcase value="ppt">
    <cfset imagesrc="/Images/powerpoint.gif">
    </cfcase>
    <cfdefaultcase>
    <cfset imagesrc="/Images/unknown.gif">
    </cfdefaultcase>
    </cfswitch>
    <div align="center"><img src="#imagesrc#" width="31"
    height="27"></div>
    </td>
    </tr>
    <cfelseif type eq 'Dir'>
    <cfif ((name neq "." ) AND (name neq "..")) >
    <cfset tempname = #url.module# & "" & #name#>
    <tr bordercolor="##D5EBFF" bgcolor="##D5EBFF">
    <td bordercolor="##D5EBFF" bgcolor="##F4FAFF"
    class="links"><a
    href="#CGI.SCRIPT_NAME#?module=#URLEncodedformat(tempname)#">#name#</a></td>
    <td bgcolor="##FFFFFF"
    class="links">Directory</td>
    </tr>
    </cfif>
    </cfif>
    </cfoutput>
    <cfelse><!--- <cfif #dirlist.recordcount# lt
    2> --->
    <tr bordercolor="#D5EBFF" bgcolor="#D5EBFF">
    <td bordercolor="#D5EBFF" bgcolor="#F4FAFF"
    class="links">
    <span class="style6">No Files
    Found</a></span></td>
    <td bgcolor="#FFFFFF"> </td>
    </tr>
    </cfif>
    </table>
    </cfif>
    <table width="100%" border="0" cellpadding="0"
    cellspacing="0" class="links">
    <tr>
    <td height="50" align="center" valign="middle"
    class="links">
    <cfinclude template="../navmenu.cfm">
    </td>
    </tr>
    </table>
    </BODY>
    </HTML>
    Thanks for your help.

    You are not able to do this with CF directly.  It would be a function of the web server.
    You could move all documents other than .cfm into a folder outside of the web root, then use tags such as cfcontent to deliver those files programatically (as often happens when you download software off of a website now days).  However I suspect this isn't what you are looking for.  Just in case here is a quick example of how you may do the force download of document from outside root:  http://www.aliaspooryorik.com/blog/index.cfm/e/posts.details/post/force-file-download-27

  • Number of files in unix directory

    Hi All,
    anyone can help me, how can I get the number of files in specific unix directory and number of files in each
    sub-directory inside that directory?
    Thank You

    Hi,
    Use the following program which will list the files on a unix system.
    Put/modify the logic for getting the file count. (play around)
    REPORT ZUNIXFILES MESSAGE-ID Z1
                      NO STANDARD PAGE HEADING
                      LINE-COUNT 65
                      LINE-SIZE  132.
    Global Variables.                                                   *
    DATA: BEGIN OF TABL OCCURS 0,
              LINE(2000),
          END OF TABL.
    DATA: PARCOM_LOC LIKE RS37A-LINE.
    DATA: SIZE(10) TYPE C,
          LINE     LIKE TABL-LINE,
          SUM(16)  TYPE C.
    DATA: FILE LIKE RS37A-LINE.
    DATA: PATH(255) TYPE C.
    Parameters.                                                       *
    SELECTION-SCREEN SKIP 2.
    PARAMETERS: PARCOM LIKE RS37A-LINE.
    *AT SELECTION-SCREEN.
    AT SELECTION-SCREEN.
      CONDENSE: PARCOM NO-GAPS.
    *TOP-OF-PAGE.
    TOP-OF-PAGE.
      PERFORM WRITE_PAGE_HEADING.
    *INITIALIZATION.
    INITIALIZATION.
      PARCOM = '/usr/sap/*'.               "Only default value
    *START-OF-SELECTION.
    START-OF-SELECTION.
      PERFORM MAKE_LOC.
      PERFORM COLLECT_DATA.
      PERFORM FILE_LIST.
    *AT LINE-SELECTION.
    AT LINE-SELECTION.
      CLEAR FILE.
      FILE = SY-LISEL+55.
      REPLACE '|' WITH SPACE INTO FILE.
      IF SY-LISEL+1(1) = 'd'.
         PATH = FILE.
         PATH+200 = '/*'.
         CONDENSE PATH NO-GAPS.
         SUBMIT ZUNIXFILES
           WITH PARCOM = PATH
           AND RETURN.
      ENDIF.
      SUBMIT ZBROWSEFILE            "Call the browse program
         WITH PARCOM = FILE
         AND RETURN.
    FORM MAKE_LOC.                                                      *
    FORM MAKE_LOC.
      CLEAR: PARCOM_LOC.
      PARCOM_LOC(7)    = 'ls -ld '.
      PARCOM_LOC+7(45) = PARCOM.
    ENDFORM.
    FORM COLLECT_DATA.                                                  *
    FORM COLLECT_DATA.
      REFRESH TABL.
      CALL 'SYSTEM' ID 'COMMAND' FIELD PARCOM_LOC
                    ID 'TAB'     FIELD TABL-SYS.
    ENDFORM.
    FORM FILE_LIST.                                                   *
    FORM FILE_LIST.
      FORMAT RESET.
      CLEAR SUM.
      LOOP AT TABL.
        CLEAR LINE.
        LINE = TABL-LINE.
        WRITE /2 LINE.
        PERFORM VERTICAL_LINES.
        SUM = SUM + SIZE.
      ENDLOOP.
      WRITE:/1(132) SY-ULINE.
    ENDFORM.
    FORM WRITE_PAGE_HEADING.                                          *
    FORM WRITE_PAGE_HEADING.
      WRITE:/1(132) SY-ULINE.
      PERFORM VERTICAL_LINES.
      FORMAT INTENSIFIED.
      WRITE: /2(131) SPACE COLOR 1.
      WRITE:  2    SY-DATUM COLOR 1.
      WRITE: 35 'File Manager' COLOR 1.
      PERFORM VERTICAL_LINES.
      WRITE:/1(132) SY-ULINE.
      PERFORM VERTICAL_LINES.
      FORMAT INTENSIFIED.
      WRITE: /2(131) SPACE  COLOR 3.
      PERFORM VERTICAL_LINES.
      FORMAT RESET.
      WRITE:/1(132) SY-ULINE.
    ENDFORM.
    FORM VERTICAL_LINES.                                              *
    FORM VERTICAL_LINES.
      PERFORM WRITE_VLINE USING ' '  1.
      PERFORM WRITE_VLINE USING ' '  132.
    ENDFORM.
    WRITE_VLINE.                                                      *
    FORM WRITE_VLINE USING MODE POS.
      IF MODE NE 'T'.
        FORMAT INTENSIFIED.
      ENDIF.
      POSITION POS.
      WRITE: SY-VLINE.
      IF MODE NE 'T'.
        FORMAT RESET.
      ENDIF.
    ENDFORM.

  • TDMS List Contents returns groups for previously opened file

    I get a directory listing of TDMS files, then loop through file by file, using TDMS List Contents to retreive the groups found in the particulare file.  I open each file, list its contents, and close it before opening and listing the next file.
    If a file has no groups, TDMS List Contents returns the group list from the previous file.
    How can I prevent this behavior?

    Unfortunately, the original VIs were developed on a Classified system, so I can't include them here.  However, I've created similar VIs that demonstrate the equivalent problem.
    Run the 'create files' VI to generate appropriate TDMS files, and the 'list contents' VI to demonstrate the issue.
    Note that these VI's were created in LabVIEW 9 SP1 (Version 9.0.1 32-bit).
    Thanks for taking a look it this!!
    Attachments:
    TDMS Issue Create Files.vi ‏18 KB
    TDMS Issue List Contents.vi ‏13 KB

  • Finder (Snow Leopard 10.6.8) taking long time to load contents of any directory. Please help?

    In my macbook pro 5,2 snow leopard (10.6.8), Finder taking long time to load contents of any directory. Please help?
    I have already tried to spotlight re-indexing but it did not help. I am hardly able to work on it, almost for each directory I browse its keeps on spinning for 1min.

    Download iTunes from Apple's web site and install it.  Don't use Software Update.

  • How to check whether a file is present in the UNIX directory of app. server

    Hi,
            I am creating files in the UNIX directory in the application server using :
                       CONCATENATE '/sapmnt/RD1/interfaces/client670/'
                       p_fname '.CSV' INTO w_filename.
               OPEN DATASET w_filename FOR OUTPUT IN TEXT MODE.
              LOOP AT t_output1.
                      TRANSFER t_output1 TO w_filename.
              ENDLOOP.
             CLOSE DATASET w_filename.
    I am unable to check whether a file with the same name exists or not. How to check the duplicate state of the file.

    You can use the following fm
    RZL_READ_FILE
    or
    use OPEN DATASET FOR INPUT.

  • How to  add a folder in unix directory?

    how to  add a folder in unix directory?
    /usr/zz00/zz/mm/..
    i need one more folder
    /usr/zz00/zz/mm/addfolder/text.txt..

    No way with pure ABAP. Either contact your unix adminstration or create a logical system command in SM69/SM49 which can be called via call function 'SXPG_CALL_SYSTEM'

  • Search for documents using External Data on list content type

    hi,
    say we have clients in an external database, we create the external content type for use in sharepoint 2013
    we create two content types, Quote and Order for use in a library
    we create a document library that uses the above content types
    we then add a column for the external data ( in this case Client Name- but also include ID) , we have the option to copy to content type selected. so now library shows 'Client' and 'Client:ID'
    I believe that column gets added to  list content types based on the 2 document content types.
    so we have list items , which have a document , a content type and a piece of data from the external LOB system.
    now that is fine, works great, however, how do you configure the content search web part to return documents based on the piece of external data - ie client:ID ? or Client Name ?
    I can map the client:ID to one of the Int00 managed properties and crawl etc - but do not see a way to use that to return documents
    any help would be appreciated :)
    thanks
    MrP

    Create a scopr with that in managed properies and then u can get results from  external sources

  • Deploying a Reusable Workflow to a List Content Type using PowerShell

    We have a situation where deployment of a reusable workflow for a site content type cannot be completed through the web interface due to the number of libraries where the content type is in use (time-out on deploy and update).
    It was hoped that this could be accomplished with PowerShell but the method of deploying to a list content type appears to be different than it is to a list (all content types).
    The below snippet works fine for a list / all content types:
    function AddWorkflowToLibraries ($SiteCollection, $ctName, $WfName, $WfAssociationName)
    $site = Get-SPSite $SiteCollection
    [Guid]$wfTemplateId = New-Object Guid
    #Step through each web in site collection
    $site | Get-SPWeb -limit all | ForEach-Object {
    $web = $_
    $_.Lists | ForEach-Object{
    if($_.AllowContentTypes -eq $true)
    if($_.ContentTypes.Item("$ctName") -ne $null)
    write-host "Enabling workflow on" $_.Title "in" $_.ParentWebUrl
    $ct = $_.ContentTypes[$ctName]
    $culture = New-Object System.Globalization.CultureInfo("en-US")
    $template = $site.RootWeb.WorkflowTemplates.GetTemplateByName($WfName, $culture)
    if($template -ne $null)
    $tasklist = "Tasks"
    $historylist = "Workflow History"
    if(!$web.Lists[$historylist])
    $web.Lists.Add($historylist, "A system library used to store workflow history information that is created in this site. It is created by the Publishing feature.",
    "WorkflowHistory", "00BFEA71-4EA5-48D4-A4AD-305CF7030140", 140, "100")
    if (!$web.Features["00BFEA71-4EA5-48D4-A4AD-305CF7030140"]) {
    Enable-SPFeature -Identity WorkflowHistoryList -Url $web.Url
    $wfHistory = $web.Lists[$historylist]
    $wfHistory.Hidden = $true
    $wfHistory.Update()
    if(!$web.Lists[$tasklist])
    $web.Lists.Add($tasklist, "This system library was created by the Publishing feature to store workflow tasks that are created in this site.", "WorkflowTasks", "00BFEA71-A83E-497E-9BA0-7A5C597D0107", 107, "100")
    $association = [Microsoft.SharePoint.Workflow.SPWorkflowAssociation]::CreateListAssociation($template, $wfName, $web.Lists[$tasklist], $web.Lists[$historylist])
    $association.AllowManual = $true
    $_.AddWorkflowAssociation($association)
    $_.Update()
    else
    Write-Error "Workflow Template not found"
    AddWorkflowToLibraries <Site Name> <Content Type Name> <Workflow Template Name> <Association Name>
    However changing the association as follows causes the script to still execute without a problem but the workflow doesn't appear for the content and the associations collection is empty:
    function AddWorkflowToLibraries ($SiteCollection, $ctName, $WfName, $WfAssociationName)
    $site = Get-SPSite $SiteCollection
    [Guid]$wfTemplateId = New-Object Guid
    #Step through each web in site collection
    $site | Get-SPWeb -limit all | ForEach-Object {
    $web = $_
    $_.Lists | ForEach-Object{
    if($_.AllowContentTypes -eq $true)
    if($_.ContentTypes.Item("$ctName") -ne $null)
    write-host "Enabling workflow on" $_.Title "in" $_.ParentWebUrl
    $ct = $_.ContentTypes[$ctName]
    $culture = New-Object System.Globalization.CultureInfo("en-US")
    $template = $site.RootWeb.WorkflowTemplates.GetTemplateByName($WfName, $culture)
    if($template -ne $null)
    $tasklist = "Tasks"
    $historylist = "Workflow History"
    if(!$web.Lists[$historylist])
    $web.Lists.Add($historylist, "A system library used to store workflow history information that is created in this site. It is created by the Publishing feature.",
    "WorkflowHistory", "00BFEA71-4EA5-48D4-A4AD-305CF7030140", 140, "100")
    if (!$web.Features["00BFEA71-4EA5-48D4-A4AD-305CF7030140"]) {
    Enable-SPFeature -Identity WorkflowHistoryList -Url $web.Url
    $wfHistory = $web.Lists[$historylist]
    $wfHistory.Hidden = $true
    $wfHistory.Update()
    if(!$web.Lists[$tasklist])
    $web.Lists.Add($tasklist, "This system library was created by the Publishing feature to store workflow tasks that are created in this site.", "WorkflowTasks", "00BFEA71-A83E-497E-9BA0-7A5C597D0107", 107, "100")
    $association = [Microsoft.SharePoint.Workflow.SPWorkflowAssociation]::CreateListContentTypeAssociation($template, $wfName, $web.Lists[$tasklist], $web.Lists[$historylist])
    $association.AllowManual = $true
    $_.ContentTypes[$ctname].AddWorkflowAssociation($association)
    $_.ContentTypes[$ctname].Update()
    else
    Write-Error "Workflow Template not found"
    AddWorkflowToLibraries <Site Name> <Content Type Name> <Workflow Template Name> <Association Name>
    The only change is:
    $association = [Microsoft.SharePoint.Workflow.SPWorkflowAssociation]::CreateListContentTypeAssociation($template, $wfName, $web.Lists[$tasklist], $web.Lists[$historylist])
    $association.AllowManual = $true
    $_.ContentTypes[$ctname].AddWorkflowAssociation($association)
    $_.ContentTypes[$ctname].Update()
    But unlike the list version, the association doesn't appear to be saved and no error is generated.
    Is anyone aware of what may cause this or have an example in C# that may explain something my script is missing?

    Hi Garry,
    After you associate the workflow to the content type, you should update the update the content type using
    $ct.UpdateWorkflowAssociationsOnChildren($true,$true,$true,$false)
     method.
    Here is the completed script:
    [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint")
    $site=Get-SPSite "http://serverName"
    $web=$site.OpenWeb()
    $list=$web.Lists["ListC"]
    $taskList=$web.Lists["Tasks"]
    $historyList=$web.Lists["Workflow History"]
    $ct=$list.ContentTypes["Link"]
    $culture=New-Object System.Globalization.CultureInfo("en-US")
    $wfTemplate=$web.WorkflowTemplates.GetTemplateByName("Three-State",$culture)
    $associationWF=[Microsoft.SharePoint.Workflow.SPWorkflowAssociation]::CreateListContentTypeAssociation($wfTemplate, "myThreeStateWF",$taskList,$historyList)
    $ct.WorkflowAssociations.Add($associationWF)
    $ct.UpdateWorkflowAssociationsOnChildren($true,$true,$true,$false)
    Here is a demo about how to update it using C#
    http://www.thorntontechnical.com/tech/sharepoint/sharepoint-2010-associate-workflow-to-content-type-in-a-feature
    Wayne Fan
    TechNet Community Support

Maybe you are looking for

  • How to construct the component tree in my custom component?Help!

    Hi, i am writing a custom component like this: public class HtmlCategory extends HtmlPanelGrid      public void processRestoreState(javax.faces.context.FacesContext context,             java.lang.Object state)           setColumns(1);           HtmlC

  • BW Report - Rounding Quantities

    Hi: I have a report with a quantity field.  When I view the quantity in the cube the value contains 3 decimals. However, when I run the query in Bex or Web, the quantity is rounded off and my decimals show as zero. Example:  Invoice Quantity = 168.65

  • Oracle errors while running script

    When i run my script i get the some error: errrors are listed below: ORA-04045: errors during recompilation/revalidation of COLLECTION.STEP ORA-04020: deadlock detected while trying to lock object COLLECTION.COL_CUSTOMER_REC

  • Why doesnt my volume work but my ringer does?

    Today from a minute to another my volume just stopped working,but meanwhile my ringer still works,what should i do?

  • Can't update to iTunes 10.4.1

    Hi, I am running iTunes10.4.0.80 on Windows Vista Home Premium SP2 and when trying to automaticaly update iTunes to 10.4.1 the installation aborts and I get a message to fetch the files and update manually. When doing this the installation aborts aga