Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- # Author: Jeoi Reqi
- # Filename: bash_get_windows_update_logs.sh
- # Version: 1.0.0
- #
- # Description:
- # This script retrieves Windows Update logs and saves them to separate files:
- # one containing verbose information saved on the desktop, and the other containing
- # ETL (Event Trace Log) data saved in the current working directory.
- #
- # Requirements:
- # - Python 3.x
- # - PowerShell
- #
- # Usage:
- # 1. Run the script using Python 3.x.
- # 2. The script will execute PowerShell commands to retrieve Windows Update logs.
- # 3. Verbose logs will be saved as 'windows_update_verbose.log' on the desktop.
- # 4. ETL logs will be saved as 'windows_update_etl.log' in the current working directory.
- #
- # Functions:
- # - main(): Executes the script, retrieves Windows Update logs, and saves them to separate files.
- # - save_verbose_log(): Saves verbose logs to 'windows_update_verbose.log' on the desktop.
- # - save_etl_log(): Saves ETL logs to 'windows_update_etl.log' in the current working directory.
- #
- # Additional Notes:
- # - Running this script requires administrative privileges as it executes PowerShell commands.
- # - Ensure that PowerShell is installed and accessible from the command line.
- # - The script may take some time to complete, depending on the size of the Windows Update logs.
- # Define the path to save the ETL log in the current working directory
- ETL_LOG_PATH="$(pwd)/windows_update_etl.log"
- # Inform the user about the logging process
- echo "Creating Windows Update logs... "
- echo "-----------------------------------------------------"
- echo "Creating Verbose log on the Desktop... "
- echo "Creating ETL log in the Current Working Directory... "
- echo "-----------------------------------------------------"
- echo "This may take some time. Thank you for your patience."
- echo "-----------------------------------------------------"
- echo
- # Run the PowerShell cmdlet to get the Windows Update ETL logs and write directly to the ETL log file
- powershell.exe -Command "get-windowsUpdateLog" > "$ETL_LOG_PATH"
- # Check if the PowerShell command executed successfully for the ETL log
- if [ $? -eq 0 ]; then
- echo "Windows Update ETL logs successfully retrieved and saved to: $ETL_LOG_PATH"
- else
- echo "Failed to retrieve Windows Update ETL logs."
- fi
- # Prompt the user to hit enter to exit
- read -rp "Press Enter to exit..."
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement