tis-powershell5 icon

PowerShell 5.1

Silent install package for PowerShell 5.1

5.1-15

  • package: tis-powershell5
  • name: PowerShell 5.1
  • version: 5.1-15
  • categories: System and network
  • maintainer: WAPT Team,Tranquil IT,Jimmy PELÉ
  • editor: Microsoft
  • locale: all
  • target_os: windows
  • architecture: all
  • signature_date:
  • size: 169.58 Mo
  • homepage : https://docs.microsoft.com/powershell/
  • depends:

package           : tis-powershell5
version           : 5.1-15
architecture      : all
section           : base
priority          : optional
name              : PowerShell 5.1
categories        : System and network
maintainer        : WAPT Team,Tranquil IT,Jimmy PELÉ
description       : Windows Management Framework 5.1 including Powershell 5.1 for Windows
depends           : tis-dotnetfx
conflicts         : 
maturity          : PROD
locale            : all
target_os         : windows
min_wapt_version  : 2.0
sources           : https://www.microsoft.com/download/details.aspx?id=54616
installed_size    : 
impacted_process  : 
description_fr    : Windows Management Framework 5.1 inclus Powershell 5.1 pour Windows
description_pl    : Windows Management Framework 5.1 wraz z Powershell 5
description_de    : Windows Management Framework 5.1 einschließlich Powershell 5
description_es    : Windows Management Framework 5.1 incluyendo Powershell 5
description_pt    : Windows Management Framework 5.1 incluindo Powershell 5
description_it    : Windows Management Framework 5.1, incluso Powershell 5
description_nl    : Windows Beheerskader 5.1 inclusief Powershell 5
description_ru    : Windows Management Framework 5.1, включая Powershell 5
audit_schedule    : 
editor            : Microsoft
keywords          : powershell,power,shell,5,5.0,5.1
licence           : 
homepage          : https://docs.microsoft.com/powershell/
package_uuid      : 83d7a6b9-faec-4a31-b402-1726b59ef46c
valid_from        : 
valid_until       : 
forced_install_on : 
changelog         : 
min_os_version    : 6.1
max_os_version    : 
icon_sha256sum    : 89b5c97d53bad78c4769ced0ed03c74955f4f53fe03d3bd29bdae353c3f0ae2f
signer            : Tranquil IT
signer_fingerprint: 8c5127a75392be9cc9afd0dbae1222a673072c308c14d88ab246e23832e8c6bb
signature         : H3neia9S4OLPc0+RHM9JOz7md3gpkF5CuqfPXX8lL0bjek1Iot8lC+zglRJSSKPBbWCSswmt1WOyJtrKv8bMgVN7K3p62aOl9Cmi7YsQh18kg9WF6p+5PUQNaDdxLqVdiAYPG0YgzMe97OVYl5p/JTDv+3DP/w16PjV0KehdR8twHYr9UFxgs2cUrCr2oMLlN39OuKsesQn2xkKSjBuBC02+PucpictKbiQbX/eHUKVsQD+tPrmRNJHpihVGldELqigJ5y088s+WpkPWyhGiD2bTVFZ1AAIHlvfSH18kgPOEpFvkIwiro8RouE18rc64+3sv5KosmrqiJEVDd2wvmQ==
signature_date    : 2022-09-13T19:00:38.637863
signed_attributes : package,version,architecture,section,priority,name,categories,maintainer,description,depends,conflicts,maturity,locale,target_os,min_wapt_version,sources,installed_size,impacted_process,description_fr,description_pl,description_de,description_es,description_pt,description_it,description_nl,description_ru,audit_schedule,editor,keywords,licence,homepage,package_uuid,valid_from,valid_until,forced_install_on,changelog,min_os_version,max_os_version,icon_sha256sum,signer,signer_fingerprint,signature_date,signed_attributes

# -*- coding: utf-8 -*-
from setuphelpers import *

