/build/static/layout/Breadcrumb_cap_w.png

Kace Software Center using Winget and PowerShell

Endorsed by Nick The Ninja

Table of Contents

Kace Software Center using Winget and Powershell 1

Using the tool 1

Creating the tool 2

Creating the Agent Shortcut in the SMA.. 2

Appendix: Sample Code. 3

 

 

Using the tool

 

1.       This can be launched using the Kace Agent Shortcuts by a local user. See Screenshot below

wdX4ayrGQp0ngAAAABJRU5ErkJggg==


2.       It then launches a GUI menu for the end user to select one or more software items to be installed using the PowerShell Winget commands.



B61g+QqaYMNQAAAAAElFTkSuQmCC



3.       The file does need to be accessible by the system so either stored locally or on a network share that a local system account can access.

Creating the tool

1.       The tool is a PowerShell script that uses windows forms for the GUI. I kept it basic for ease of use and maximum compatibility

2.       PowerShell Code is listed in appendix below.

3.       Adding an item to select is easy.

a.       If you wish to change an existing one just edit the highlighted portion to the desired name

                                                             a.      $checkboxList.Items.Add("Notepad++")

b.       If you wish to add a new item and are out of available items simply insert this code into a new line.

                                                             a.      $checkboxList.Items.Add("Notepad++")

4.       Editing the Command portion

a.       Changing existing one to install another piece of software.

                                                             a.      "Notepad++" { & winget install -e --id Notepad++.Notepad++ --silent }

1.       Change the green highlighted section to match the checkbox name listed above in the script

2.       Change the blue highlighted section to the correct PowerShell command you wish to execute when the item is selected.

5.       Once done save your script as a PS1 file.

a.       It may be possible to run it in this format but I did not test this ability due to possible issues with PowerShell execution policies across environments.

6.       Next, we need to convert this to an exe.

a.       There are several ways to do this but I selected to use PS2EXE

                                                             a.      https://github.com/MScholtes/PS2EXE

b.       Sometimes execution policy can interfere with this tool.

                                                             a.      Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope Process

7.       File placement

                                                             a.      This can be put on a network share

                                                             b.      It can also be placed locally on devices using the SMA file Sync underneath distribution.

8.       Make sure to put this in a trusted directory for you’re A/V to not cause issues or whitelist the file.

Creating the Agent Shortcut in the SMA

 

Appendix: Sample Code

Sample PowerShell Script:

Add-Type -AssemblyName System.Windows.Forms

Add-Type -AssemblyName System.Drawing

 

$form = New-Object System.Windows.Forms.Form

$form.Text = "Application Installer"

$form.Size = New-Object System.Drawing.Size(400, 350)

$form.StartPosition = "CenterScreen"

 

$checkboxList = New-Object System.Windows.Forms.CheckedListBox

$checkboxList.Location = New-Object System.Drawing.Point(10, 10)

$checkboxList.Size = New-Object System.Drawing.Size(360, 300)

$checkboxList.CheckOnClick = $true

$checkboxList.Items.Add("Notepad++")

$checkboxList.Items.Add("7-Zip")

$checkboxList.Items.Add("Wireshark")

$checkboxList.Items.Add("Putty")

$checkboxList.Items.Add("RSAT Tools")

$checkboxList.Items.Add("Firefox")

$checkboxList.Items.Add("Chrome")

$checkboxList.Items.Add("Zoom")

$checkboxList.Items.Add("Cisco Webex")

$checkboxList.Items.Add("Microsoft Teams")

$checkboxList.Items.Add("Team Viewer")

$checkboxList.Items.Add("Adobe Reader")

$checkboxList.Items.Add("VLC Player")

$checkboxList.Items.Add("Libre Office")

$checkboxList.Items.Add("Slack")

$form.Controls.Add($checkboxList)

 

$installButton = New-Object System.Windows.Forms.Button

$installButton.Location = New-Object System.Drawing.Point(150, 320)

$installButton.Size = New-Object System.Drawing.Size(100, 25)

$installButton.Text = "Install"

$installButton.Add_Click({

    $selectedItems = $checkboxList.CheckedItems

    foreach ($item in $selectedItems) {

        switch ($item) {

            "Notepad++" { & winget install -e --id Notepad++.Notepad++ --silent }

            "7-Zip" { & winget install -e --id mcmilk.7zip-zstd --silent }

            "Wireshark" { & winget install -e --id WiresharkFoundation.Wireshark --silent }

            "Putty" { & winget install -e --id PuTTY.PuTTY --silent }

            "RSAT Tools" { & Get-WindowsCapability -name rsat* -online | Add-WindowsCapability -Online }

            "Firefox" { & winget install -e --id Mozilla.Firefox -e --silent --accept-source-agreements --accept-package-agreements }

            "Chrome" { & winget install -e --id Google.Chrome --silent }

            "Zoom" { & winget install -e --id Zoom.Zoom --silent }

            "Cisco Webex" { & winget install -e --id Cisco.WebexTeams --silent }

            "Microsoft Teams" { & winget install -e --id Microsoft.Teams --silent }

            "Team Viewer" { & winget install -e --id TeamViewer.TeamViewer --silent }

            "Adobe Reader" { & winget install -e --id Adobe.Acrobat.Reader.64-bit --silent }

            "VLC Player" { & winget install -e --id VideoLAN.VLC --silent }

            "Libre Office" { & winget install -e --id TheDocumentFoundation.LibreOffice --silent }

            "Slack" { & winget install -e --id SlackTechnologies.Slack --silent }

        }

    }

    [System.Windows.Forms.MessageBox]::Show("Installation complete.")

})

$form.Controls.Add($installButton)

 

$form.ShowDialog() | Out-Null

 


Comments

This post is locked

Don't be a Stranger!

Sign up today to participate, stay informed, earn points and establish a reputation for yourself!

Sign up! or login

Share

 
This website uses cookies. By continuing to use this site and/or clicking the "Accept" button you are providing consent Quest Software and its affiliates do NOT sell the Personal Data you provide to us either when you register on our websites or when you do business with us. For more information about our Privacy Policy and our data protection efforts, please visit GDPR-HQ