Solved

Get URL with SiteID using PowerShell

Posted on 2013-12-12
8
6,360 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
Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

 
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

Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

Question has a verified solution.

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

When installing SharePoint 2010 RTM I came across a strange error, I was getting timeouts during the installation. I searched the web and found the best solution to be found here (http://social.msdn.microsoft.com/Forums/en-US/sharepoint2010genera…
A recent project that involved parsing Tableau Desktop and Server log files to extract reusable user queries for use in other systems. I chose to use PowerShell to gather the data, and SharePoint to present it...

733 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