Solved

Get URL with SiteID using PowerShell

Posted on 2013-12-12
8
5,433 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
 
LVL 44

Expert Comment

by:Rainer Jeschor
Comment Utility
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
Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

 

Author Comment

by:exonedge
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Microsoft SharePoint Foundation 2010 and Microsoft SharePoint Server 2010 do not offer the option to configure the location of the SharePoint diagnostic trace log files during installation.  This can, however, be configured through Central Administr…
Pimping Sharepoint 2007 without Server-Side Code Part 1 One of my biggest frustrations with Sharepoint 2007 in the corporate world is that while good-intentioned managers lock down the more interesting capabilities of Sharepoint programming in…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

743 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

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now