rzander / ruckzuck

software package manager for windows
https://ruckzuck.tools
Microsoft Public License
221 stars 20 forks source link

RZ4Intune failed with Error 401 Unauthorized #216

Closed ftucho closed 1 year ago

ftucho commented 1 year ago

The RZ4Intune.ps1 script fails on the step InvokeWebrequest.

PS>CommandInvocation(Out-String): "Out-String"
>> ParameterBinding(Out-String): name="InputObject"; value="The remote server returned an error: (401) Unauthorized."
Invoke-RestMethod : The remote server returned an error: (401) Unauthorized.
At C:\Users\tucho\AppData\Local\Temp\intunewin\RZ4Intune.ps1:1224 char:9
+ $rzSW = Invoke-RestMethod -Uri "$($url)/rest/v2/getsoftwares?shortnam ...
+         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-RestMethod], 
WebException
    + FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeRestMethodCommand
Invoke-RestMethod : The remote server returned an error: (401) Unauthorized.

Manual test in Powershell failed with the same error from the server.

Add-Type -AssemblyName System.Web
$url = Invoke-RestMethod -Uri "https://ruckzuck.tools/rest/v2/geturl"
$ShortName = "Adobe Acrobat Reader DC (64-bit) - MUI"
Invoke-RestMethod -Uri "$($url)/rest/v2/getsoftwares?shortname=$([System.Web.HttpUtility]::UrlEncode($ShortName))"
Invoke-RestMethod : The remote server returned an error: (401) Unauthorized.
At line:1 char:1
+ Invoke-RestMethod -Uri "$($url)/rest/v2/getsoftwares?shortname=$([Sys ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-RestMethod], WebException
    + FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeRestMethodCommand

image

rzander commented 1 year ago

/rest/v2/getsoftwares requires an API-Key to access the repository. It seems you are using an outdated version of the tool ?!

flogi12 commented 1 year ago

Had the same issue. On the "RuckZuck for Intune" page https://github.com/rzander/ruckzuck/wiki/RuckZuck-for-Intune is a direct Link to an older release. Maybe just describe to get the RZ4Intune.exe from a recent relese. Otherwise, thanks for your hard work

ftucho commented 1 year ago

Hello, thank you for the answer. The file version was the actual one. I think there was a problem with the RZ4Intune.ps1 file in the temp folder. Deleted the files from the temp folder and retried it sucessfully. In the new RZ4Intune.ps1 file I can see the new command. $rzSW = Invoke-RestMethod -Uri "$($url)/rest/v2/getsoftwares?shortname=$([System.Web.HttpUtility]::UrlEncode($ShortName))&apikey=$((Get-date).Ticks)"

ghost commented 1 year ago

Had the same issue. On the "RuckZuck for Intune" page https://github.com/rzander/ruckzuck/wiki/RuckZuck-for-Intune is a direct Link to an older release. Maybe just describe to get the RZ4Intune.exe from a recent relese. Otherwise, thanks for your hard work

Please update link to https://github.com/rzander/ruckzuck/releases/download/1.7.2.5/RZ4Intune.exe