This is a bit ugly but it will get the job done.
I have this very basic flow, it just runs the PS script and outputs the results in a message box.

Throw this into the PowerShell task and then view the output.
$psVersion = (Get-Host).Version.Major
if ($psVersion -ne 7) {
$processInfo = New-Object System.Diagnostics.ProcessStartInfo
$processInfo.FileName = "C:\Program Files\PowerShell\7\pwsh.exe"
$processInfo.RedirectStandardError = $true
$processInfo.RedirectStandardOutput = $true
$processInfo.UseShellExecute = $false
$processInfo.Arguments = $MyInvocation.MyCommand.Definition
$process = New-Object System.Diagnostics.Process
$process.StartInfo = $processInfo
$process.Start() | Out-Null
$process.WaitForExit()
$stdout = $process.StandardOutput.ReadToEnd()
$stderr = $process.StandardError.ReadToEnd()
Write-Host $stdout
} else {
# Your logic goes here!
Write-Host "PowerShell Version = $psVersion"
}
You should get this ...

Essentially, it's checking for the version and if it's not version 7, it will launch PowerShell 7 and then retrieve the output.
Take note of the file path for PS7, you may need to change that or you may be able to simplify it. I've gone with the full path to make sure it works.