Share via

Install through powershell

Runner4505 1 Reputation point
2022-07-15T18:26:56.37+00:00

I am trying to install an application on a computer using powershell. Basically just running a script that will install the program, require a reboot, and be able to be accessed.
I've done research on it and all I can find is going through powershell, changing directories to the downloads file, select the application and install it. However, the program I am trying to install is not in my download file. It is under the following:

Settings

Apps & Features

  >Optional Features    

       >Add a Feature     

           >"Search" for the program (such as "IE 11")    

I can't find how to create a script that will automatically install this program across multiple workstations. I find the command "Install-WindowsOptionalFeature" but every time I run that command that I get the error that is not a recognized cmdlet, script file, etc. Any help would be awesome. Thank you!

Windows for business | Windows Server | User experience | PowerShell
0 comments No comments

3 answers

Sort by: Most helpful
  1. Rich Matheisen 48,116 Reputation points
    2022-07-16T18:30:18.26+00:00

    Try this on Windows 10:

    Get-WindowsOptionalFeature -Online |   
        Select-Object FeatureName |   
            Select-String Internet-expl* |  
                If ($_ -match "FeatureName=(.+[^}])"){  
                    Enable-WindowsOptionalFeature -FeatureName $matches[1] -Online  
                }  
                else{  
                    Write-Host "Unable to find feature" -f Yellow  
                }  
    

    The code ASSUMES that there's either one matching feature, or no matching feature. The complete feature name on my machine is "internet-explorer-optional-amd64", so if you get multiple matches you can adjust the "Select-String" value accordingly to reduce the number of features to one.

    Was this answer helpful?

    0 comments No comments

  2. Adis Klacar 1 Reputation point
    2022-07-15T19:25:18.64+00:00

    Hi,

    PowerShell command for XPS Viewer is:
    DISM /Online /Add-Capability /CapabilityName:XPS.Viewer~~~~0.0.1.0

    To remove XPS Viewer, use the following command in PowerShell:
    DISM /Online /Remove-Capability /CapabilityName:XPS.Viewer~~~~0.0.1.0

    Was this answer helpful?


  3. Rich Matheisen 48,116 Reputation points
    2022-07-15T19:08:48.437+00:00

    Try Enable-WindowsOptionalFeature

    Was this answer helpful?


Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.