Remember to maintain security and privacy. Do not share sensitive information. Procedimento.com.br may make mistakes. Verify important information. Termo de Responsabilidade

How to Execute Invoke-WsusServerCleanup via PowerShell for Efficient WSUS Maintenance

The Windows Server Update Services (WSUS) is a crucial component for managing updates in a Windows environment. Over time, WSUS can accumulate unnecessary updates, leading to performance issues and increased storage usage. To maintain optimal performance, it's essential to perform regular cleanup operations. The Invoke-WsusServerCleanup cmdlet in PowerShell is a powerful tool designed to streamline this process by removing obsolete updates, declining expired updates, and more.

Understanding Invoke-WsusServerCleanup

The Invoke-WsusServerCleanup cmdlet is part of the UpdateServices module in PowerShell. It performs several cleanup tasks on a WSUS server, including:

  • Removing obsolete updates
  • Declining expired updates
  • Deleting obsolete computers
  • Removing unneeded update files

Prerequisites

Before running the Invoke-WsusServerCleanup cmdlet, ensure you have:

  1. Administrative privileges on the WSUS server.
  2. PowerShell installed and configured on your server.
  3. The UpdateServices module available on your system.

Examples

Example 1: Basic Cleanup

To perform a basic cleanup of the WSUS server, open PowerShell with administrative privileges and execute the following command:

Invoke-WsusServerCleanup

This command will execute all available cleanup tasks, which include removing obsolete updates, declining expired updates, and cleaning up unnecessary files.

Example 2: Targeted Cleanup

If you want to perform specific cleanup tasks, you can use the parameters provided by the cmdlet. For instance, to remove only obsolete updates and unnecessary update files, use:

Invoke-WsusServerCleanup -CleanupObsoleteUpdates -CleanupUnneededContentFiles

Example 3: Scheduling Cleanup

To automate the cleanup process, you can schedule a task using Task Scheduler. Here’s how you can create a scheduled task to run the cleanup every Sunday at 2 AM:

  1. Open Task Scheduler and create a new task.

  2. Set the trigger to run weekly on Sundays at 2 AM.

  3. In the "Action" tab, select "Start a Program" and enter the following in the "Program/script" field:

    powershell.exe
  4. In the "Add arguments" field, enter:

    -Command "Invoke-WsusServerCleanup"
  5. Save the task.

Conclusion

Regularly executing the Invoke-WsusServerCleanup cmdlet helps maintain the efficiency and performance of your WSUS server by removing unnecessary data and optimizing storage usage. By scheduling regular cleanups, you can ensure that your WSUS server remains in optimal condition without manual intervention.

To share Download PDF

Gostou do artigo? Deixe sua avaliação!
Sua opinião é muito importante para nós. Clique em um dos botões abaixo para nos dizer o que achou deste conteúdo.