0

Hey Guys im new to StackOverflow and I'm here to ask a Question about my Powershell Script for the Automation of a Script on my mgmt Server to all XENAPP Servers im hosting. I want to execute with one click the Citrix Optimizer to every XENAPP. This is my Code... btw i am a complete beginner to PowerShell.

#Citrix Optimizer for every Server

$templates= "\\xxx\xxx\xxx\templates"
$Program= "\\xxx\xxx\xxx\CtxOptimizerEngine.ps1"
$computer= Get-ADComputer -LDAPFilter "(name=*xxxxxxxxxxxx*)" -SearchBase "OU=Test Server,OU=CVAD1912,OU=Server,DC=xxxxxxxxxxx,DC=xx"
$computername=$computer.name

foreach ($server in $computername){

Invoke-Command -ComputerName $server -ScriptBlock{

$using:Program} -Source AutoSelect from $templates -Mode Analyze
    
}

My error Code is:

Invoke-Command : Es wurde kein Parameter gefunden, der dem Parameternamen "Source" entspricht.
In C:\xxxxxx\xxxxxx\xxxxxx\xxxxxx\CitrixOptimizer.ps1:14 Zeichen:17
+ $using:Program} -Source AutoSelect from $templates -Mode Analyze
+                 ~~~~~~~
    + CategoryInfo          : InvalidArgument: (:) [Invoke-Command], ParameterBindingException
    + FullyQualifiedErrorId : NamedParameterNotFound,Microsoft.PowerShell.Commands.InvokeCommandCommand

I know... My Visual Code is in German but i hope you can help me.

FYI: in the code are some things just filled up with x, this is just not to leak something personal. I guess it should not affect your help.

Appreciate the Help!

Best cosmo_

cosmo_
  • 11
  • 5
  • Can you show the output from `Get-Command \\path\to\CtxOptimizerEngine.ps1 -Syntax`? – Mathias R. Jessen Aug 17 '22 at 08:50
  • 1
    `Invoke-Command -Source` I assume the -Source parameter is intended for `CtxOptimizerEngine.ps1` and not as a parameter for Invoke-Command? – notjustme Aug 17 '22 at 09:55
  • Hey Guys, I finally found the error! If you are interested what it was: `$using:Program -Source Auto-Select from $templates -Mode Analyze` This was the original code. But i saw that i already used AutoSelect and I won't need the from $templates anymore. And @notjustme you were right. but I were also able to fix that. Thanks Guys for helping me so that I were able to do it. Best cosmo_ – cosmo_ Aug 17 '22 at 11:22

0 Answers0