The major issue with Invoke-VMScript, besides the password, is that it does not support multi-line bash scripts currently.
As an alternative, you could look at my Invoke-VMScriptPlus function.
A drawback with OScustomizationSpec is that it does not cover all OS configuration features for Linux systems.
As an alternative for that, you could use pre- and post-customization scripts.
But then you are very close to using Invoke-VMScript(Plus) but without the password.
What I usually do:
- when the target Guest OS is Windows I use an OSCustomizationSpec
- the network part might become tricky when a VM has multiple vNICs. Then I tend to use Invoke-VMScript to run the network config via netssh (or some similar command)
- when the target Guest OS is Linux I a common deployment mechanism, like for example cloud-init.
- For fine-tuning a Linux Guest OS I use my Invoke-VMScriptPlus function