Created
January 15, 2020 05:09
-
-
Save csdy/4167436e20a9f3b56dc0c8489900da8d to your computer and use it in GitHub Desktop.
[PowerShell] Firewall Dropbox Lan Sync
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$myWindowsID = [System.Security.Principal.WindowsIdentity]::GetCurrent(); | |
$myWindowsPrincipal = New-Object System.Security.Principal.WindowsPrincipal($myWindowsID); | |
$adminRole = [System.Security.Principal.WindowsBuiltInRole]::Administrator; | |
if ($myWindowsPrincipal.IsInRole($adminRole)) | |
{ | |
$Host.UI.RawUI.WindowTitle = $myInvocation.MyCommand.Definition + "(Elevated)"; | |
$Host.UI.RawUI.BackgroundColor = "DarkBlue"; | |
Clear-Host; | |
} | |
else { | |
$newProcess = New-Object System.Diagnostics.ProcessStartInfo "PowerShell"; | |
$newProcess.Arguments = "& '" + $script:MyInvocation.MyCommand.Path + "'" | |
$newProcess.Verb = "runas"; | |
[System.Diagnostics.Process]::Start($newProcess); | |
Exit; | |
} | |
New-NetFirewallRule -DisplayName "Block Dropbox Lan Sync" -Direction Outbound -RemotePort 17500 -Protocol UDP -Action Block | |
New-NetFirewallRule -DisplayName "Block Dropbox Lan Sync" -Direction Inbound -LocalPort 17500 -Protocol UDP -Action Block | |
Write-Host -NoNewLine "Press any key to continue..."; | |
$null = $Host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment