- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to install the MSI package using PowerShell DSC?
To install the MSI package using DSC, we need to use the DSC resource “Package”. Let see which properties are available for this resource.
PS C:\> Get-DscResource -Name Package | Select -ExpandProperty Properties Name PropertyType IsMandatory Values ---- ------------ ----------- ------ Name [string] True {} Path [string] True {} ProductId [string] True {} Arguments [string] False {} Credential [PSCredential] False {} DependsOn [string[]] False {} Ensure [string] False {Absent, Present} LogPath [string] False {} PsDscRunAsCredential [PSCredential] False {} ReturnCode [UInt32[]] False {}
Name, Path, and ProductID parameters are mandatory for this DSC resource.
The best way to retrieve the above details is to install the sample package on the test machine and then get the details. We will use here the 7Zip MSI package installed on one computer.
Get-Package 7-zip* | fl *
From the above output, we can grab here the name of the Package after installation, ProductID (i.e. ProductCode).
Configuration Install7zip{ Node @("LabMachine2k16","AD"){ Package 7zip{ Name = '7-Zip 19.00 (x64 edition)' ProductId = '23170F69-40C1-2702-1900-000001000000' Path = '\ad\shared\7z1900-x64.msi' Ensure = 'Present' } } }
In the above example, the source package is located at the source location and we want to install 7zip on the two nodes.
To generate the MOF file at the specific location so we can use them later to start the configuration,
Install7zip -OutputPath C:\Temp\7zipInstall -Verbose
Output
Once the MOF file is generated, we can start the configuration to apply DSC,
Start-DscConfiguration -Path C:\Temp\7zipInstall -Wait -Force -Verbose
Once the above command runs successfully, check if the configuration is applied or not using,
Test-DscConfiguration -Path C:\Temp\7zipInstall
You should get output like below, which shows that both the servers are in the desired state, which means the MSI package is installed.
If the InDesiredState property is false, it means the server has missed the configuration.
- Related Articles
- How to uninstall the MSI package using PowerShell?
- How to install DSC resources using PowerShell?
- How to install the MSI file using PowerShell?
- How to retrieve the MSI package product code using PowerShell?
- How to install MSI file to the custom directory using PowerShell?
- How to install the Nuget Package using PowerShell?
- How to install MSI file using batch file in PowerShell?
- Azure DSC node configuration using PowerShell
- How to install pandas using the python package manager?
- Get the Reverse Shell with MSI package
- How to uninstall software using Package management in PowerShell?
- How to Install the Azure CLI on Windows using PowerShell?
- How to install a certificate to the certificate store using PowerShell?
- How to install Selenium package in Anaconda?
- How to resolve - Relative path is not supported in PowerShell DSC?
