link icon
Ask The Community

Powershell pass variable to ArgumentList

I have some trouble passing a variable to an ArgumentList. I want to install TeamViewer via MSI with powershell:

Start-Process 'msiexec.exe' -ArgumentList $tvparams

I want to deploy the machine on a Teamviewer-Site and pass the variable $serialnumber as the alias:

$serialnumber = (get-ciminstance -classname win32_bios -property serialnumber).serialnumber

$tvparams = '/i','ASSIGNMENTOPTIONS="--alias  $serialnumber"'

The onboarding of the machine works but instead of the actual serialnumber as an alias the machine pops up as "$serialnumber" on the Teamviewer-Site as if it is a String instead of a variable.

Im fiddling with the quotes for too long so im asking now. I feel like there must be a simple solution