Silent client install using Powershell

Hello all,

I have been working on converting the Python silent install script to a PowerShell script. Its been my experience, that after converting the script to an EXE format using py2exe, it had issues running on a significant number of devices which seemed to derive from the additional imports.

My thought was to convert the script to native Powershell. I have a programming background, however, I am not exactly a Powershell guru.I have made progress, but I am having issues with the get_response function.

Within PS I wanted to verify that the Username existed so I could know if I was on the right track or not. I have not done any other conversions yet for the existing code. It seems my implementation of Invoke-RestMethod is incorrect. Could anyone point me in the right direction?

Original Python:

Github with PS:

Just a heads up you can install via Chocolatey as well. I maintain the package in the Choco repo and I push updated packages very soon after they are released.

https://chocolatey.org/packages/urbackup-client

choco install urbackup-client -y

Yes, but that will not automatically create a user and download the user specific installer. The basic UrBackup installer requires additional configuration to work as an internet client. I’m trying to create an internet only unattended silent install. Otherwise I’d have UB installed on everything by now :slight_smile:

Thanks for the heads up though! Congrats on the Chocolatey package.

Ahh I see. I suppose passing arguments to the the .exe or .msi installers cant do what you need? I only use UB for a few local clients so Im not familiar with what you are doing. I will say that you can create Chocolatey extensions (which are just PowerShell scripts) that sort of act as Chocolatey packages. I wish I could help with the PS stuff but I actually have not used REST yet. At any rate, good luck!

Can’t help. This is just too annoying. My VisualStudio can debug a lot of programming languages including python and all the .net languages but not powershell.
After somehow managing to run the script it has a lot of syntax errors. The first:

In C:\Users\Martin\Desktop\pstest\UrBackupInstaller.ps1:125 Zeichen:50

  •     $payload = @{"username" = server_username,"password" = $passw ...
    
  •                                              ~
    

Argument in der Parameterliste fehlt.

Yeah, you have to use the Windows PowerShell ISE. I think its included with all PowerShell versions 3 and 4 and enabled by default. In Windows 7 you have to run a command to invoke the ISE.

https://docs.microsoft.com/en-us/powershell/scripting/Starting-Windows-PowerShell-on-Earlier-Versions-of-Windows

As far as the script, it was a bit late when I made that last upload.
I fixed all of the syntax errors.The PS Script passes a basic syntax run.
I added commenting to define the function sections and to give a base understanding

I still need to write the Installer Download section.

However, at this point we should be able to debug the initial server communications and user creation.

Thanks for the tip

As far as I can see there are still a lot of non-UrBackup specific issues

Have you had any more luck developing this? I took what you had and I’ve made a bit of progress after some changes, some of which have been to make it PowerShell 2 compatible. I’m still not able to login via the API, though I can get the initial response with the salt. I’m guessing the main issue right now is trying to hash the password properly.

I was out all weekend. I was just happy to get it to retrieve the salt on Thursday. I’m slowly making progress. I’m not innately familiar with PowerShell or Python so I work on it when I have free time and a couple of hours to burn. Its a learning process.

Basically, I run the Python version through the debugger and pause it at set break points. Look at the variable contents, then attempt to mimic the responses/functions with PowerShell.

Well obviously that would be the smartest thing to do :slight_smile: I’m going to give that a go myself and once I can get successful login I’ll send the code over to you, unless of course you beat me to it. Ultimately I’d like to translate that Python API wrapper into a PowerShell module. We’ll see how motivated I am.

I am pretty sure there is a plugin or something similar that you can add to Visual Studio to debug PowerShell. I know you can do it in Visual Studio Code at least.

Debugging is not the issue for me at this moment. I can’t get the password hash to match up to what the Python wrapper produces.