This script has already been produced in a previous post, but for convenience I thought I would replicate it here.
#Get the Site Collection
$SiteCollection = Get-SPSite http://%5BSharePoint Site] #Change to you site URL
#Get the Term Store ID
$TaxSession = Get-SPTaxonomySession -Site $SiteCollection
$TermStore = $TaxSession.TermStores[“Managed Metadata Service”] #Change to your service name
$TermStore.Id
#Get the Term Set ID
$TermStoreGroup = $TermStore.Groups[“Corporate Taxonomy”] #Change to your Terms Store name
$TermSet = $TermStoreGroup.TermSets[“Department”] #Change to your term set name
$TermSet.Id