Powershell as win32 not working

Iron Contributor


Hello everyone,


I've been working on deploying a script to prevent a user from using Chrome:

# Check if the script is running with administrator privileges if (-not ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")) { Write-Host "Please run this script as an administrator." Exit } # Define the path to chrome.exe $chromeExePath = "C:\Program Files\Google\Chrome\Application\chrome.exe" # Create a new firewall rule to block chrome.exe New-NetFirewallRule -DisplayName "Block Chrome" -Direction Outbound -Program $chromeExePath -Action Block # Verify the rule $rule = Get-NetFirewallRule -DisplayName "Block Chrome" if ($rule) { Write-Host "Successfully blocked Chrome." } else { Write-Host "Failed to create the firewall rule." }


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."



Screenshot 2023-10-24 at 14.45.23.png

The install fails, any ideas where I am going wrong? 

3 Replies

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.

Hi, So what would it look like?
best response confirmed by ABill1 (Iron Contributor)

@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