"""
Usable WAPT package functions: install(), uninstall(), session_setup(), audit(), update_package()

https://docs.microsoft.com/powershell/scripting/install/installing-windows-powershell
https://docs.microsoft.com/powershell/scripting/windows-powershell/install/installing-windows-powershell?view=powershell-7.1#upgrading-existing-windows-powershell
https://www.microsoft.com/download/details.aspx?id=54616

"""
# Declaring global variables - Warnings: 1) WAPT context is only available in package functions; 2) Global variables are not persistent between calls
kbs_dict = [
    {
        "dl_url": "https://download.microsoft.com/download/6/F/5/6F5FF66C-6775-42B0-86C4-47D41F2DA187/Win7AndW2K8R2-KB3191566-x64.zip",
        "kb_name": "Win7AndW2K8R2-KB3191566-x64.msu",
        "win_vers": WindowsVersions.Windows7,
        "arch": "x64",
    },
    {
        "dl_url": "https://download.microsoft.com/download/6/F/5/6F5FF66C-6775-42B0-86C4-47D41F2DA187/Win7-KB3191566-x86.zip",
        "kb_name": "Win7-KB3191566-x86.msu",
        "win_vers": WindowsVersions.Windows7,
        "arch": "x86",
    },
    {
        "dl_url": "https://download.microsoft.com/download/6/F/5/6F5FF66C-6775-42B0-86C4-47D41F2DA187/W2K12-KB3191565-x64.msu",
        "kb_name": "W2K12-KB3191565-x64.msu",
        "win_vers": WindowsVersions.WindowsServer2012,
        "arch": "x64",
    },
    {
        "dl_url": "https://download.microsoft.com/download/6/F/5/6F5FF66C-6775-42B0-86C4-47D41F2DA187/Win8.1AndW2K12R2-KB3191564-x64.msu",
        "kb_name": "Win8.1AndW2K12R2-KB3191564-x64.msu",
        "win_vers": WindowsVersions.Windows81,
        "arch": "x64",
    },
    {
        "dl_url": "https://download.microsoft.com/download/6/F/5/6F5FF66C-6775-42B0-86C4-47D41F2DA187/Win8.1-KB3191564-x86.msu",
        "kb_name": "Win8.1-KB3191564-x86.msu",
        "win_vers": WindowsVersions.Windows81,
        "arch": "x86",
    },
]


def install():
    # Declaring local variables
    if iswin64():
        arch = "x64"
    else:
        arch = "x86"
    patched = False

    # Installing Windows KBs
    for kb in kbs_dict:
        kb_file = kb["kb_name"]
        kb_name = kb_file.split("-")[1].upper()
        kb_nb = kb_name.replace("KB", "")
        if kb["arch"] == arch:
            if kb["win_vers"] == windows_version(members_count=2):
                with EnsureWUAUServRunning():
                    if not is_kb_installed(kb_nb):
                        print("Installing: {}".format(kb_file))
                        run(
                            r"wusa.exe {} /quiet /norestart".format(makepath(basedir, kb_file)),
                            accept_returncodes=[0, 3010, 2359302, -2145124329],
                            timeout=3600,
                        )
                        if not is_kb_installed(kb_nb):
                            error("{} installation do not complete".format(kb_name))
                    else:
                        print("{} is already installed".format(kb_name))
                    patched = True
    if not patched:
        print("INFO: No need to patch this PC")


def update_package():
    # Declaring local variables
    proxies = get_proxies()
    if not proxies:
        proxies = get_proxies_from_wapt_console()

    # Downloading latest binaries
    for dl_kb in kbs_dict:
        dl_kb_file = dl_kb["dl_url"].split("/")[-1]
        if not isfile(dl_kb_file):
            wget(dl_kb["dl_url"], dl_kb_file, proxies=proxies)

    # Extracting
    for zip_in_dir in glob.glob("*.zip"):
        print("Extracting: " + zip_in_dir)
        unzip(zip_in_dir, filenames="*.msu", ignore_basename=True)
        remove_file(zip_in_dir)

# -*- coding: utf-8 -*-
from setuphelpers import *

# Declaring global variables - Warnings: 1) WAPT context is only available in package functions; 2) Global variables are not persistent between calls
kbs_dict = [
    {
        "dl_url": "https://download.microsoft.com/download/6/F/5/6F5FF66C-6775-42B0-86C4-47D41F2DA187/Win7AndW2K8R2-KB3191566-x64.zip",
        "kb_name": "Win7AndW2K8R2-KB3191566-x64.msu",
        "win_vers": WindowsVersions.Windows7,
        "arch": "x64",
    },
    {
        "dl_url": "https://download.microsoft.com/download/6/F/5/6F5FF66C-6775-42B0-86C4-47D41F2DA187/Win7-KB3191566-x86.zip",
        "kb_name": "Win7-KB3191566-x86.msu",
        "win_vers": WindowsVersions.Windows7,
        "arch": "x86",
    },
    {
        "dl_url": "https://download.microsoft.com/download/6/F/5/6F5FF66C-6775-42B0-86C4-47D41F2DA187/W2K12-KB3191565-x64.msu",
        "kb_name": "W2K12-KB3191565-x64.msu",
        "win_vers": WindowsVersions.Windows81,
        "arch": "x64",
    },
    {
        "dl_url": "https://download.microsoft.com/download/6/F/5/6F5FF66C-6775-42B0-86C4-47D41F2DA187/Win8.1AndW2K12R2-KB3191564-x64.msu",
        "kb_name": "Win8.1AndW2K12R2-KB3191564-x64.msu",
        "win_vers": WindowsVersions.WindowsServer2012,
        "arch": "x64",
    },
    {
        "dl_url": "https://download.microsoft.com/download/6/F/5/6F5FF66C-6775-42B0-86C4-47D41F2DA187/Win8.1-KB3191564-x86.msu",
        "kb_name": "Win8.1-KB3191564-x86.msu",
        "win_vers": WindowsVersions.Windows81,
        "arch": "x86",
    },
]


