Solved

Get URL with SiteID using PowerShell

Posted on 2013-12-12
8
5,857 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
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Work Over Net is a new and very powerful collaboration product. With its new easy interface it is becoming very competitive to other similar products like webex and office interactive. WON 2010 have the standard business tools needed for multi-offic…
For SharePoint sites, particularly public-facing ones, there are times when adding JavaScript, Meta Tags, CSS Styles or other content to the page <head> section is more practical than modifying master pages.  For instance, you could add the jQuery l…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

773 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