Clear-ASMonitoringSqlDatabase cmdlet in non-interactive mode

%3CLINGO-SUB%20id%3D%22lingo-sub-782792%22%20slang%3D%22en-US%22%3EClear-ASMonitoringSqlDatabase%20cmdlet%20in%20non-interactive%20mode%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-782792%22%20slang%3D%22en-US%22%3E%3CP%3EHi%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI'm%20trying%20to%20automate%20running%20of%20powershell%20command%20below%20in%20non-interactive%20way.%20The%20command%20prompts%20for%20a%20confirmation.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIs%20there%20a%20way%20to%20bypass%20the%20confirmation%20prompt%20or%20accept%20the%20default%20confirmation%20response%20in%20the%20command%2Fscript%20so%20that%20it'll%20run%20automatically%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EClear-ASMonitoringSqlDatabase%20-ConnectionString%20%22Data%20Source%3Dlocalhost%3BInitial%20Catalog%3DMonitoring%3BIntegrated%20Security%3DFalse%3BUser%20ID%3Dxxx%3BPassword%3Dxxx%22%20-MaxAge%203%20-PurgeMode%20EventAgeMode%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EAny%20help%20is%20much%20appreciated!%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ERegards%2C%3C%2FP%3E%3CP%3EArman%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-782792%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3Eappfabric%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EWindows%20PowerShell%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-785396%22%20slang%3D%22en-US%22%3ERe%3A%20Clear-ASMonitoringSqlDatabase%20cmdlet%20in%20non-interactive%20mode%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-785396%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F385364%22%20target%3D%22_blank%22%3E%40acelestial%3C%2FA%3E%26nbsp%3B%20put%20a%20-force%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-markup%22%3E%3CCODE%3EClear-ASMonitoringSqlDatabase%20-ConnectionString%20%22Data%20Source%3Dlocalhost%3BInitial%20Catalog%3DMonitoring%3BIntegrated%20Security%3DFalse%3BUser%20ID%3Dxxx%3BPassword%3Dxxx%22%20-MaxAge%203%20-PurgeMode%20EventAgeMode%20-force%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-791037%22%20slang%3D%22en-US%22%3ERe%3A%20Clear-ASMonitoringSqlDatabase%20cmdlet%20in%20non-interactive%20mode%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-791037%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F383049%22%20target%3D%22_blank%22%3E%40gastone%3C%2FA%3E%26nbsp%3B%26nbsp%3BClear-ASMonitoringSqlDatabase%20cmdlet%20has%20%3CU%3Eno%3C%2FU%3E%26nbsp%3B%20either%20-Force%20or%20-Confirm%20options.%3C%2FP%3E%3C%2FLINGO-BODY%3E
Highlighted
New Contributor

Hi,

 

I'm trying to automate running of powershell command below in non-interactive way. The command prompts for a confirmation.

 

Is there a way to bypass the confirmation prompt or accept the default confirmation response in the command/script so that it'll run automatically?

 

Clear-ASMonitoringSqlDatabase -ConnectionString "Data Source=localhost;Initial Catalog=Monitoring;Integrated Security=False;User ID=xxx;Password=xxx" -MaxAge 3 -PurgeMode EventAgeMode

 

Any help is much appreciated!

 

Regards,

Arman

 

2 Replies

@acelestial  put a -force

Clear-ASMonitoringSqlDatabase -ConnectionString "Data Source=localhost;Initial Catalog=Monitoring;Integrated Security=False;User ID=xxx;Password=xxx" -MaxAge 3 -PurgeMode EventAgeMode -force

 

Highlighted

@gastone  Clear-ASMonitoringSqlDatabase cmdlet has no  either -Force or -Confirm options.