Skip to content

Bug: Incorrect WhatIf check in Disable-LanmanCache.ps1 #3

@leonardokr

Description

@leonardokr

Description

In Disable-LanmanCache.ps1, the restart prompt guard uses if (-not $WhatIf), but $WhatIf is never declared as a parameter. It will always evaluate to $null (falsy), so the restart prompt always appears regardless of -WhatIf usage.

Expected Behavior

When running with -WhatIf, the restart prompt (Read-Host) should be suppressed.

Actual Behavior

$WhatIf is always $null, so the prompt always shows. The ShouldProcess calls on the registry operations work correctly, but the restart prompt escapes the WhatIf guard.

Fix

Replace if (-not $WhatIf) with a proper check, such as:

if (-not $WhatIfPreference) {
    # prompt for restart
}

Files Affected

  • Scripts/Registry/Disable-LanmanCache.ps1

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions