Private/GetOpenSUSE423Scripts.ps1
function GetOpenSUSE423Scripts { [CmdletBinding()] Param( [Parameter(Mandatory=$True)] [string]$OpenSUSE423PackageUrl, [Parameter(Mandatory=$True)] [string]$OpenSUSE423PackageName ) [System.Collections.ArrayList]$OpenSUSE423PMInstallScript = @( 'zypper -n remove powershell' 'zypper --non-interactive rr microsoft' 'rpm --import https://packages.microsoft.com/keys/microsoft.asc' 'zypper --non-interactive ar --gpgcheck-allow-unsigned-repo https://packages.microsoft.com/rhel/7/prod/ microsoft' 'zypper --non-interactive update' "rpm -ivh --nodeps $OpenSUSE423PackageUrl" #"zypper -n install --force powershell" ) [System.Collections.ArrayList]$OpenSUSE423ManualInstallScript = @( 'zypper -n remove powershell' 'zypper --non-interactive rr microsoft' 'rpm --import https://packages.microsoft.com/keys/microsoft.asc' 'zypper --non-interactive ar --gpgcheck-allow-unsigned-repo https://packages.microsoft.com/rhel/7/prod/ microsoft' "rpm -ivh --nodeps $OpenSUSE423PackageUrl" #"zypper -n install --force $OpenSUSE423PackageUrl" ) [System.Collections.ArrayList]$OpenSUSE423UninstallScript = @('zypper 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]$OpenSUSE423PMInstallScript ManualInstallScript = [System.Collections.ArrayList]$OpenSUSE423ManualInstallScript UninstallScript = [System.Collections.ArrayList]$OpenSUSE423UninstallScript ConfigurePwshRemotingScript = [System.Collections.ArrayList]$LinuxPwshRemotingScript } } |