Fetching full folder URL in Powershell

Hi,
I am trying to upload some images to a sub-folder in a library.
However, the folder path does not seem to be correct, and the image is not getting added.
The actual url will be : http://server/Lists/LibraryName/subfolder
But when using the powershell, the path is coming as :
http://Server/LibraryName/subfolder/
Below is the powershell code used:
function UploadImages($weburl)
$docLibraryName = "TestLibrary"
$localFolderPath = "C:\Users\Test\test_image"
Add-PsSnapin Microsoft.SharePoint.PowerShell -erroraction silentlycontinue
$web = Get-SPWeb -Identity $webUrl
$docLibrary = $web.Lists[$docLibraryName]
$subFolderName="test_image"
#Attach to local folder and enumerate through all files
$files = ([System.IO.DirectoryInfo] (Get-Item $localFolderPath)).GetFiles() | ForEach-Object {
#Create file stream object from file
$fileStream = ([System.IO.FileInfo] (Get-Item $_.FullName)).OpenRead()
$contents = new-object byte[] $fileStream.Length
$fileStream.Read($contents, 0, [int]$fileStream.Length);
$fileStream.Close();
write-host "Copying" $_.Name "to" $docLibrary.Title "in" $web.Title "..."
#Add file
$folder = $web.getfolder($docLibrary.Title + "/" + $subFolderName)
write-host "folder is " $folder
write-host "whole url is " $folder.Url + "/" + $_.Name
[Microsoft.SharePoint.SPFile]$spFile = $folder.Files.Add($folder.Url + "/" + $_.Name, $contents, $true)
$spItem = $spFile.Item
Write-Host -f Green "Added Images to Library !!!"
$web.Dispose()
The below line is throwing error:
[Microsoft.SharePoint.SPFile]$spFile = $folder.Files.Add($folder.Url + "/" + $_.Name, $contents, $true)
The write host output is showing the below:
Copying ab_small_gif.gif to testLibrary in testLab ...
folder is testLibrary/test_image
whole url is testLibrary/test_image + / + ab_small_gif.gif
864
ForEach-Object : Exception calling "Add" with "3" argument(s):
"<nativehr>0x80070003</nativehr><nativestack></nativestack>There is no file
with URL 'http://server/testLibrary/test_image/ab_small_gif.gif' in this Web."
How to fix this?
Thanks

Hi  ,
According to your description, my understanding is that you encountered the error “There is no file with URL 'http://server/testLibrary/test_image/ab_small_gif.gif' in this Web” when you try to upload some
images to a sub-folder in a library using PowerShell script.
Per my knowledge, the URL of a SharePoint library should be as this : 
http://servername/LibraryName
Such as :
http://sp2013/Shared%20Documents
The URL of a SharePoint list should be as this:
http://servername/Lists/ListName
Such as :
http://sp2013/Calendar
So please make sure the location you want to upload the images to is  a library.
Also you can try to  create a new Document Library and upload your images.
Thanks,
Eric
Forum Support
Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Subscriber Support,
contact [email protected]
Eric Tao
TechNet Community Support

Similar Messages

  • PowerShell : SPWeb.GetFolder() with browser folder url failed

    I am using powershell script and when I call SPWeb.GetFolder() with
    (short url) it works fine and when I used (browser url) it's not working. However it refers to the same folder
    e.g
    short url
    http://intranet.company.eg/it/Test/Test
    browser url :
    http://intranet.company.eg/it/Test/Forms/AllItems.aspx?RootFolder=%2fit%2fTest%2fTest&FolderCTID=0x01200008503521C8123648B5EE9C5BFFC50F6A
    I need to get the folder url as input from user so is there any way to solve this issue or workaround for that ?
    In brief how can I make easy way to get folder from user as input parameter then I make operations on it?

    Hi Mohammed,
    All items.aspx with query string is a list view page, if you want to get the whole url (browser url you mean), you need to construct the whole url with each part value (i.e. list url, folder name, rootfolder value and folderCTID value).
    Thanks
    Daniel Yang
    TechNet Community Support
    Please remember to mark the replies as answers if they help, and unmark the answers if they provide no help. If you have feedback for TechNet Support, contact
    [email protected]

  • How can I include a Credit Mgmt Case Folder URL in a workflow notification?

    I have a requirement to add a URL to a workflow notification, which is easy enough. The issue I am having is that I am not able to create a URL that successfully opens the Credit Management Case Folder that is specified in the worflow notification.
    I am only able to get the URL to launch the following successfully: http://<ce:0000>/OA_HTML/RF.jsp?function_id=16351&resp_id=23916&resp_appl_id=222&security_group_id=0&lang_code=US
    Has anyone else solved this issue? Any help would be appreciated.

    We are using eBusiness Suite 11.5.10.2, 10g database
    I created a woflow attribute of type URL.
    Name: Case Folder Link
    Frame Target: New Window
    Value: http://<instance>/OA_HTML/RF.jsp?function_id=16351&resp_id=23916&resp_appl_id=222&security_group_id=0&lang_code=US
    I then added the following line to add the URL attribute to the HTML message body.
    Case Folder Link : &CASE_FOLDER_LINK
    When using the link above I don't get any error message. However when I try to change the URL to a specific case folder URL (Note this URL should change depending on the Case Folder # provided in the notification message.):
    http://<instance>/OA_HTML/OA.jsp?_rc=ARCMANALYSISDATACRDSUMMARYPAGE&_ri=222&retainAM=Y&cmSubRegion=PARTYREGION&cmPartyId=%7B!!k5vkXUpUCWxLhSZj.uqBHQ%7D&cmCustAccountId=%7B!!lBrDTc7.B3E6QA-16tJNIw%7D&cmSiteUseId=%7B!!7jcW1qvgKOeEFCpFYCanSA%7D&OAHP=ARCMMENUAPPLICATION&OASF=ARCMANALYSISDATACRDSUMMARY&_ti=1687529995&oapc=9&oas=GiXPV8nU9RQ6Ej53zIESsw..
    The error I receive is:
    Error: You are trying to access a page that is no longer active. - The referring page may have come from a previous session. Please select Home to proceed.

  • Get ClientContext from Full sharepoint url?

    I am receiving a full sharepoint url like 'http://TestServer/sites/TestSite/TestSubSite/_vti_bin/lists.asmx'
    I know the following code will not work as the url does not directly reference a site.
    using (var context = new ClientContext(http://TestServer/sites/TestSite/TestSubSite/_vti_bin/lists.asmx))
    My question is...considering urls are provided to me, what logic can I apply to modify the url so that I am only referencing the subsite 'http://TestServer/sites/TestSite/TestSubSite'?
    Thanks heaps.

    You can do it easily with string manipulation:
    string url = "http://TestServer/sites/TestSite/TestSubSite/_vti_bin/lists.asmx";
    int index = url.IndexOf("/_vti_bin");
    if (index > 0)
    string newurl = url.Substring(0, index);
    Saifullah Shafiq
    Blog:  
    Twitter:   LinkedIn:
      Facebook:
      Google+:
      Latest Book:
    A Practical Guide to SharePoint 2013

  • Assigning Full Folder In DMS

    Dear Sir/mam
    In CV01N insteat of assigning single file i want to assign full folder with many autocad files, can you sugest any other subsequent way to assign so many file bcoz every time i have to select sing file.
    I hadassigned one document to doc.type and now i want change that doc type of copy that content to other doc type is there way required your valuable answer.
    regards
    kunal

    hi, kunal,
    Q. did u sent any folder in Internet.?
    i think ans is No! right.
    u see folder is not a Workstaion application component. this never executes. think logicly.
    In DMS we are creating folders, and attaching Original files, which are excutables.
    if u want alternative as per your requirement i would suggest, you have to Zip the folder and Attach Zip file in DMS.
    this will works, there is no configuration is required for this.
    whil opening or checkout, u need to copy to desk top and exract, and agian Chek in or SAVE.
    hope under stood
    Benakaraja
    ??p

  • Output folder URL not sticking

    In the Flex Build Path setting for my Flex project, I set the
    Output folder and Output folder URL. It appears that the Output
    folder URL is not getting saved when I shut down and reopen Flex
    Builder. The Output folder is sticking, but I need to respecify the
    Output folder URL each time I fire up Flex Builder.

    The attribute name in .actionScriptProperties is "rootURL",
    but I just tried
    manually inserting it there, and unfortunately, it looks like
    beta 3 ignores it.
    - Mike Morearty
    Developer, Flex Builder team
    http://www.morearty.com/blog
    mgbaron wrote:
    > I'm getting stuck on this issue as well.
    >
    > In the meantime, is there a parameter I can add to my
    .actionscriptProperties file that will make the output folder when
    I close FlexBuilder?

  • Need help with 'Output Folder URL'

    How can I compile my application and have it get posted on a
    server?
    When I create a project, in the “Flex Build Path”
    I add my server URL in the 'Output Folder URL' field. But when I
    Run my project, it doesn't even seem to attempt to push any files
    to the server. It just brings up my browser with the path to it,
    which it obviously gets a 404 error. And its going to need a
    username and password to post files to a server. Where would I
    assign theses value to Flex Builder?

    After I installed Apache Ant and tinkered with it for about 5
    hours, I have what initially wanted. The code below will compile,
    copy and launch. I also made a splash logo that appears when its
    building. Ant is a nice utility for automated development.
    Ref:
    http://blog.jodybrewster.net/2008/04/09/installing-ant-in-flex-builder-3/
    http://ant.apache.org/manual/tasksoverview.html
    <project name="buildXIFF" default="main">
    <property name="compiler" value="C:\Program
    Files\Adobe\Flex Builder 3\sdks\3.2.0\bin\mxmlc.exe"/>
    <property name="firefox" location="C:\Program
    Files\Mozilla Firefox\firefox.exe"/>
    <property name="projectURL" value="
    http://vmwinserver2003/flex/tests/XIFF/XIFF.html"/>
    <property name="baseDirectory"
    value="Z:\Documents\Programming\Flex\Tests\XIFF"/>
    <property name="baseServerDirectory"
    value="Y:\flex\tests\XIFF"/>
    <target name="main">
    <splash
    imageurl="file:${baseDirectory}/build/FxAntBuildLogo.png"
    showduration="2000"/>
    <antcall target="compile" />
    <antcall target="copy" />
    <antcall target="launch" />
    </target>
    <target name="compile" description="Build XIFF
    project">
    <echo>Building files in bin directory in
    repository</echo>
    <exec executable="${compiler}">
    <arg line="-file-specs '${baseDirectory}/src/XIFF.mxml'
    "/>
    <arg line="-output= '${baseDirectory}/bin-debug/' "/>
    </exec>
    </target>
    <target name="copy" description="Copy XIFF bin directory
    to server">
    <echo>Copying bin directory from repository to server.
    Overwriting all files in destination directory.</echo>
    <copy todir="${baseServerDirectory}" overwrite="true">
    <fileset dir="${baseDirectory}/bin-debug/"/>
    </copy>
    </target>
    <target name="launch">
    <echo>Launching browser, URL is the project's html
    page on the server.</echo>
    <exec executable="${firefox}" spawn="true">
    <arg value="${projectURL}"/>
    </exec>
    </target>
    </project>

  • Site Studio Error Handler for virtuals folder URLs

    Hi Experts,
    we have a ErrorHandler section in sitestudio to handle 404 URLs. It is working fine for site URLs.
    My question is .. would it be worked for virtual folder URLs.
    IF we have a vitual folder structure like this - /abc/xyz/ and this folder has one file say "abc.html"...
    http://server/siteid/abc/xyz/abc.html - It works fine .....
    I user typed any wrong URL like
    http://server/siteid/abc/xyz/abcdefgh.html
    would it be handled by Sitestudio ErrorHandler ???

    This is the mapping from my first post:
    <instance-name>/webdav-test/newsletters/ <!--$cgipath-->?IdcService=GET_FILE&dDocName=<!--$suffix-->&allowInterrupt=1&RevisionSelectionMethod=LatestReleased&Rendition=web&noSaveAs=1
    The only change is I added <instance-name> to mine at the begining (if I don't it won't work because I didn't feel like adding webdav-test as prefix in my apache).
    Then I run it like this:
    http://www.example.com/<instance-name>/webdav-test/newsletters/000001
    Notice that I put contentId as in 000001, not xyz.htm because it won't work (xyz.htm is not a valid dDocName). This works perfectly fine for me.
    I'm guessing in your case it'd run: http://www.example.com/webdav-test/newsletters/000001, you'll have to give the contentId instead of the actual name of the file for that.
    Cheers

  • GPO Folder redirection using Powershell

    Dear,
    how can i configure a gpo for Folder Redirection using powershell.
    I would like to create gpo's with all kinds of folder redirection configurations using a script.
    Davy

    Hi,
    Just checking in to see if the suggestions were helpful. Please let us know if you would like further assistance.
    TechNet Subscriber Support
    If you are
    TechNet Subscription
    user and have any feedback on our support quality, please send your feedback
    here.
    Regards, Yan Li

  • How to send the folder url using SharePoint Designer WF??

    Hi,
    i am trying to send the folder url as a email link using SharePoint designer workflow. i already created the WF which is sending the item url attaching with email. is there anyway i can add folder url too, so that once user will click they can see all the
    files in that folder?
    Thanks

    I think you've got a quote in the wrong place, but you're close. 
    Do a 'set workflow variable', and create a new one called whatever - this one was called link
    Add that variable to your email:
     Of course you can set your text to whatever you want. I use this technique to do formatting in email - you can create a pretty complex bit of html in a string variable and insert it into email - Outlook/Exchange will interpret.
    And actually, I think there's another variable, maybe in the workflow context section, that would have your site address, so you wouldn't have to hardcode your https://xxxx.com . 
    Robin

  • LoadMovie without having to use full path/URL

    I've always used loadMovie to call external swf files from a
    main/menu swf file, but it seems that some new security settings
    and restrictions, I'm not able to do this anymore - at least not
    online. All my swf files are in the same directory, and when I play
    the swf locally, it loads all the external swfs without a problem.
    I tried changing the path to my swf in the loadMovie command
    to the pull path on the server, and this worked. The problem is, I
    have to hand off my website to another company, and it will go
    through many rounds of testing (and servers) before eventually
    going online. Is there any way to avoid having to use the full
    path/domain in the loadMovie command for a situation like this
    where the domain/path will change?
    I have this in the Flash embed tag:
    <PARAM NAME="allowScriptAccess" VALUE="sameDomain" />
    I have this as my loadMovie command:
    loadMovie ("flashfile.swf", 1);
    But it only works when I have it like this, which is a
    problem because the URL will change many times before launch.
    loadMovie ("
    http://www.website/media/flashfile.swf",
    1);
    Any help would be appreciated!

    Yes, I've done this all the time too, and never had this
    problem, which is why I'm stumped.
    I've changed my code to this, with module_proxy being an
    empty movie clip. This works. But when I take out the URL and path,
    even though the swf files are in the same directory, it's doesn't
    play.
    loadMovie ("
    http://www.website/media/01_Mixie_Pixie_Telegram_Service.swf",
    "module_proxy");
    _parent.gotoAndPlay("dim_menu");
    //openCountdownFile();
    stop();
    Then, I tried to create a varible for the URL/domain, so I
    can change it out more easily (although when I hand this off, I
    won't be able to do that):
    var domainPath = "
    http://www.website/media/"
    function (openCountdownFile){
    var linkToSWF = domainPath + eval(PgFile[item_chosen]);
    loadMovie (linkToSWF, "module_proxy");
    parent.gotoAndPlay("dim_menu");
    var swfPageLabel = item_chosen.toString();
    gotoAndPlay(swfPageLabel);
    This doesn't seem to work either. So, if swf files SHOULD be
    able to communicate using loadMovie, why am I having this problem?
    Thanks.

  • FetchArt doesn't fetch full-size cover art

    Amazon sometimes has several user-submitted cover art images, and apparently FetchArt is grabbing the first available. But this image is not always full size. I'm using FetchArt 1.1.1 (I can't get the updated FetchArt to install - puts a red arrow on all my drives).
    I'd like to get the full-size image (manually drag n drop from Amazon is fine), but I can't seem to get rid of the small image FetchArt originally got for me.
    I've thrown the original in the Trash, and manually gone to get the image I want, but the original small image keeps popping up as the default for the song/album in question. Even when I just go through the songs and use the arrow at the top of the image window to select the preferred image, things still default back to the small size image.
    Anyone know how I get rid of the small image, and get iTunes to default to the larger, preferred image?
    Thanks
    PMG4 (3.4), Silver Door, FW400   Mac OS X (10.3.9)   Dual 1.25, 512 RAM, original Airport card, iTunes 6.0.4

    James,
    If your albums are available at the iTMS, copy the URL (control-click on the album name and choose 'Copy itunes Music Store URL) and paste it in this page
    M
    17' iMac fp 800 MHz 768 MB RAM   Mac OS X (10.3.9)   Several ext. HD (backup and data)

  • Full folder names don't show.

    In iOS, file/folder names are shortened when they cannot be displayed in one line. However, viewing a folder name within a folder still shows its shortened name. The expected result is that it should show its full, non-shortened name.
    "Cloud File Managers" is the full name of the folder.
    Hopefully this gets resolved.

    Screen shot - http://oi43.tinypic.com/13ymcfo.jpg

  • Reapeating Table with Full Document URL in column

    All,
    SP 2010 + InfoPath 2010
    I can easily connect to a library or list on my SP library from an InfoPath form.
    I can pull into a repeating table the SP library Name column, yet the Name field doesn't appear. (thus you don't get the full path of a document).
    I want to be able to open a document up by clicking a url from the InfoPath repeating table.
    I don't want to add another column to my library or list as I want to replicate this functionality across multiple libraries/lists. This would mean I'd have to write a 2nd workflow for each library/and or update all my existing workflows.
    Thus how can I retrieve the full path of a document and have it in a repeating table and make it clickable?
    Thanks
    W

    Hi W,
    How about using Document ID as workaround? Document ID for a document is unique and could be used to access the document.
    Add document ID into data connection and display it as a column, it should display as hyperlink in the repeating table.
    For reference to enable and configure document id in SharePoint Server 2010:
    http://office.microsoft.com/en-in/sharepoint-server-help/enable-and-configure-unique-document-ids-HA101790471.aspx
    Regards,
    Rebecca Tu
    TechNet Community Support

  • How to fetch KM folder owner by java API in JSPDynpage

    Hi All,
    we have an application accessing KM folders using KM APIs, using some of them we could get folder name created bye, modified by etc.
    but to fetch the owner of the folder (specified in the properties-->mislenous) we couldn't fined any method.
    can somebody help us to retrieve folder owner(s) list with some API / code.
    Thanks in advance,
    Sai

    Hi Yogalakshmi,
    I tried your below code, at all times the ACLmanager is always null.
    so when, even the inherited ACL is null I am creating acl with the same resource.
    at this time I am getting object for owners but its displaying ice_service instead of my user ID.
    what this ice_service, how to get the actual owners.. below is my code..
    public void getOwnersList(String folderID){
                try{
                      IUser user = WPUMFactory.getServiceUserFactory().getServiceUser("cmadmin_service");
                      IResourceContext rc = new ResourceContext(user);
                      RID rid = new RID(folderID); // here could not get .getRID() method...
                      IResource groupFolder = ResourceFactory.getInstance().getResource(rid, rc);
                      ISecurityManager sm = groupFolder.getRepositoryManager().getSecurityManager(groupFolder);
                      IAclSecurityManager asm = (IAclSecurityManager)sm;
                      IResourceAclManager ram = asm.getAclManager();
                      IResourceAcl ra =  ram.getAcl(groupFolder);
                      if(ra==null) {
                          ra = ram.getInheritedAcl(resource);
                          if(ra==null)
                                 ram.createAcl(groupFolder);
                                IUMPrincipalList pal = ra.getOwners();
                                IUMPrincipalListIterator it = pal.iterator();
                                while(it.hasNext()){
                                         IUMPrincipal pl = it.next();
                                         response.write("<br> pl.getDisplayName()"+pl.getDisplayName());
                                        response.write("<br> pl.getDisplayId()"+pl.getDisplayId());
                catch(Exception ex){
                      response.write("Exception ="+ex.getMessage());
                return null;
    Thanks & Regards,
    Sai Krishna
    Edited by: Konchada Sai Krishna on Sep 1, 2009 12:39 PM

Maybe you are looking for

  • Updating Template Details During the Creation of Business Partner

    Dear ABAPers,        I am working in SAP CRM 5.0.I am creating the Business partner Using the Transaction code 'BUP1'.My Requirement is at the time of saving the Business Partner i want  to update the Template Details.I tried with the BAdI  'BUPA_TEM

  • Return text from a PDF stored in a SQL Server database (Adobe iFilter)

    We are storing PDF files inside a SQL Server 2008R2 DB. We have installed the Adobe iFilter to create a full-text catalog in order to search these files. Everything was working great, until.... we tried to get the text out of that PDF for display on

  • How to make the default tree row selection programatically

    I have one use case where I am displaying the tree table based on some parameter which is just for filtering the table and display the part of hierarchy. The problem here is I want to make a default selected row when the tree will be rendered to UI b

  • Requirement mapping.

    Hi SAP Professionals, I'm not getting any clue how to map the following requirement? Please go through the scenario. Scenario: After Inquiry preparation following acitivities should done: 1. look up of the finished product availability; whether it is

  • MSI RMA

    I've just RMA'd my motherboard to MSI. It's an X58 pro. How long does the RMA process usually take? I've seen people say anything from 2 weeks to 2 months.