def update_package():
    # Declaring local variables
    proxies = get_proxies()
    if not proxies:
        proxies = get_proxies_from_wapt_console()

    # Downloading latest binaries
    for dl_kb in kbs_dict:
        dl_kb_file = dl_kb["dl_url"].split("/")[-1]
        if not isfile(dl_kb_file):
            wget(dl_kb["dl_url"], dl_kb_file, proxies=proxies)

    # Extracting
    for zip_in_dir in glob.glob("*.zip"):
        print("Extracting: " + zip_in_dir)
        unzip(zip_in_dir, filenames="*.msu", ignore_basename=True)
        remove_file(zip_in_dir)


def unzip(zipfn, target=None, filenames=None, ignore_basename=False, extract_with_full_paths=True):
    r"""Unzip the files from zipfile with patterns in filenames to target directory

    Args:
        zipfn (str) : path to zipfile. (can be relative to temporary unzip location of package)
        target (str) : target location. Defaults to dirname(zipfile) + basename(zipfile)
        filenames (str or list of str): list of filenames / glob patterns (path sep is normally a slash)
        ignore_basename (bool): avoid or not the generation of a parent folder when no target is given
        extract_with_full_paths (bool): keeping or not the subfolders of the archive as is

    Returns:
        list : list of extracted files

    >>> unzip(r'C:\tranquilit\wapt\tests\packages\tis-7zip_9.2.0-15_all.wapt')
    [u'C:\\tranquilit\\wapt\\tests\\packages\\tis-7zip_9.2.0-15_all\\7z920-x64.msi',
     u'C:\\tranquilit\\wapt\\tests\\packages\\tis-7zip_9.2.0-15_all\\7z920.msi',
     u'C:\\tranquilit\\wapt\\tests\\packages\\tis-7zip_9.2.0-15_all\\setup.py',
     u'C:\\tranquilit\\wapt\\tests\\packages\\tis-7zip_9.2.0-15_all\\WAPT/control',
     u'C:\\tranquilit\\wapt\\tests\\packages\\tis-7zip_9.2.0-15_all\\WAPT/wapt.psproj',
     u'C:\\tranquilit\\wapt\\tests\\packages\\tis-7zip_9.2.0-15_all\\WAPT/manifest.sha256',
     u'C:\\tranquilit\\wapt\\tests\\packages\\tis-7zip_9.2.0-15_all\\WAPT/signature']

    >>> unzip(r'C:\tranquilit\wapt\tests\packages\tis-7zip_9.2.0-15_all.wapt',filenames=['*.msi','*.py'])
    [u'C:\\tranquilit\\wapt\\tests\\packages\\tis-7zip_9.2.0-15_all\\7z920-x64.msi',
     u'C:\\tranquilit\\wapt\\tests\\packages\\tis-7zip_9.2.0-15_all\\7z920.msi',
     u'C:\\tranquilit\\wapt\\tests\\packages\\tis-7zip_9.2.0-15_all\\setup.py']

    >>> unzip(r'C:\tranquilit\wapt\tests\packages\tis-7zip_9.2.0-15_all.wapt',filenames='WAPT/*')
    [u'C:\\tranquilit\\wapt\\tests\\packages\\tis-7zip_9.2.0-15_all\\WAPT/control',
     u'C:\\tranquilit\\wapt\\tests\\packages\\tis-7zip_9.2.0-15_all\\WAPT/wapt.psproj',
     u'C:\\tranquilit\\wapt\\tests\\packages\\tis-7zip_9.2.0-15_all\\WAPT/manifest.sha256',
     u'C:\\tranquilit\\wapt\\tests\\packages\\tis-7zip_9.2.0-15_all\\WAPT/signature']

    >>> unzip(r'C:\tranquilit\wapt\tests\packages\tis-7zip_9.2.0-15_all.wapt',filenames='WAPT/control')
    [u'C:\\tranquilit\\wapt\\tests\\packages\\tis-7zip_9.2.0-15_all\\WAPT\\control']

    >>> unzip(r'C:\tranquilit\wapt\tests\packages\tis-7zip_9.2.0-15_all.wapt',filenames='WAPT/control',ignore_basename=True)
    [u'C:\\tranquilit\\wapt\\tests\\packages\\WAPT\\control']

    >>> unzip(r'C:\tranquilit\wapt\tests\packages\tis-7zip_9.2.0-15_all.wapt',filenames='WAPT/control',extract_with_full_paths=False)
    [u'C:\\tranquilit\\wapt\\tests\\packages\\control']

    .. versionadded:: 1.3.11

    .. versionchanged:: 2.2
        added ignore_basename and extract_with_full_paths parameters

    """
    from waptutils import CustomZipFile
    import sys

    zipf = CustomZipFile(zipfn, allowZip64=True)
    if not target:
        target = makepath(os.path.dirname(os.path.abspath(zipfn)), os.path.splitext(os.path.basename(zipfn))[0])
        if ignore_basename:
            target = makepath(os.path.dirname(os.path.abspath(zipfn)))

    if filenames is not None:
        filenames = [pattern.replace("\\", "/") for pattern in ensure_list(filenames)]

    def match(fn, filenames):
        # return True if fn matches one of the pattern in filenames
        if filenames is None:
            return True
        else:
            for pattern in filenames:
                if glob.fnmatch.fnmatch(fn, pattern):
                    return True
            return False

    if filenames is not None:
        files = [fn for fn in zipf.namelist() if match(fn, filenames)]
        members = files
    else:
        files = zipf.namelist()
        members = None

    if sys.platform != "darwin" and extract_with_full_paths:
        zipf.extractall(target, members)
    elif not extract_with_full_paths:
        files_to_extract = files
        files = []
        os.makedirs(target, exist_ok=True)
        for fn in files_to_extract:
            filename = os.path.basename(fn)
            # skip directories
            if not filename:
                continue

            # copy file (taken from zipfile's extract)
            source = zipf.open(fn)
            files.append(os.path.join(filename))
            dest = open(os.path.join(target, filename), "wb")
            with source, dest:
                shutil.copyfileobj(source, dest)
    else:  # the zipfile module doesn't support symlinks, and it's used in macOS packages
        try:
            members_str = " ".join('"{0}"'.format(m) for m in members) if members else ""
            unzip_cmd = "unzip -qq {zipfile} {members_str} -d {destination_dir}".format(
                zipfile=zipfn, members_str=members_str, destination_dir=target
            )
            run(unzip_cmd)
        except:
            print("Error : couldn't unzip {}".format(zipfn))
            return []

    return [makepath(target, fn.replace("/", os.sep)) for fn in files]

