question

JohnLenz-5880 avatar image
0 Votes"
JohnLenz-5880 asked DSPatrick answered

Are there log cleanup scripts

Server 2102R2

Are there scripts/tasks to cleanup/delete of log entries? I do it manually but it is very tedious.

Suggestions ,please

windows-server
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

DSPatrick avatar image
0 Votes"
DSPatrick answered

From PowerShell you can Clear-EventLog
https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.management/clear-eventlog?view=powershell-5.1


--please don't forget to upvote and Accept as answer if the reply is helpful--



5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

DSPatrick avatar image
0 Votes"
DSPatrick answered DSPatrick edited

Not sure what logs you're asking about. You may need to roll your own or take a look here for some examples / ideas.
https://docs.microsoft.com/en-us/samples/browse/

--please don't forget to upvote and Accept as answer if the reply is helpful--



5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

TeemoTang-MSFT avatar image
0 Votes"
TeemoTang-MSFT answered

Which type of logs do you want to clear? Event log, IIS log or WSUS log? We need more detailed information to assist you with demand.
In general, if you want to an event log cleanup script, please refer to this Microsoft document
Clear-EventLog
https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.management/clear-eventlog?view=powershell-5.1

If you want to cleaup IIS log, refer to this article:
How to: Cleanup IIS Log Files
https://community.spiceworks.com/how_to/85462-cleanup-iis-log-files


If the Answer is helpful, please click "Accept Answer" and upvote it.
Information posted in the given link is hosted by a third party. Microsoft does not guarantee the accuracy and effectiveness of information.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

JohnLenz-5880 avatar image
0 Votes"
JohnLenz-5880 answered

I am looking to clear out event logs

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

JohnLenz-5880 avatar image
0 Votes"
JohnLenz-5880 answered

Thanks,
I am trying example 4. Will report back

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

DSPatrick avatar image
0 Votes"
DSPatrick answered

Sounds good

--please don't forget to upvote and Accept as answer if the reply is helpful--



5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

JohnLenz-5880 avatar image
0 Votes"
JohnLenz-5880 answered

Got it to work
first you have to be at PowerShell 5. Server2012R2 is level 4.
Next you execute in elevated window.
Beautiful

Does it work in Windows 10?

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

DSPatrick avatar image
0 Votes"
DSPatrick answered

Glad to hear, you're welcome. Yes, it will work on windows 10 as well.

--please don't forget to upvote and Accept as answer if the reply is helpful--





5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.