Skip to content

Instantly share code, notes, and snippets.

@csdy
Created January 15, 2020 05:09
Show Gist options
  • Save csdy/4167436e20a9f3b56dc0c8489900da8d to your computer and use it in GitHub Desktop.
Save csdy/4167436e20a9f3b56dc0c8489900da8d to your computer and use it in GitHub Desktop.
[PowerShell] Firewall Dropbox Lan Sync
$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