locked
Powershell Cmdlet XML Error RRS feed

  • Question

  • I have a 2012r2 server running as my WSUS point and I am trying to write a powershell script to perform the monthly cleanup and approve updates for our update groups. However when I run a cmdlet like Get-WsusUpdates or Get-WsusComputer I receive an error "There is an error in XML document".  I'm not sure which XML document it is referring to.  This error happens for these cmdlets regardless of the parameters, if any, I enter.  I've been scouring the interwebs to see if anyone else has seen this issue and surprisingly I can't find much. Any ideas of how I can use these cmdlets would be appreciated.

    Monday, August 1, 2016 6:01 PM

Answers

  • Hi rdr222,

    >I have a 2012r2 server running as my WSUS point and I am trying to write a powershell script to perform the monthly cleanup and approve updates for our update groups

    Let's back to your original requirements. Hope the following method could work around the Powershell issue.

    1. In order to perform WSUS cleanup and maintenance, we may use the following method:

    1).Download and install the following tools:

    Microsoft Command Line Utilities 11 for SQL Server:

    https://www.microsoft.com/en-us/download/details.aspx?id=36433

    ODBC driver 11 for SQL:

    https://www.microsoft.com/en-us/download/details.aspx?id=36434

    2). In CMD, direct to SQLCMD.exe path using command:

    cd C:\Program Files\Microsoft SQL Server\Client SDK\ODBC\110\Tools\Binn

    3). Cope the script and store it locally:

    https://gallery.technet.microsoft.com/scriptcenter/6f8cde49-5c52-4abd-9820-f1d270ddea61#content

    4). In CMD, run the following command:

    SQLCMD -E -S np:\\.\pipe\MICROSOFT##WID\tsql\query -i <script location>

    Then use task schedule to perform it regularly.

    2. In order to approve updates for our update groups, we may create automatic approval rules in GUI:

    Best Regards,

    Anne


    Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Support, contact tnmff@microsoft.com.

    Friday, August 12, 2016 7:24 AM

All replies

  • Hi rdr,

    According to the screenshot, it seems there are something wrong with the powershell module.

    1. Please check C:\Windows\System32\WindowsPowerShell\v1.0\Modules\UpdateServices, if all the files are all correct there, you may cope the entire "UpdateServices" folder from a working WSUS server to this WSUS server, check if it could work:

    2. If cope the folder couldn't work, you may reinstall the WSUS role, when set up, check if the powershell cmdlets is included:

    Best Regards,

    Anne


    Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Support, contact tnmff@microsoft.com.

    Tuesday, August 2, 2016 5:32 AM
  • I setup a test server from scratch and installed WSUS on it. I compared the file versions of the files in C:\Windows\System32\WindowsPowerShell\v1.0\Modules\UpdateServices on both the problem server and the new test server and did not find any differences. I even opened up the PSD1 and ps1xml files in notepad++ and did a compare that also did not find any differences. I can use the PS module on the problem server to connect to the database on the new test server without error, but if I use the PS module from the new test server to connect to the database on the problem server I get the same error.  The issue seems to be in the data itself that the PS module is trying to access.  The server with the issue has a database that was migrated from a WSUS 3.0 server

    Wednesday, August 10, 2016 4:53 PM
  • Hi rdr222,

    >The issue seems to be in the data itself that the PS module is trying to access.

    1. Get-WsusUpdate is the basic command, do you still have issues with this command, besides, could you use TAB key to get this command?

    2. Besides, the command to connect to the WSUS database is a little different between WSUS 3.0 and WSUS 4.0:

    On WSUS 4.0, the command to connect the SUSDB is:

    SQLCMD -E -S np:\\.\pipe\MICROSOFT##WID\tsql\query

    Best Regards,

    Anne


    Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Support, contact tnmff@microsoft.com.



    Thursday, August 11, 2016 2:01 AM
  • I receive the same error with Get-WsusUpdate as I did before.  It does autocomplete if I tab while typing it.  I can use it from the WSUS server I'm having issues with to get updates from the test WSUS server I setup
    Thursday, August 11, 2016 3:53 PM
  • Hi rdr222,

    >I have a 2012r2 server running as my WSUS point and I am trying to write a powershell script to perform the monthly cleanup and approve updates for our update groups

    Let's back to your original requirements. Hope the following method could work around the Powershell issue.

    1. In order to perform WSUS cleanup and maintenance, we may use the following method:

    1).Download and install the following tools:

    Microsoft Command Line Utilities 11 for SQL Server:

    https://www.microsoft.com/en-us/download/details.aspx?id=36433

    ODBC driver 11 for SQL:

    https://www.microsoft.com/en-us/download/details.aspx?id=36434

    2). In CMD, direct to SQLCMD.exe path using command:

    cd C:\Program Files\Microsoft SQL Server\Client SDK\ODBC\110\Tools\Binn

    3). Cope the script and store it locally:

    https://gallery.technet.microsoft.com/scriptcenter/6f8cde49-5c52-4abd-9820-f1d270ddea61#content

    4). In CMD, run the following command:

    SQLCMD -E -S np:\\.\pipe\MICROSOFT##WID\tsql\query -i <script location>

    Then use task schedule to perform it regularly.

    2. In order to approve updates for our update groups, we may create automatic approval rules in GUI:

    Best Regards,

    Anne


    Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Support, contact tnmff@microsoft.com.

    Friday, August 12, 2016 7:24 AM
  • Hi rdr222,

    Do you get any progress? Feel free to feed back the result.

    Best Regards,

    Anne


    Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Support, contact tnmff@microsoft.com.

    Tuesday, August 16, 2016 5:16 AM
  • Hi rdr,

    Just to confirm if you have solved your issue. Feel free to feed back.

    Best Regards,

    Anne


    Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Support, contact tnmff@microsoft.com.

    Wednesday, August 24, 2016 8:12 AM
  • I know this is kind of a dead thread, but I wanted to share my experience on this.  I just had this start happening today.  Apparelty in my case it was related to bad info in the tbComputerTargetDetail table in the WSUS database.

    I tried the above script but that did not work (Although I bet it did do some good)

    To resolve the issue, I took the following steps:

    1. Figured out what machine was causing the issue: To do this, I ran the PowerShell commands below.  This pulled all machine names out of AD and attempted to get the computer info from WSUS, whichever one gave an error, was the problematic machine: 

    function Get-BrokenComputerTargets() {
    Write-Host "Gathering AD Computer Names..."
    $adpc = (Get-ADComputer -Filter '*' -Properties "Name").Name
    $ErrorPCs = @()

    Write-Host $adpc.Count "Computers found..."
    Write-Host "Passing Computer names to WSUS for testing... please be patient"
    $adpc | % { $pc = $_; try { Get-WSUSComputer -NameIncludes $pc | Out-Null } catch { $ErrorPCs += $pc } }

    Write-Host "The following computers had an error trying to retreive from WSUS"
    $ErrorPCs | Out-Host
    }

    2. Found the entries in the WSUS database causing the issue, using the Microsoft SQL Management Studio and connecting to the WID databse using named pipes (see above)

    3. When I looked up the PC in the tbComputerTarget and tbComputerTargetDetail tables, I discovered that the "ComputerModel" column had a weird ASCII character instead of an actual model.

    4. I deleted the data from that column (Left just a space there) and restarted the WSUS Service

    5. VOILA!  It all works again

    Hope this helps anyone else that stumbles across this!

    • Proposed as answer by Patrik_Hansson Thursday, January 11, 2018 3:26 PM
    Monday, March 20, 2017 6:35 PM