Removing Software Packages

Removes the specified Software Package object(s).


Examples:


Hint: The execution of these examples requires a connected PowerShell drive.


The deletion of Software Package objects is constrained by the same restrictions as the creation of such objects, i.e. filesystem operations have to be performed manually. 


If only the database objects are deleted and the corresponding filesystem objects are left alone, an inconsistent status would be created. Therefore you are required to force the deletion of the database objects through calling the Remove-EmdbSoftwarePackage cmdlet using the additional parameter -CustomDepotManagement. Analogical you must call the Delete()-method using the additional parameter $true


This example shows the removing of the Software Package "MyEscriptPackage" in the current context:


Cd "emdb:\rootDSE\Global Software Library\Application Library\Settings"

Remove-EmdbSoftwarePackage "MyEscriptPackage" -CustomDepotManagement


Alternatively, the Software Package from the previous example can be deleted by executing the following command:


$MySoftwarePackage = Get-EmdbSoftwarePackage "emdb:\rootDSE\Global Software Library\Application Library\MyEScriptPackage"

$MySoftwarePackage.Delete($true)


Alternatively the Software Package "Global Software Library\Application Library\Adobe\Adobe Reader\Adobe Reader 9.0" can be removed using the Remove-Item cmdlet:


Remove-Item "emdb:\rootDSE\Global Software Library\Application Library\Adobe\Adobe Reader\Adobe Reader 9.0"


Hint: Alternatively the alias DEL can be used to remove Software Folder objects.


Note: When using Remove-Item or DEL for deleting a Software Package, you aren't required to force the deletion. On the other hand, you do not get any hint that inconsistencies may arise, if the accompanying filesystem objects aren't removed, too.


Using the above-mentioned process, the Package directory keeps residing orphaned in the filesystem. Therefore deleting the corresponding filesystem objects is highly recommended. The following scriptcode deletes a Software Package from the database and also its Package directory including all subdirectories: 


$MyDSMShare = "\\CHISV01\DSM$"

$MySoftwarePackage = Get-EmdbSoftwarePackage "emdb:\rootDSE\Global Software Library\Application Library\MyEScriptPackage"

$MyWorkPath = "$MyDSMShare\Work\$($MySoftwarePackage.RepositoryID)\Projects\$($MySoftwarePackage.PackageId)"

$MySoftwarePackage.Delete($True)

Remove-Item -Path "filesystem::$MyWorkPath" -Recurse 


Warning: Please pay attention which directories you are going to delete - especially if your Packages have multiple revisions!


Starting with PSX 3.1 there was a new option implemented when deleting Software Package objects. When specifying the SingleItemExpected-switch it is expected, that none or exactly one object is affected. If the command would delete more than one object, an error is raised that can be caught and handled in scripts.