Powershell Script Error

Guys, I  need some help with the following PS script

Getting the below error
PS C:\XXXXXXXX\APFW\Scripts> .\Start-XXXSimplePatching_DEVONLY.ps1 -Group "Server XXXXXX Development Group" -EndTime 26/
02/2019 23:00
Get-WsusComputer : Cannot validate argument on parameter 'ComputerTargetGroups'. The argument is null or empty.
Provide an argument that is not null or empty, and then try the command again.
At C:\XXXXXXXX\APFW\Scripts\Manual_Remove-PatchFile_script.ps1:5 char:51
+ $Servers = Get-WsusComputer -ComputerTargetGroups "$Group"
+                                                   ~~~~~~~~
    + CategoryInfo          : InvalidData: (:) [Get-WsusComputer], ParameterBindingValidationException
    + FullyQualifiedErrorId : ParameterArgumentValidationError,Microsoft.UpdateServices.Commands.GetWsusComputerComman


Script Details as follows:

Param(
[String]$Group,
[STRING]$EndTime,
[STRING]$EndDate
)

Import-Module PoshRSJob
Import-Module AutomatedPatching
$Group = "XXXXXXXX Servers Dev"
# Define log folder location

$LogFolder = "C:\XXXXXXX\APFW\Logs\$Group\"

If ((Test-Path -Path "$LogFolder") -eq $false) {
    New-Item -Path "$LogFolder" -ItemType Directory
    }

# Ensure all old log files are removed to allow fresh start

C:\XXXXXXX\APFW\Scripts\Manual_Remove-PatchFile_script(2).ps1 -List "C:\XXXXXXX\APFW\Manual_Lists\Dev_Servers.txt"

# Patch only Simple servers

$Servers = Get-Content -Path "C:\XXXXXXX\APFW\Manual_Lists\Dev_Servers.txt"
$Servers | Export-CSV -Path "C:\temp\$Group.csv" -notypeinformation


foreach ($Server in $Servers) {
        $SRV = $server.FullDomainName.TrimEnd("ds.acc.co.nz")
        Start-APFWPatching -computername $SRV -enddate $EndDate -endtime $EndTime -wait 15 -Verbose | Out-File "$LogFolder\$SRV.txt"
    }







Function Manual_Remove-PatchFile_script {
    Param(
    [String]$Group
    )

    $Servers = Get-WsusComputer -ComputerTargetGroups "$Group"
    
    foreach ($server in $servers.fulldomainname) {
        $server = $Server.TrimEnd(".ds.XXX.co.XX")
        $StatusFile = "\\$Server\C$\windows\temp\$Server.xml"

        If ((Test-Path -Path $StatusFile) -eq $true) {
            Remove-Item -Path $StatusFile -Force
        }
    }
}

Open in new window

Craig PaulsenSenior Systems EngineerAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Sam JacobsDirector of Technology Development, IPMCommented:
That should be:
 $Servers = Get-WsusComputer -ComputerTargetGroups "$($Group)"

Open in new window

If it is a single group without spaces or special characters in the name, you can leave out the quotes:
 $Servers = Get-WsusComputer -ComputerTargetGroups $Group

Open in new window

Craig PaulsenSenior Systems EngineerAuthor Commented:
will modify this
Craig PaulsenSenior Systems EngineerAuthor Commented:
still the same error
JavaScript Best Practices

Save hours in development time and avoid common mistakes by learning the best practices to use for JavaScript.

Sam JacobsDirector of Technology Development, IPMCommented:
Is the error in the same place? Maybe the value is actually blank.
Can you place the following right above that line:
Write-Host  "Value of Group: $($Group)"

Open in new window

What gets printed out?
Sam JacobsDirector of Technology Development, IPMCommented:
I think I see the problem ... While you are passing $Group to the script, you are not passing it to the function Manual_Remove-PatchFile_script.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Craig PaulsenSenior Systems EngineerAuthor Commented:
thanks, appreciate that Sam, it's looking alot better now, it's outputting the list to C:temp
Sam JacobsDirector of Technology Development, IPMCommented:
Cool ... most welcome.
Craig PaulsenSenior Systems EngineerAuthor Commented:
thanks again mate
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Powershell

From novice to tech pro — start learning today.