Get List of all SharePoint GUIDs using PowerShell

Below are the scripts that can help you retrivesharepoint GUIDs which at times are very handy.
 
Lets start with Sharepoint 2010
 
$site = Get-SPSite http://yourserver/sites/yoursite
 $web = $site.OpenWeb("yoursubsite")
 write-host "Site: " + $site.idwrite-host "Web: " + $web.id
 $web.lists Format-Table title,id -AutoSize$web.Dispose()
 $site.Dispose()
 
Quick Trick Note: You could change $site.OpenWeb("yoursubsite") to $site.RootWeb to get just the top site.
 
Now lets take SharePoint 2007
 
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint")
 $site = New-Object Microsoft.SharePoint.SPSite("http://yourserver/sites/yoursite")
 $web = $site.OpenWeb("yoursubsite")
 write-host "Site: " + $site.idwrite-host "Web: " + $web.id
 $web.lists Format-Table title,id -AutoSize
 $web.Dispose()
 $site.Dispose()

Hope this helps