Skip to content

Commit e188a38

Browse files
authored
Add files via upload
0 parents  commit e188a38

8 files changed

+1990
-0
lines changed

CLIENT_{YOURCOMPANY.printix.net}_{TENANTID}.MSI

Whitespace-only changes.

Install-Printix.ps1

Lines changed: 163 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,163 @@
1+
# Define the path to the MSI, the wrapped arguments, and the .NET installer script
2+
$msiPath = "$PSScriptRoot\CLIENT_{<YOURCOMPANY>.printix.net}_{<TENANTID>}.MSI" # REPLACE WITH YOUR PRINTIX MSI FROM SOFTWARE DROPDOWN IN PRINTIX ADMIN CONSOLE
3+
$wrappedArgs = "WRAPPED_ARGUMENTS=/id:<YOURTENANTID>"
4+
$dotNetInstaller = "$PSScriptRoot\install-dotnet.ps1"
5+
6+
# Function to check if the script is running as administrator
7+
function Test-IsAdmin {
8+
$currentUser = New-Object Security.Principal.WindowsPrincipal([Security.Principal.WindowsIdentity]::GetCurrent())
9+
return $currentUser.IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)
10+
}
11+
12+
# Restart script with elevated privileges if not already running as admin
13+
if (-not (Test-IsAdmin)) {
14+
Start-Process powershell "-File `"$PSCommandPath`"" -Verb RunAs
15+
exit
16+
}
17+
18+
# Setup logging
19+
$logDirectory = "C:/IntuneLogs"
20+
$logFile = "$logDirectory/PrintixLog$(Get-Date -Format 'yyyyMMddHHmmss').txt"
21+
22+
if (-not (Test-Path $logDirectory)) {
23+
New-Item -Path $logDirectory -ItemType Directory -Force | Out-Null
24+
}
25+
26+
function Log-Message {
27+
param (
28+
[string]$message
29+
)
30+
Add-Content -Path $logFile -Value $message
31+
}
32+
33+
# Define the registry path and value name
34+
$regPath = "HKLM:\SOFTWARE\printix.net\Printix Client\CurrentVersion"
35+
$parentRegPath = "HKLM:\SOFTWARE\printix.net"
36+
37+
# Function to compare version numbers
38+
function Compare-Version {
39+
param (
40+
[string]$v1,
41+
[string]$v2
42+
)
43+
$ver1 = [System.Version]$v1
44+
$ver2 = [System.Version]$v2
45+
return $ver1.CompareTo($ver2)
46+
}
47+
48+
# Function to install Printix Client
49+
function Install-PrintixClient {
50+
param (
51+
[string]$msiPath,
52+
[string]$wrappedArgs
53+
)
54+
Log-Message "Installing Printix Client..."
55+
$installProcess = Start-Process msiexec.exe -ArgumentList "/i `"$msiPath`" $wrappedArgs /qn /norestart" -PassThru -Wait
56+
57+
if ($installProcess.ExitCode -eq 0) {
58+
Log-Message "Printix Client installation completed successfully."
59+
Start-Sleep -Seconds 60
60+
Log-Message "Printix Client installation script completed successfully."
61+
exit 0
62+
} elseif ($installProcess.ExitCode -eq 1618) {
63+
Log-Message "Another installation is already in progress. Waiting before retrying..."
64+
Start-Sleep -Seconds 120
65+
Install-PrintixClient -msiPath $msiPath -wrappedArgs $wrappedArgs
66+
} else {
67+
Log-Message "Printix Client installation failed with exit code $($installProcess.ExitCode)."
68+
exit $installProcess.ExitCode
69+
}
70+
}
71+
72+
# Check if any .NET Runtime 6 version is installed by looking for the specific folders
73+
function Check-DotNetRuntime {
74+
$dotnetFolders = @(
75+
"C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App\",
76+
"C:\Program Files\dotnet\shared\Microsoft.NETCore.App\",
77+
"C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App\"
78+
)
79+
80+
foreach ($folder in $dotnetFolders) {
81+
if (-not (Get-ChildItem -Path $folder -Directory | Where-Object { $_.Name -like "6*" })) {
82+
Log-Message "Required .NET 6.x folder not found in: $folder"
83+
return $false
84+
}
85+
}
86+
87+
Log-Message ".NET Runtime 6.x is installed in all required folders."
88+
return $true
89+
}
90+
91+
# Function to install .NET Runtimes
92+
function Install-DotNetRuntimes {
93+
$dotnetInstallScript = "$dotNetInstaller"
94+
95+
if (-not (Test-Path $dotnetInstallScript)) {
96+
Log-Message "The dotnet-install.ps1 script was not found."
97+
exit 1
98+
}
99+
100+
Log-Message "Installing .NET Desktop Runtime 6.0.32..."
101+
& powershell -File $dotnetInstallScript -Runtime windowsdesktop -Channel 6.0 -Version 6.0.32
102+
Log-Message ".NET Desktop Runtime 6.0.32 installation completed."
103+
104+
Log-Message "Installing .NET ASP.NET Core Runtime 6.0.32..."
105+
& powershell -File $dotnetInstallScript -Runtime aspnetcore -Channel 6.0 -Version 6.0.32
106+
Log-Message ".NET ASP.NET Core Runtime 6.0.32 installation completed."
107+
108+
# Update PATH globally
109+
$dotnetPath = "C:\Program Files\dotnet"
110+
$existingPath = [System.Environment]::GetEnvironmentVariable("Path", "Machine")
111+
112+
if ($existingPath -notlike "*$dotnetPath*") {
113+
[System.Environment]::SetEnvironmentVariable("Path", "$existingPath;$dotnetPath", "Machine")
114+
Log-Message "PATH environment variable updated to include $dotnetPath."
115+
116+
# Refresh the current session to recognize the updated PATH
117+
$env:Path = [System.Environment]::GetEnvironmentVariable("Path", "Machine")
118+
} else {
119+
Log-Message "PATH environment variable already includes $dotnetPath."
120+
}
121+
}
122+
123+
# Main logic
124+
if (Check-DotNetRuntime) {
125+
Log-Message ".NET Runtime 6.x is already installed in all required folders."
126+
} else {
127+
Install-DotNetRuntimes
128+
}
129+
130+
# Proceed with Printix installation only if .NET Runtime is confirmed to be present in all required folders
131+
if (Check-DotNetRuntime) {
132+
# Check if the full registry entry exists
133+
if (Test-Path $regPath) {
134+
$currentVersion = (Get-ItemProperty -Path $regPath -Name "CurrentVersion").CurrentVersion
135+
$minVersion = "2.3.0.211"
136+
$comparison = Compare-Version $currentVersion $minVersion
137+
138+
if ($comparison -lt 0) {
139+
$uninstallerPath = "C:\Program Files\printix.net\Printix Client\unins000.exe"
140+
if (Test-Path $uninstallerPath) {
141+
Log-Message "Uninstalling existing Printix Client version $currentVersion..."
142+
Start-Process -FilePath $uninstallerPath -ArgumentList "/verysilent" -Wait
143+
Log-Message "Printix Client uninstalled successfully."
144+
}
145+
146+
Install-PrintixClient -msiPath $msiPath -wrappedArgs $wrappedArgs
147+
} elseif ($comparison -ge 0) {
148+
Log-Message "Current Printix Client version ($currentVersion) is up-to-date. No action required."
149+
exit 0
150+
}
151+
} else {
152+
if (Test-Path $parentRegPath) {
153+
Log-Message "Printix would be installed."
154+
Install-PrintixClient -msiPath $msiPath -wrappedArgs $wrappedArgs
155+
} else {
156+
Log-Message "Registry path $parentRegPath does not exist. Installing Printix Client."
157+
Install-PrintixClient -msiPath $msiPath -wrappedArgs $wrappedArgs
158+
}
159+
}
160+
} else {
161+
Log-Message "Skipping Printix Client installation due to missing .NET Runtime 6 in one or more required folders."
162+
exit 0
163+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<SoftwareIdentity tagId="wix:bundle/1BB295E8-8251-4404-96F1-C437DA87FCE0" name="Microsoft Windows Desktop Runtime - 6.0.32 (x64)" version="6.0.32.33814" versionScheme="multipartnumeric" xmlns="http://standards.iso.org/iso/19770/-2/2015/schema.xsd">
3+
<Entity name="Microsoft Corporation" regid="microsoft.com" role="softwareCreator tagCreator" />
4+
<Meta persistentId="wix:bundle.upgrade/E50DC420-5C2F-5516-1DA5-0F8B584F9E0D" />
5+
</SoftwareIdentity>

README.txt

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
Printix Deployment with .NET 6.x Runtime Check
2+
3+
Project Overview:
4+
5+
This project contains scripts and resources for deploying the Printix Client using Microsoft Intune while ensuring the necessary .NET 6.x runtimes are installed. This is necessary for deploying the new Printix client since the Tungsten Automation acquisition of Printix. .NET 6 is required prior to Printix install.
6+
The scripts are designed to handle cases where multiple versions of .NET may already be installed, and they ensure the Printix Client installation only proceeds if the required .NET 6.x runtimes are present in specific folders.
7+
8+
9+
Project Structure:
10+
11+
12+
Project Folder/
13+
14+
├── CLIENT_{<YOURCOMPANY>.printix.net}_{<TENANTID>}.MSI
15+
├── dotnet-install.ps1
16+
├── dotnet.exe
17+
├── hostfxr.dll
18+
├── install-dotnet.ps1
19+
├── Install-Printix.ps1
20+
├── Microsoft Windows Desktop Runtime - 6.0.32 (x64).swidtag
21+
└── README.txt
22+
23+
Files Description
24+
25+
CLIENT_{<YOURCOMPANY>.printix.net}_{<TENANTID>}.MSI
26+
The MSI installer for the Printix Client. You should replace this with your organization's Printix installer (MSI), which can be obtained from the Software dropdown in the Printix admin panel.
27+
28+
dotnet-install.ps1
29+
A script provided by Microsoft for installing various versions of .NET runtimes. This script is utilized to install the required .NET 6.x runtimes if they are not already present on the target system.
30+
31+
dotnet.exe
32+
The .NET executable file that will be placed in the appropriate directory as part of the installation process. (Can be found in a normal dotnet install at C:/Program Files/dotnet/)
33+
34+
hostfxr.dll
35+
A required DLL for .NET runtimes that will be copied to the target system as part of the installation process. (Can be found in a normal dotnet install at C:/Program Files/dotnet/)
36+
37+
install-dotnet.ps1
38+
This script checks the system for the presence of .NET 6.x runtimes in the specified folders. If the runtimes are missing, it uses dotnet-install.ps1 to install them.
39+
40+
Install-Printix.ps1
41+
The main script that performs the installation of the Printix Client. This script checks for the presence of .NET 6.x runtimes before proceeding with the Printix installation. If .NET 6.x is missing, it installs it first.
42+
43+
Microsoft Windows Desktop Runtime - 6.0.32 (x64).swidtag
44+
A software identification tag file that will be copied to the appropriate directory on the target system. (Can be found in a normal dotnet install at C:/Program Files/dotnet/)
45+
46+
47+
How to Use:
48+
49+
Pre-Requisites
50+
51+
Microsoft Intune: Ensure that your environment has Microsoft Intune set up for application deployment.
52+
Administrator Privileges: The scripts need to be run with administrator privileges to install software and modify system paths.
53+
54+
Steps to Deploy
55+
56+
Prepare Your Own Printix Installer:
57+
Replace the provided CLIENT_{<YOURCOMPANY>.printix.net}_{<TENANTID>}.MSI with your organization's Printix MSI installer.
58+
59+
Modify the Scripts:
60+
Update any hardcoded paths or variables in the scripts if your environment requires different paths.
61+
62+
Create an Intune Application Package:
63+
Package all the files in this project (except the README.txt) into a .intunewin file using the IntuneWinAppUtil tool.
64+
Create a new Windows app (Win32) deployment in Intune and upload the .intunewin file.
65+
66+
Configure Detection Rules:
67+
In Intune, set up detection rules for the Printix Client. You can use a registry path like:
68+
69+
70+
Path: HKEY_LOCAL_MACHINE\SOFTWARE\printix.net\Printix Client\CurrentVersion
71+
Value name: CurrentVersion
72+
Detection method: String comparison
73+
Operator: Equals
74+
Value: <expected Printix version>
75+
76+
This ensures that Intune can verify if the Printix Client is already installed.
77+
78+
Deploy to Devices:
79+
Assign the application to the target devices or groups in Intune.
80+
The script will ensure that .NET 6.x runtimes are installed before attempting to install the Printix Client.
81+
82+
What Happens During Execution:
83+
84+
Check for .NET 6.x Runtimes:
85+
The script Install-Printix.ps1 checks if any version of .NET 6.x is installed by verifying the existence of folders that start with "6" in the following directories:
86+
C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App\
87+
C:\Program Files\dotnet\shared\Microsoft.NETCore.App\
88+
C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App\
89+
90+
Install .NET 6.x if Required:
91+
If any of the required folders do not contain a 6.x version, the script installs .NET 6.0.32 using the install-dotnet.ps1 script.
92+
93+
Install Printix Client:
94+
After confirming that .NET 6.x is installed, the script proceeds to install the Printix Client using the provided MSI installer.
95+
96+
Logging:
97+
The script logs all actions and results in the C:/IntuneLogs directory, which can be useful for troubleshooting.
98+
99+
Modifications Required
100+
101+
Update Printix Installer:
102+
Replace the CLIENT_{<YOURCOMPANY>.printix.net}_{<TENANTID>}.MSI with your organization's MSI file.
103+
104+
Update Detection Rules:
105+
Ensure the detection rules in Intune match the version of Printix that you are deploying.
106+
107+
Optional Script Modifications:
108+
If your environment has different paths or requires additional configurations, modify the scripts accordingly.
109+
110+
Conclusion
111+
112+
This project provides a robust solution for deploying the Printix Client with the necessary .NET 6.x runtimes in environments managed by Microsoft Intune. By following the steps outlined in this README, you can ensure that the deployment is successful even in environments with multiple versions of .NET installed.

0 commit comments

Comments
 (0)