Cannot clear Event Viewer logs with .ps1 script


  1. Posts : 27
    Windows 10
       #1

    Cannot clear Event Viewer logs with .ps1 script


    I created a PowerShell script saved as a .ps1 file, which is stated below. Whenever I run it, it says "Access is denied" and does not clean Event Viewer logs. Please take a look at the attached screenshots and let me know what I am doing wrong. By the way, whenever I run the script below in PowerShell with administrative privileges, it does clear all Event Viewer logs.

    wevtutil el | Foreach-Object {wevtutil cl "$_"}

    Attachment 231000Attachment 231001Attachment 231002
      My Computer


  2. Posts : 6,847
    22H2 64 Bit Pro
       #2
      My Computer


  3. Posts : 5,330
    Windows 11 Pro 64-bit
       #3

    Batch script attached to this post will clear event logs history.
    Cannot clear Event Viewer logs with .ps1 script Attached Files
      My Computer


 

  Related Discussions
Our Sites
Site Links
About Us
Windows 10 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 10" and related materials are trademarks of Microsoft Corp.

© Designer Media Ltd
All times are GMT -5. The time now is 03:50.
Find Us




Windows 10 Forums