f62d1e7edb82e367f7b8313089e164ae29a8c71adcfd14a87485653209d27a19 : setup.py
a8d788fa31b02a999cc676fb546fc782e86c2a0acd837976122a1891ceee42c0 : Win8.1AndW2K12R2-KB3191564-x64.msu
4575c47bedf732c7a215a5dd9e184ac2f06f10c0f23fcef38eec96b0ff3bd121 : Win7-KB3191566-x86.msu
d53153205c7edac1b5f55d03fb2fae31bce8e498bbee137e6804aa29b8ed2c98 : update_package.py
c51abfc65dff5f6858c0b9f6420caa0c166df7a6d8b484f8a3c68ea99f0032b0 : Win7AndW2K8R2-KB3191566-x64.msu
f3430a90be556a77a30bab3ac36dc9b92a43055d5fcc5869da3bfda116dbd817 : Win8.1-KB3191564-x86.msu
89b5c97d53bad78c4769ced0ed03c74955f4f53fe03d3bd29bdae353c3f0ae2f : WAPT/icon.png
a5a97261381e1d0ad46ee15916abec9c2631d0201f5cc50ceb0197a165a0bbbf : WAPT/certificate.crt
1b9ab3a7fe39dfed225ee6cee5cf287d08e0874f9dbd83d2cab91a9774fcc146 : WAPT/changelog.txt
e51e2d485a31ac6d74fc530f872cd2c14117cffa09a8c942368dfbb24868f3b8 : luti.json
4a1385642c1f08e3be7bc70f4a9d74954e239317f50d1a7f60aa444d759d4f49 : W2K12-KB3191565-x64.msu
725ae3074279add3259495e229f58d900950de943428d6bb9ef86552ec6e33fd : WAPT/control

5.1-15

[FIX] KB3191564 and KB3191565 were reversed