HodorNV / ALOps

ALOps
58 stars 24 forks source link

Powershell 7 Compatibility for AlOps Tasks #791

Open joandrsn opened 2 weeks ago

joandrsn commented 2 weeks ago

As I understand it, to use PowerShell 7 with AlOps tasks, we need to set the pwsh flag (despite the documentation stating # Run task in Powershell Core. $(pwsh), which is no longer accurate).

Microsoft has announced that the PowerShell 5 module will be deprecated in BC26.

This means we need to update all AlOps tasks to use PowerShell 7 by adding the pwsh: true setting to each task.

Questions:

  1. Are there any plans to automatically detect when PowerShell 7 should be used?
  2. Could there be an option for a global variable to manage this?

I understand that there are challenges involved, particularly in ensuring that this change doesn't disrupt builds for customers using versions earlier than BC24.

PeterConijn commented 2 weeks ago

I have tried turning that on in our release pipeline, but it leads to error:

2024-09-04T10:53:35.1795744Z WARNING: Proxy creation has been skipped for the following command: 'ConvertFrom-SecureString, ConvertTo-SecureString, Get-Acl, Get-AuthenticodeSignature, Get-CmsMessage, Get-Credential, Get-ExecutionPolicy, Get-PfxCertificate, New-FileCatalog, Protect-CmsMessage, Set-Acl, Set-AuthenticodeSignature, Set-ExecutionPolicy, Test-FileCatalog, Unprotect-CmsMessage', because it would shadow an existing local command.  Use the AllowClobber parameter if you want to shadow existing local commands.
2024-09-04T10:53:35.3599517Z ##[error]Failed to generate proxies for remote module 'Microsoft.PowerShell.Security'. No command proxies have been created, because all of the requested remote commands would shadow existing local commands.  Use the AllowClobber parameter if you want to shadow existing local commands.

I am without a doubt missing a beat or two, but I don't know which one(s).

PeterConijn commented 1 week ago

Forgive my ignorance in this area, but is there something specific we need to change on our Azure VM agent server? I have been using the PowerShell Core boolean, but that led to the errors above, as did changing the startup load order.

Does anyone know the steps we need to take to migrate this to PS7?