Private/GetUbuntu1404Scripts.ps1

function GetUbuntu1404Scripts {
    [CmdletBinding()]
    Param(
        [Parameter(Mandatory=$True)]
        [string]$Ubuntu1404PackageUrl,

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

    [System.Collections.ArrayList]$Ubuntu1404PMInstallScript = @(
        'apt-get remove -y powershell'
        'ls packages-microsoft-prod.deb && rm -f packages-microsoft-prod.deb'
        'dpkg --purge packages-microsoft-prod'
        'wget -q https://packages.microsoft.com/config/ubuntu/14.04/packages-microsoft-prod.deb'
        'dpkg -i packages-microsoft-prod.deb'
        'apt-get update'
        'apt-get install -y powershell'
    )

    [System.Collections.ArrayList]$Ubuntu1404ManualInstallScript = @(
        "wget -q $Ubuntu1404PackageUrl"
        "dpkg -i $Ubuntu1404PackageName"
        'apt-get install -f'
    )

    [System.Collections.ArrayList]$Ubuntu1404UninstallScript = @('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]$Ubuntu1404PMInstallScript
        ManualInstallScript         = [System.Collections.ArrayList]$Ubuntu1404ManualInstallScript
        UninstallScript             = [System.Collections.ArrayList]$Ubuntu1404UninstallScript
        ConfigurePwshRemotingScript = [System.Collections.ArrayList]$LinuxPwshRemotingScript
    }
}