Using the commands I've created so far you can now create audiences, add rules, and display those rules all via STSADM. If you're like me and you do a lot of testing of this stuff before you push out the final version then you'll want a way to also easily delete audiences that you've created. Of course you could easily do this via the browser but what if you've added complex rules to your audience using my gl-addaudiencerule command? You'll find that you can't delete it from the browser. To deal with this I've created an additional command called, simply enough, gl-deleteaudience.
One thing I added to the command was an option to delete only the rules and not the audience itself. This allows you to essentially revert the audience back to a pure state so that you can manage it via the browser if you so desire. The code to delete an audience is real simple - essentially one line: manager.Audiences.Remove(audience.AudienceID); - the rest is just error handling and clearing of the rules:
The help for the command is shown below:
C:\>stsadm -help gl-deleteaudience stsadm -o gl-deleteaudience Deletes an audience. To delete only the rules associated with the audience pass in the -rulesonly parameter. Parameters: -name <audience name> [-ssp <SSP name>] [-rulesonly (delete only the rules)]
The following table summarizes the command and its various parameters:
|Command Name||Availability||Build Date|
|Parameter Name||Short Form||Required||Description||Example Usage|
|name||n||Yes||The name of the audience to delete.||-name "IT"
|ssp||No||The name of the SSP that the audience is associated with. If omitted the default SSP will be used.||-ssp SSP1|
|-rulesonly||ro||No||If specified then only the audience rules will be deleted and not the audience itself.||-rulesonly
The following is an example of how to delete an audience:
stsadm -o gl-deleteaudience -name "IT"
The following is an example of how to delete only the rules associated with an audience
stsadm -o gl-deleteaudience -name "IT" -rulesonly