I'm coming from a full stack GCP/AWS background and now work at an Azure company, where I'm trying to make our PowerShell scripts compatible for both Linux and Windows environments. I've been using PowerShell 7.5 but ran into some confusion with my coworkers, as they prefer PowerShell 5.1 and are not willing to upgrade. I want to understand how I can ensure my scripts work seamlessly across these versions. Additionally, I've organized my scripts into separate files for better management but now I'm wondering about the best way to structure them—specifically how to use `Utilities.psm1` to import all the other scripts without too much refactoring. Any resources or tips on managing these cross-compatibility issues?
2 Answers
Have you considered just setting the required version for PowerShell in your scripts? If your coworkers refuse to install PowerShell 7, it might help to make it clear why it would benefit them. Also, are you using specific modules with dependencies that might require the newer version? Importing scripts into your module is definitely possible, but you need to ensure that all the necessary files are correctly referenced! You can compile requirements in your manifest file to manage dependencies better.
For cross-platform compatibility, there's not much shortcut other than thorough testing. Fortunately, PowerShell 5 syntax works in 7, so try to stick to it where possible. But keep in mind that file paths differ between Linux and Windows, which could cause issues. If you're looking for a good module layout, check out the ModuleBuilder module; it offers a structured way to manage everything and even helps with merging your files into a single module. Also, ensure your manifest files are set up correctly if you're going that route!

Related Questions
How To: Running Codex CLI on Windows with Azure OpenAI
Set Wordpress Featured Image Using Javascript
How To Fix PHP Random Being The Same
Why no WebP Support with Wordpress
Replace Wordpress Cron With Linux Cron
Customize Yoast Canonical URL Programmatically