• WSUS执行清理时出现错误


    参考:

    https://docs.microsoft.com/en-us/powershell/module/updateservices/Invoke-WsusServerCleanup?view=windowsserver2016-ps

    https://social.technet.microsoft.com/Forums/ie/ko-KR/b7ef1bad-c90a-4eb9-86ed-0628bc8243e0/2816529702wsus2610220986296162596825454242113816935823?forum=systemsmanagementserverzhchs

     手工执行清理命令:

    powershell:

    <#
    https://docs.microsoft.com/en-us/powershell/module/updateservices/Invoke-WsusServerCleanup?view=windowsserver2016-ps
    Invoke-WsusServerCleanup
          [-UpdateServer <IUpdateServer>]
          [-CleanupObsoleteComputers]
          [-CleanupObsoleteUpdates]
          [-CleanupUnneededContentFiles]
          [-CompressUpdates]
          [-DeclineExpiredUpdates]
          [-DeclineSupersededUpdates]
          [-WhatIf]
          [-Confirm]
          [<CommonParameters>]
    #>
    echo ....删除的过时更新....
    Invoke-WsusServerCleanup -CleanupObsoleteUpdates -Verbose
    echo ....删除的过时计算机....
    Invoke-WsusServerCleanup -CleanupObsoleteComputers -Verbose
    echo ....拒绝的过期更新....
    Invoke-WsusServerCleanup -DeclineExpiredUpdates -Verbose
    echo ....释放的磁盘空间....
    Invoke-WsusServerCleanup -CleanupUnneededContentFiles -Verbose
    echo ....删除的过时更新....
    Invoke-WsusServerCleanup -DeclineSupersededUpdates -Verbose
    echo ....拒绝的过期更新....
    Invoke-WsusServerCleanup -DeclineExpiredUpdates -Verbose
    echo ....done....

     在WINDOWS做个定时任务,每月执行一下自动清理

    "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe" -noLogo "C:\Users\Administrator\Desktop\clean_wsus.ps1"

     ######### 2022/09/29/

    今天遇到一台WSUS,手工清理还是会出现超时现象,参照文章,要用SMSS连接WID内部数据库 \\.\pipe\MICROSOFT##WID\tsql\query 执行脚本

    https://www.sqlshack.com/managing-the-windows-internal-database-wid/

    http://jeffbuenting.github.io/wsus/sql/powershell/2018/07/05/WSUS_Cleanup_Timeout.html

    http://pnijjar.freeshell.org/2016/wsus-stuck/

    --************** vexation code with my small changes
    USE SUSDB
    DECLARE @var1 INT, @curitem INT, @totaltodelete INT
    DECLARE @msg nvarchar(200)
    CREATE TABLE #results (Col1 INT) INSERT INTO #results(Col1)
    EXEC spGetObsoleteUpdatesToCleanup
    SET @totaltodelete = (SELECT COUNT(*) FROM #results)
    SELECT @curitem=1
    DECLARE WC Cursor FOR SELECT Col1 FROM #results
    OPEN WC
    FETCH NEXT FROM WC INTO @var1 WHILE (@@FETCH_STATUS > -1)
    BEGIN SET @msg = cast(@curitem as varchar(5)) + '/' + cast(@totaltodelete as varchar(5)) + ': Deleting ' + CONVERT(varchar(10), @var1) + ' ' + cast(getdate() as varchar(30))
    RAISERROR(@msg,0,1) WITH NOWAIT
    EXEC spDeleteUpdate @localUpdateID=@var1
    SET @curitem = @curitem +1
    FETCH NEXT FROM WC INTO @var1
    END
    CLOSE WC
    DEALLOCATE WC
    DROP TABLE #results
  • 相关阅读:
    关于观察者模式和发布/订阅模式
    git:error: Your local changes to the following files would be overwritten by merge:
    node中几个路径的梳理
    centOS 开启服务器后无法访问(大坑啊)
    文件上传简记
    自建nodejs服务器(一:有个服务器)
    nodejs上使用sql
    express笔记
    windows下node配置npm全局路径(踩坑)
    DropMaster
  • 原文地址:https://www.cnblogs.com/d9394/p/16669572.html
Copyright © 2020-2023  润新知