Get site url from library url

13/01/2012 23:16

Get site url from library url

 

 $libraryUrl="https://td_sp_ui/sites/test/CategoryCards/Pages"

    #take site url from library url (one level folder)
    $siteUrl=$libraryUrl.substring(0, $libraryUrl.LastIndexOf("/"));
    $siteUrl

 

Get site url from list url


    $libraryUrl="http://td_sp_ui/sites/test/Helpdesk/Lists/Glossary-ListInstance1"

    #take site url from library url (one level folder)
    $ListsUrl=$libraryUrl.substring(0, $libraryUrl.LastIndexOf("/"));   
    $siteUrl=$ListsUrl.substring(0, $ListsUrl.LastIndexOf("/"));
    $siteUrl