Private/GetFedoraScripts.ps1

function GetFedoraScripts {
    [CmdletBinding()]
    Param(
        [Parameter(Mandatory=$True)]
        [string]$FedoraPackageUrl,

        [Parameter(Mandatory=$True)]
        [string]$FedoraPackageName
    )

    [System.Collections.ArrayList]$FedoraPMInstallScript = @(
        'dnf remove powershell -y'
        'rpm --import https://packages.microsoft.com/keys/microsoft.asc'
        'curl https://packages.microsoft.com/config/rhel/7/prod.repo | sudo tee /etc/yum.repos.d/microsoft.repo'
        'dnf update -y'
        'dnf install -y compat-openssl10'
        'dnf install -y powershell'
    )

    [System.Collections.ArrayList]$FedoraManualInstallScript = @(
        'dnf remove powershell -y'
        'dnf install -y compat-openssl10'
        "dnf install -y $FedoraPackageUrl"
    )

    [System.Collections.ArrayList]$FedoraUninstallScript = @('dnf remove powershell')

    [System.Collections.ArrayList]$LinuxPwshRemotingScript = @(
        "if echo `$(cat /etc/ssh/sshd_config | grep -c '^Subsystem powershell') > /dev/null -gt 0; then sed -i '/^Subsystem powershell/d' /etc/ssh/sshd_config; fi"
        'pscorepath=$(command -v pwsh)'
        'if test -z $pscorepath; then echo pwshNotFound && exit 1; fi'
        'subsystemline=$(echo "Subsystem powershell $pscorepath -sshs -NoLogo -NoProfile")'
        'sed -i "s|sftp-server|sftp-server\n$subsystemline|" /etc/ssh/sshd_config'
        'systemctl restart sshd'
    )

    [pscustomobject]@{
        PackageManagerInstallScript = [System.Collections.ArrayList]$FedoraPMInstallScript
        ManualInstallScript         = [System.Collections.ArrayList]$FedoraManualInstallScript
        UninstallScript             = [System.Collections.ArrayList]$FedoraUninstallScript
        ConfigurePwshRemotingScript = [System.Collections.ArrayList]$LinuxPwshRemotingScript
    }
}