Scenario 2 – creating multiple packages with the .csv/.txt file input
This example covers the creation of multiple packages with the details present in the .txt
file. Upon successful execution, we can see multiple packages created in the Configuration Manager console with the details or configurations present in the input file.
Prescripting activities
We are required to create a .csv
file with the details of each package that will be created. The details include the name of the packages, the manufacturer and version, and the description and the path of the source file, with the file located in the D:\SCCM
folder. For reference, let's name the Package.csv
file. For the current example, we will take an example file with contents, as shown in the following screenshot:
Consider the following code:
$PkgDetails = Import-csv –path "D:\SCCM\Package.csv"
Foreach($Pkg in $PkgDetails)
{
$PkgName = $($Pkg.Name)
$Description = $($Pkg.Description)
$Mnfr = $($Pkg.Manufacturer)
$Version = ...