.PARAMETER SqlCredential
Allows you to login to SQL Server using alternative credentials.

.PARAMETER Database
The database where the certificate will be removed.

.PARAMETER Certificate
The certificate that will be removed

.PARAMETER WhatIf
Shows what would happen if the command were to run. No actions are actually performed.

.PARAMETER Confirm
Prompts you for confirmation before executing any changing operations within the command.

.PARAMETER EnableException
By default, when something goes wrong we try to catch it, interpret it and give you a friendly warning message.
This avoids overwhelming you with "sea of red" exceptions, but is inconvenient because it basically disables advanced scripting.
Using this switch turns this "nice by default" feature off and enables you to catch exceptions with your own try/catch.

if($Pscmdlet.ShouldProcess($instance,"Dropping the certificate named $cert for database '$db' on $server")){try{$smocert.Drop()Write-Message-LevelVerbose-Message"Successfully removed certificate named $cert from the $db database on $server"$output.status="Success"}catch{$output.Status="Failure"Stop-Function-Message"Failed to drop certificate named $cert from $db on $server."-Target$smocert-InnerErrorRecord$_-Continue}$output}}}process{

foreach($instancein$SqlInstance){try{Write-Message-LevelVerbose-Message"Connecting to $instance"$server=Connect-SqlInstance-SqlInstance$instance-SqlCredential$sqlcredential}catch{Stop-Function-Message"Failure"-CategoryConnectionError-ErrorRecord$_-Target$instance-Continue}

foreach($dbin$Database){$currentdb=$server.Databases[$db]

if($null-eq$currentdb){Stop-Function-Message"Database '$db' does not exist on $server"-Target$currentdb-Continue}

if(-not$currentdb.IsAccessible){Stop-Function-Message"Database '$db' is not accessible"-Target$currentdb-Continue}

foreach($certin$certificate){$smocert=$currentdb.Certificates[$cert]

if($null-eq$smocert){Stop-Function-Message"No certificate named $cert exists in the $db database on $server"-Target$currentdb.Certificates-Continue}