Created
July 26, 2017 14:00
-
-
Save vikaskumar185/6526cfa79ed2e2e7e312a400bfc83807 to your computer and use it in GitHub Desktop.
This scripts helps deleting TargetTypes in SDL Web 8+ which has components already published. This script needs Powershell Core service module to run.
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
[CmdletBinding()] | |
Param( | |
[Parameter(Mandatory=$true)] | |
[string]$TargetTypeTcmId = 'tcm:0-17-65538', #BusinessProcessType | |
[switch]$DryRun = $false | |
) | |
Begin{ | |
try{ | |
Write-Host "Preparing" | |
$modules = "Tridion-CoreService" | |
$modules | foreach {Import-Module $_ -ErrorAction Stop} | |
$client = Get-TridionCoreServiceClient | |
} | |
catch{ | |
Write-Host ("Process stopped with error {0}"-f $_ ) -ForegroundColor Red -BackgroundColor Black | |
exit | |
} | |
} | |
Process{ | |
try{ | |
$publicationIds = (Get-TtmMapping).PublicationId | |
Write-Host ("Following will be updated:") | |
foreach ($publicationId in $publicationIds){ | |
if ($DryRun){ | |
Write-Host ("Would mark UnPublish for Publication {0} with Target Type ({1})" -f $publicationId, $TargetTypeTcmId) | |
} | |
else { | |
$client.RemovePublishStates($publicationId, $TargetTypeTcmId) | |
Write-Host ("Marked UnPublish for Publication {0} with Target Type ({1})" -f $publicationId, $TargetTypeTcmId) | |
} | |
} | |
Write-Host "Done" | |
} | |
catch{ | |
Write-Host ("#Process stopped with error {0}"-f $_ ) -ForegroundColor Red -BackgroundColor Black | |
continue | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment