Solved

Get URL with SiteID using PowerShell

Posted on 2013-12-12
8
6,103 Views
Last Modified: 2013-12-12
I ran a sql command and all I have to work with is the SiteID and WebID. How can I use those GUID to produce a URL using PowerShell?
0
Comment
Question by:exonedge
  • 4
  • 3
8 Comments
 
LVL 44

Expert Comment

by:Rainer Jeschor
ID: 39714038
Hi,
which SharePoint version and edition?
What do you try to achieve?
Direct queries using SQL commands against Sharepoint databases are a no-go!
And you should be able to use the commandlets Get-SPWeb / Get-SPSite providing the parameter -Identity and the guid to get the objects. Then you can use the various properties to get the urls.
HTH
Rainer
0
 
LVL 1

Expert Comment

by:Sunny_2009
ID: 39714300
Save All SiteID in E:\temp\SiteID.txt with each ID on new line and run below script .

Script :
=====================================
$content = Get-Content E:\temp\SiteID.txt
foreach($line in $content)
{
$site = Get-SpSite $line
$site.Url + "," + $site.Id.Guid | out-file E:\temp\SiteUrl.txt -append -width 1000
}
Write-Host "Completed"

Open in new window


===============================
Hope this helps you
0
 

Author Comment

by:exonedge
ID: 39714621
I am trying to track down a workflow that is causing issues and I found it in sql against a Nintex Database, but the query in sql does not provide a URL. It only provides the SiteID and WebID. I need the URL to track down the workflow. I have been working with a Microsoft tech on this as well and they are the ones that started me off with queries against the SharePoint database. I can ask the Microsoft tech I am working with for the command line to get this also now that I think of it.
0
U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

 
LVL 44

Expert Comment

by:Rainer Jeschor
ID: 39714736
Hi,
OK - I just wanted to explicitely mention, that esp. updating data inside SharePoint database will result in an unsupported environment/farm.

So you should be able to get the url by using:
Get-SPWeb -Site 5953f454-5681-45b8-b2b0-c28a74608e11 | WHERE  {$_.Id -eq "d30d787b-9c5c-4deb-8e05-0a597f1bdf38"} | Select Url, Title

Open in new window


where the first GUID is the Site GUID (id) and the second one the web guid (id).

HTH
Rainer
0
 

Author Comment

by:exonedge
ID: 39714745
What you gave me almost worked. It provided me with http://hostname/managed Path/site guid but no site url.
0
 
LVL 44

Accepted Solution

by:
Rainer Jeschor earned 500 total points
ID: 39714824
Sorry,
I do not understand your response.

The above command should return the Url of the SPWeb as well as the title - and this worked on my dev environment (SharePoint Server 2010 Enterprise).

If you need the url of the SPSite then use:
Get-SPSite -identity 5953f454-5681-45b8-b2b0-c28a74608e11 | Select Url

Open in new window

0
 

Author Comment

by:exonedge
ID: 39714826
That was it, thank you! If it makes you feel any better we are not making changes to the database. We are just looking up info.
0
 
LVL 44

Expert Comment

by:Rainer Jeschor
ID: 39714853
Hi,
glad that it worked :-D

Thanks for the points and it is not about me - I just do not want that someone is getting into a really really ugly situation where MS support just decline any service due to an unsupported state of the farm (I experienced this once - and trust me - the responsible SharePoint "admin" had to look quickly for a new job). And SharePoint is not only complex but also due to the complexity and flexibility "buggy" - and in some situations only MS support can deeply analyze the root cause.

KR
Rainer
0

Featured Post

Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you create your solutions on SharePoint sooner or later you will come upon a request to set  permissions of the item depending on some of the item's meta-data - the author, people assigned as approvers, divisions, categories etc. The most natu…
SharePoint Designer 2010 has tools and commands to do everything that can be done with web parts in the browser, and then some – except uploading a web part straight into a page that is edited in SPD. So, can it be done? Scenario For a recent pr…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question