Yum -y groupinstall 'Development Tools' yum -y install pam-devel yum -y install openssl-devel yum -y install python yum -y install python-devel Installing Pre-requisites in Ubuntu. The default package manager in Ubuntu is apt-get. So, we use apt-get to install the pre-requisites required for OMI and DSC.
PowerShell DSC allows you to install software and ensures the applications stay installed.
Adam Bertram
Adam Bertram is a 20-year IT veteran, Microsoft MVP, blogger, and trainer. Adam is the founder of the e-learning tech screencast platform TechSnips. Catch up on Adam’s articles at adamtheautomator.com, or follow TechSnips on Twitter at @techsnips_io.
Latest posts by Adam Bertram (see all)
PowerShell Desired State Configuration (DSC) is a powerful, declarative language that allows administrators to guarantee a server stays the way you want. Whether you simply want to ensure certain registry keys exist, check that files are in a certain place or provision entire servers from scratch, virtually anything is possible with DSC.
![]()
DSC has a resources concept, which represents different sets of functionality. To install software onto a machine with DSC requires the Package resource. This allows you to define an installer package you'd like to install on a machine.
When DSC is invoked, this resource will first check to see if the software is already installed. If not, it will proceed to run the installer to get the software installed. Although the Package resource has some setbacks, it's still a good way to get 'well behaved' packages installed on a number of machines.
For this article, I'm going to demonstrate installing the 7-Zip x64 MSI package with the Package resource, though you can also install EXE packages. You'll see that the 7-Zip MSI package works well with DSC, but not all MSI packages work equally as well. It depends on how the MSI was packaged.
First, you need to have PowerShell v4 or later installed. Otherwise, DSC is not available. You can always check this by typing $PSVersionTable.PSVersion.Major into the console. Once you've confirmed a current version, the next step is to ensure the Package resource is available by running Get-DscResource.
If it is available, you should see the Package resource properties.
Package resource properties
I'll be installing 7-Zip on a single, local machine, so I'll need to check that the package exists on that machine. This is not a requirement, however, for the Package resource. I'll be using DSC in 'push' mode here. If you've got lots of servers to install software on, look into setting up DSC in 'pull' mode.
I've downloaded and placed the 7-Zip MSI package on my computer at C:7z1514-x64.msi. Now that it's in place, I'll need to install the package once manually to gather a proper name and product ID for the configuration script. This is an important step, as these attributes detect if the software is installed.
Once installed, I'll note the name and productID it was installed with. To do this, I'll use the Get-InstalledSoftware function in my SoftwareInstallManager module. Otherwise, you'll need to scour the HKLM:SOFTWAREMicrosoftWindowsCurrentVersionUninstall and HKLM:SOFTWAREWow6432NodeMicrosoftWindowsCurrentVersionUninstall registry keys looking for the 7-Zip key.
Retrieving the application name and product ID
Now that I have the proper name and product ID, I can create the DSC configuration script.
You can see above that I have a user-defined configuration called Install7Zip and am pointing the install to the local computer name. Inside, I'm referencing the Package resource and calling it Install7Zip as well. I'd like to confirm the software is present on the local machine, and I've filled in the values we collected earlier.
Once the configuration is built, we'll need to execute it like a simple PowerShell function. This will create a MOF file with the name of the local computer in the location of the output path.
Creating the MOF file
Once the MOF is generated, we just need to start the DSC configuration process by running Start-DscConfiguration-Path C:Install7Zip-Wait-Verbose.
Dsc Install Msi
This will force DSC to first check that the software is installed. If not, it will run the MSI provided and install the software. By default, Start-DscConfiguration creates a job and runs in the background. Using the Wait parameter allows me to monitor the process as it goes along. You can see this process below.
Installing an application with PowerShell DSC
The beauty of DSC is that you don't have to code any of the usual logic required to check if the software is installed or not. Simply start the DSC configuration again, and it knows the software is already set up. It won’t attempt to run the MSI again.
Checking if an applications is installed
Installing software using the DSC Package resource can be advantageous for 'well-behaved' EXE and MSI installers. However, as you attempt to deploy more software installers with it, you'll see that, due to the lack of standardization across many installers, it might not work as expected. If so, look into technologies like Choclatey or use PowerShell modules like my SoftwareInstallManager module to ease software deployments.
Nikon Dsc File Viewer
Users who have LIKED this post:
Comments are closed.
|
AuthorWrite something about yourself. No need to be fancy, just an overview. Archives
November 2020
Categories |