Created
October 29, 2013 14:20
-
-
Save BenNeise/7215567 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Get all templates | |
$objTemplates = Get-Template | |
# Loop through the templates | |
ForEach ($objTemplate in $objTemplates){ | |
# Set the $StrInterimTemplateName variable to the template name, replacing the string "Tmpl" with an empty string | |
$StrInterimTemplateName = ($objTemplate.Name -replace("Tmpl","")) | |
# As the string we've just removed might be anywhere in the name, we need to replace double spaces with single | |
$StrInterimTemplateName = ($StrInterimTemplateName -replace(" "," ")) | |
# And also remove trailing spaces from the start, or the end of the string | |
$StrInterimTemplateName = $StrInterimTemplateName.Trim() | |
# Display on screen what we're doing (as the "Set-Template" with -WhatIf isn't very clear | |
Write-Host Changing `[($objTemplate.Name)`] to `[ Tmpl $StrInterimTemplateName `] | |
# Change the Template Name to the $StrInterimTemplateName variable preceeded by "Tmpl", uncomment the #-WhatIf if testing | |
Set-Template -Template $objTemplate -Name "Tmpl $StrInterimTemplateName" #-WhatIf | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment