Cannot clear Event Viewer logs with .ps1 script

  1. Posts : 23
    Windows 10 64-bit

    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. Callender's Avatar
    Posts : 4,415
    21H1 64 Bit Home
      My Computer

  3. FreeBooter's Avatar
    Posts : 4,075
    Windows 10 Pro 64-bit

    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 22:03.
Find Us

Windows 10 Forums