This project is read-only.


Mar 11, 2014 at 10:26 PM
Edited Mar 11, 2014 at 11:52 PM
You might want to add this code:
    if ($client.count -gt 1) {
        foreach ($possibleclient in $client) {
            if ($possibleclient.FullDomainName.Split('.')[0] -eq $computer) {
                $client = $possibleclient
Otherwise if a computer you want to remove from a group partially matches the name of other computers, you will be potentially removing the wrong computer(s). For example, consider 3 computers named:


If I wanted to remove RDI from a group, Remove-PoshWSUSClientFromGroup will get back all three from Get-PoshWSUSClient. By implementing this check you only remove the computer you want out of a list returned by Get-PoshWSUSClient.

EDIT: It appears the same code should be added to Add-PoshWSUSClientToGroup, otherwise multiple computers can be returned by Get-PoshWSUSClient. In fact, I'm not sure how widespread the use of Get-PoshWSUSClient is, but it might be better to have a parameter for returning only a single exact match from Get-PoshWSUSClient.
Mar 13, 2014 at 7:06 PM
I'll have to spend some time with this. The API by design treats everything like a wildcard at the end of the string. So in you example, RDI would grab that along with everything else that starts with RDI. A workaround is to use Where-Object to better filter the clients as well as using -WhatIf to see what would get changed.