Deploying PowerShell script via an Intunewin app

Resource - Link
Resource - Link

Script has NO REBOOT -

Example from Resource 2 -

Install Command - powershell.exe -ExecutionPolicy Bypass -File Install-TheThing.ps1
Uninstall Command - powershell.exe -ExecutionPolicy Bypass -File Uninstall-TheThing.ps1

Script has this -
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Search /V SearchboxTaskbarMode /t REG_DWORD /d 0

Added user - user05

From the link


$registryPath = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System"
$Name = "scforceoption"

New-ItemProperty -Path $registryPath -Name $name -Value $value -PropertyType DWORD -Force | Out-Null

Save the script as smartcard.ps1 in a empty folder.

In the folder containing the ps1 file create an install.cmd file. Paste the following code:
powershell.exe -executionpolicy bypass -command "& '.\SmartCard.ps1' 1"

Along with the install.cmd file create an uninstall.cmd file. Paste the following code:
powershell.exe -executionpolicy bypass -command "& '.\SmartCard.ps1' 0"

You should now have a folder containing smartcard.ps1, install.cmd and uninstall.cmd.


You now need to download the Intune-Win32-App-Packaging-Tool from the official Microsoft GitHub repository.

Once downloaded extract the contents then launch an elevated command prompt. Change directory to the extracted location. Run the IntuneWinAppUtil.exe application.
1. Please specify the source folder: paste the full path to your folder containing smartcard.ps1, install.cmd and uninstall.cmd
2. Please specify the setup file: SmartCard.ps1
3. Please specify the output folder: Paste any path you want to save the intunewin file too.


Next from the Intune portal > Client Apps select Add App
App Type: Windows app (Win32)
App Package File: Choose your SmartCard.intunewin file
App Information: Fill as you like
a. Install Command: install.cmd
b. Uninstall Command: uninstall.cmd
c. Install Behaviour: choose system or user
Requirements: Choose OS and architecture
Detection rules: (Because we are changing a registry setting it is easy to detect by using the manually configure detection rules option)
a. Rule Type: Registry
b. Key Path: HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System
c. Value Name: scforceoption
d. Detection Method: Integer Comparison
e. Operator: Equals
f. Value: 1
Select Add


No comments:

Post a Comment