Private/GetDebian8Scripts.ps1

function GetDebian8Scripts {
    [CmdletBinding()]
    Param(
        [Parameter(Mandatory=$True)]
        [string]$Debian8PackageUrl,    

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

    [System.Collections.ArrayList]$Debian8PMInstallScript = @(
        'apt-get remove -y powershell'
        'apt-get install -y curl apt-transport-https ca-certificates'
        'curl https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add -'
        "sh -c 'echo `"deb [arch=amd64] https://packages.microsoft.com/repos/microsoft-debian-jessie-prod jessie main`" > /etc/apt/sources.list.d/microsoft.list'"
        'apt-get update'
        'apt-get install -y powershell'
    )

    [System.Collections.ArrayList]$Debian8ManualInstallScript = @(
        "ls $Debian8PackageName && rm -f $Debian8PackageName"
        "wget -q $Debian8PackageUrl"
        "dpkg -i $Debian8PackageName"
        'apt install -f'
    )

    [System.Collections.ArrayList]$Debian8UninstallScript = @('apt-get 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]$Debian8PMInstallScript
        ManualInstallScript         = [System.Collections.ArrayList]$Debian8ManualInstallScript
        UninstallScript             = [System.Collections.ArrayList]$Debian8UninstallScript
        ConfigurePwshRemotingScript = [System.Collections.ArrayList]$LinuxPwshRemotingScript
    }
}