# Get the directories inside the template dir. as relative paths
$templateDirs = Get-ChildItem -Directory -Recurse -Name $templatePath
# Ditto for directory 1 and directory 2
$dir1Dirs = Get-ChildItem -Directory -Recurse -Name $dir1Path
$dir2Dirs = Get-ChildItem -Directory -Recurse -Name $dir2Path
# Compare to the template dirs.
Compare-Object $templateDirs $dir1Dirs
'---' # Output separator string just to show distinct outputs.
Compare-Object $templateDirs $dir2Dirs
Note the use of -Name with Get-ChildItem, which causes all subdirectories (-Directory, -Recurse to be reported as paths relative to the input directory, which allows convenient comparison between directory trees.
Also note that the Compare-Object cmdlet by default outputs [pscustomobject] instances with two properties, and only for differences between the input sets:
.InputObject, in your case a relative directory path that is unique to one input set.
.SideIndicator, which is a string indicating whether the input object was unique to the left side (the first input set, implicitly bound to parameter -ReferenceObject) - '<=' - or to the right side (the second input set, implicitly bound to parameter -DifferenceObject) - '=>'
The above yields something like:
InputObject SideIndicator
----------- -------------
C => # folder C only in dir. 1, not in template dir.
---
B <= # folder B only in template dir., not in dir. 2