install powershell windows 10 code example

Example 1: how to install powershell

for Ubuntu

# Update the list of packages
sudo apt-get update
# Install pre-requisite packages.
sudo apt-get install -y wget apt-transport-https software-properties-common
# Download the Microsoft repository GPG keys
wget -q https://packages.microsoft.com/config/ubuntu/16.04/packages-microsoft-prod.deb
# Register the Microsoft repository GPG keys
sudo dpkg -i packages-microsoft-prod.deb
# Update the list of packages after we added packages.microsoft.com
sudo apt-get update
# Install PowerShell
sudo apt-get install -y powershell
# Start PowerShell
pwsh


for macOS
brew install --cask powershell

Example 2: install windows app powershell

Add-AppxPackage <PackageName>.AppxBundle

Example 3: install powershell msi comand

$MSIInstallArguments = @(
    "/i"
    '"c:\alkane.msi"'
    "/qb!"
    "/norestart"
    "/l*v"
    '"C:\Temp\alkane_install_log.log"'
)
Start-Process "msiexec.exe" -ArgumentList $MSIInstallArguments -Wait -NoNewWindow 


$MSIUninstallArguments = @(
    "/x"
    "{0233CEF0-B5CD-40BB-AEAD-A131A547112E}"
    "/qb!"
    "/norestart"
    "/l*v"
    '"C:\Temp\alkane_uninstall_log.log"'
)
Start-Process "msiexec.exe" -ArgumentList $MSIUninstallArguments -Wait -NoNewWindow

Tags:

C Example