param ( [string]$DomainName = "contoso.com" ) $scriptName = $MyInvocation.MyCommand.Name $logFile = "C:\$scriptName_log.txt" Start-Transcript -Path $logFile -Append Import-Module ADCSTemplate Get-ChildItem -Path "C:\setup\templates" -Filter *.json | % { $TemplateName = $_.BaseName if (-not(Get-ADCSTemplate -DisplayName $TemplateName)) { New-ADCSTemplate ` -DisplayName $TemplateName ` -JSON (Get-Content "C:\setup\templates\$_" -Raw) ` -Identity "$DomainName\Domain Users" ` -Publish } } Stop-Transcript