scansources.ps1 error
scansources.ps1 error
I get a error when i run the script P4A Chocolatey Sources
I was not able to assign my proget proxy to any agent.
When i add it manually with choco command, my proxy works.
Is There a BUG ?
TEST-DC
2
10.03.2025 12:41:34
Chocolatey returned -> [C:\Windows\LTSvc\C4A\scansources.ps1 : Fehlendes Argument für den Parameter "WORK". Geben Sie einen Parameter vom Typ
"System.String" an, und versuchen Sie es erneut.
In Zeile:1 Zeichen:88
+ ... ass -Scope Process -Force; C:\Windows\LTSvc\C4A\scansources.ps1 -WORK
+ ~~~~~
+ CategoryInfo : InvalidArgument: (:) [scansources.ps1], ParameterBindingException
+ FullyQualifiedErrorId : MissingArgument,scansources.ps1]
ComputerID
Hidden_ComputerID
I was not able to assign my proget proxy to any agent.
When i add it manually with choco command, my proxy works.
Is There a BUG ?
TEST-DC
2
10.03.2025 12:41:34
Chocolatey returned -> [C:\Windows\LTSvc\C4A\scansources.ps1 : Fehlendes Argument für den Parameter "WORK". Geben Sie einen Parameter vom Typ
"System.String" an, und versuchen Sie es erneut.
In Zeile:1 Zeichen:88
+ ... ass -Scope Process -Force; C:\Windows\LTSvc\C4A\scansources.ps1 -WORK
+ ~~~~~
+ CategoryInfo : InvalidArgument: (:) [scansources.ps1], ParameterBindingException
+ FullyQualifiedErrorId : MissingArgument,scansources.ps1]
ComputerID
Hidden_ComputerID
Re: scansources.ps1 error
Sorry had to go translate that.
So error is saying that no data was passed along with the -WORK option.
The only way I could see that is if line 30 failed to convert line 29 in to a base64 string. Line 28 sets the WORK string to blank, Line 29 is the string we are going to convert and send. So it would only make since that this was the failure point and nothing was returned form Base64 request.
Can you execute the following on the agent in question to see what you get as a return
Should return something like
Also have a look at the comands log for agent, confirm that there was no data after the -WORK switch for command
Cmmand would loo like this
instead of this
So error is saying that no data was passed along with the -WORK option.
The only way I could see that is if line 30 failed to convert line 29 in to a base64 string. Line 28 sets the WORK string to blank, Line 29 is the string we are going to convert and send. So it would only make since that this was the failure point and nothing was returned form Base64 request.
Can you execute the following on the agent in question to see what you get as a return
Code: Select all
[Convert]::ToBase64String([System.Text.Encoding]::UTF8.GetBytes("AddSource|none|MyName|MyURL|MyUsername|mypass|0"))
Should return something like
Code: Select all
QWRkU291cmNlfG5vbmV8TXlOYW1lfE15VVJMfE15VXNlcm5hbWV8bXlwYXNzfDA=
Also have a look at the comands log for agent, confirm that there was no data after the -WORK switch for command
Cmmand would loo like this
Code: Select all
C:\Windows\LTSvc\C4A\scansources.ps1 -WORK
Code: Select all
C:\Windows\LTSvc\C4A\scansources.ps1 -WORK QWRkU291cmNlfG5vbmV8TXlOYW1lfE15VVJMfE15VXNlcm5hbWV8bXlwYXNzfDA=
Re: scansources.ps1 error
These are the commands which i can see, when i started the Script
the error ist on the last execute command here the output of the first two execute command lines (i changed host and password)
1.
cmd.exe!!! /c "@powershell Set-ExecutionPolicy Bypass -Scope Process -Force; "%LTSVCDir%\C4A\convert-to-b64.ps1 -clearString 'AddSource|none|chocorepo|http://proget.host.de:8080/nuget/chocop ... password|5'"
Output:
QWRkU291cmNlfG5vbmV8Y2hvY29yZXBvfGh0dHA6Ly9wcm9nZXQubWFuZV0L2Nob2NvcHV3xjaG9jbxNYW5kYWxhMjAyNSMzfDU=
2. cmd.exe!!! /c "@powershell Set-ExecutionPolicy Bypass -Scope Process -Force; "%LTSVCDir%\C4A\scansources.ps1 -WORK U2NhblNvdXJjZXN8bm9uZXxub25lfG5vbmV8bm9uZXxub25lfG5vbmU=""
Output:
(4693','25','chocolatey','https://community.chocolatey.org/api/v2/','0')
the error ist on the last execute command here the output of the first two execute command lines (i changed host and password)
1.
cmd.exe!!! /c "@powershell Set-ExecutionPolicy Bypass -Scope Process -Force; "%LTSVCDir%\C4A\convert-to-b64.ps1 -clearString 'AddSource|none|chocorepo|http://proget.host.de:8080/nuget/chocop ... password|5'"
Output:
QWRkU291cmNlfG5vbmV8Y2hvY29yZXBvfGh0dHA6Ly9wcm9nZXQubWFuZV0L2Nob2NvcHV3xjaG9jbxNYW5kYWxhMjAyNSMzfDU=
2. cmd.exe!!! /c "@powershell Set-ExecutionPolicy Bypass -Scope Process -Force; "%LTSVCDir%\C4A\scansources.ps1 -WORK U2NhblNvdXJjZXN8bm9uZXxub25lfG5vbmV8bm9uZXxub25lfG5vbmU=""
Output:
(4693','25','chocolatey','https://community.chocolatey.org/api/v2/','0')
Re: scansources.ps1 error
the command
[Convert]::ToBase64String([System.Text.Encoding]::UTF8.GetBytes("AddSource|none|MyName|MyURL|MyUsername|mypass|0"))
works as expected
[Convert]::ToBase64String([System.Text.Encoding]::UTF8.GetBytes("AddSource|none|MyName|MyURL|MyUsername|mypass|0"))
works as expected
Re: scansources.ps1 error
Interesting...
Further down the code we have the function to add source
Lastly the actual code that run s just a few short lines.
So starting at the top, We take in a base64 encryptrd string called WORK, Work is then decoded to a normal string "AddSource|none|MyName|MyURL|MyUsername|mypass|0" and then split in the pipe key ( | ) in to an array and then assigned a variable name for each value.
We test the CMD variable (in this case is AddSource) which launches the addSourceRepo function above. That function takes your data and adds the repo to chocolatey as seen in function.
If $xc = Output ->(4693','25','chocolatey','https://community.chocolatey.org/api/v2/','0')
Then I'm thinking this was a scanSource and not an addSource command.
Ths is plausable as we do send a scan request first, so we need to see if we get inside the look of the Automate script where we test for and add sourcers.
Please try running scrit in debug mode on the agent in question. Place a break at line 33 so script runs through the loop once and stops. Then lets look at script and command logs, we have a script log line that will print out "Chocolatey returned -> [@ADDSOURCE@]" in the agents script logs.
Did we get the log, did it stop at the break point if so post the log and the command input/output.
Code: Select all
param(
[Parameter(Mandatory = $true)]
[string]
$WORK
)
try{
$args = [System.Text.Encoding]::UTF8.GetString([System.Convert]::FromBase64String($WORK))
$workdata = $args.Split("|")
$CMD = $workdata[0]
$package = $workdata[1]
$sourcename = $workdata[2]
$sourceURL = $workdata[3]
$username = $workdata[4]
$password = $workdata[5]
$priority = $workdata[6]
Further down the code we have the function to add source
Code: Select all
function addSourceRepo{
try{
if($username -eq ""){
$xc = c:\programdata\chocolatey\bin\choco.exe source add -n="'$sourcename'" -s="'$sourceURL'" --priority="'$priority'"
write-output $xc
}else{
$xc = c:\programdata\chocolatey\bin\choco.exe source add -n="'$sourcename'" -s="'$sourceURL'" -u="'$username'" -p="'$password'" --priority="'$priority'"
write-output $xc
}
}catch{
return
}
}
Code: Select all
if($CMD -eq "ScanPackages"){
scan-packages
}elseif($CMD -eq "ScanSources"){
scan-sources
}elseif($CMD -eq "AddSource"){
addSourceRepo
}elseif($CMD -eq "RemoveAllSources"){
removeAllSources
}elseif($CMD -eq "RemoveSource"){
$xc = c:\programdata\chocolatey\bin\choco.exe source remove -n="'$sourcename'"
}else{
write-output "Command not found"
}
So starting at the top, We take in a base64 encryptrd string called WORK, Work is then decoded to a normal string "AddSource|none|MyName|MyURL|MyUsername|mypass|0" and then split in the pipe key ( | ) in to an array and then assigned a variable name for each value.
We test the CMD variable (in this case is AddSource) which launches the addSourceRepo function above. That function takes your data and adds the repo to chocolatey as seen in function.
Code: Select all
$xc = c:\programdata\chocolatey\bin\choco.exe source add -n="'$sourcename'" -s="'$sourceURL'" -u="'$username'" -p="'$password'" --priority="'$priority'"
If $xc = Output ->(4693','25','chocolatey','https://community.chocolatey.org/api/v2/','0')
Then I'm thinking this was a scanSource and not an addSource command.
Ths is plausable as we do send a scan request first, so we need to see if we get inside the look of the Automate script where we test for and add sourcers.
Please try running scrit in debug mode on the agent in question. Place a break at line 33 so script runs through the loop once and stops. Then lets look at script and command logs, we have a script log line that will print out "Chocolatey returned -> [@ADDSOURCE@]" in the agents script logs.
Did we get the log, did it stop at the break point if so post the log and the command input/output.
Re: scansources.ps1 error
i have to manually set
UseintEnc to 0 to make the script run to validatesources
line 32 logs:
Chocolatey v2.4.3
Added chocorepo - http://host:8080/nuget/chocopublic/ (Priority 5)
%sqldatasetrowcount%=1
then script exits in cleanup
UseintEnc to 0 to make the script run to validatesources
line 32 logs:
Chocolatey v2.4.3
Added chocorepo - http://host:8080/nuget/chocopublic/ (Priority 5)
%sqldatasetrowcount%=1
then script exits in cleanup
Re: scansources.ps1 error
Ok thats interesting....
On line 4 we set that value so you must have it set in the main console.
Ok lets try this, If you have the Use International Encoding selected, Run script in debug and place a break at line 90.
I was in the wrong area of script for your encoding selection. This is the loop that you should be in.
If you are using the same agent to test, then remove the source if it exists on agent first before running debug test.
P.s do not mind that my script image does not look like your script entirly. I am making some modifications to the script to improve it just a little and adding some more logging.
On line 4 we set that value so you must have it set in the main console.
Ok lets try this, If you have the Use International Encoding selected, Run script in debug and place a break at line 90.
I was in the wrong area of script for your encoding selection. This is the loop that you should be in.
If you are using the same agent to test, then remove the source if it exists on agent first before running debug test.
P.s do not mind that my script image does not look like your script entirly. I am making some modifications to the script to improve it just a little and adding some more logging.
Re: scansources.ps1 error
I just pushed out an update to build 3.7.0.13.
It should improve the source script a little and provide some script logging to help show you where in script you are at if a failure arrises. Make sure to restart the DBagent afterwards..
https://delivery.shopifyapps.com/-/e8e9 ... 3174c10eab
It should improve the source script a little and provide some script logging to help show you where in script you are at if a failure arrises. Make sure to restart the DBagent afterwards..
https://delivery.shopifyapps.com/-/e8e9 ... 3174c10eab
Re: scansources.ps1 error
i have habitat - can i use your download link or does that effect our license ?
Re: scansources.ps1 error
Problem seems to be in Line
@myencodedsourceworkstring@ ist empty
so that line 94 gives the error
this is sourceworkstring:
AddSource|none|chocorepo|http://host.de:8080/nuget/chocopublic/| ... password|5
there is a shellresult, which looks like the encoded string, but @myencodedsourceworkstring@ ist empty
so that line 94 gives the error
this is sourceworkstring:
AddSource|none|chocorepo|http://host.de:8080/nuget/chocopublic/| ... password|5