Oct 24 2023 06:44 AM - edited Oct 24 2023 06:45 AM
Hello everyone,
I've been working on deploying a script to prevent a user from using Chrome:
This script is functional.
I also have another script called install.ps1 that installs it. The installation command is:
powershell.exe -ExecutionPolicy Bypass -File Blockchrome.ps1
I package the install.ps1 as the source for the intunewin file and then deploy it to the desired devices.
Detection script:
# Check if the "Block Chrome" firewall rule exists
$rule = Get-NetFirewallRule -DisplayName "Block Chrome"
if ($rule) {
Write-Host "Firewall rule 'Block Chrome' already exists."
} else {
Write-Host "Firewall rule 'Block Chrome' does not exist."
}
The install fails, any ideas where I am going wrong?
Oct 25 2023 06:15 AM - edited Oct 25 2023 06:17 AM
In the Detection script, you have to do an output (which you did using Write-Host), but you have to exit with 0 if successful (exit 0). Exit with 1 if failed, in which case the install script should run (exit 1)
Please click Mark as Best Response & Like if my post helped you to solve your issue.
This will help others to find the correct solution easily. It also closes the item.
If one of the posts was helpful in other ways, please consider giving it a Like.
Oct 25 2023 09:56 AM
Solution@ABill1 Like this:
# Check if the "Block Chrome" firewall rule exists
$rule = Get-NetFirewallRule -DisplayName "Block Chrome"
if ($rule) {
Write-Host "Firewall rule 'Block Chrome' already exists."
Exit 0
} else {
Write-Host "Firewall rule 'Block Chrome' does not exist."
Exit 1
}