Last active
February 2, 2022 23:52
-
-
Save kilasuit/54b34164fb3588b027eaef4456b938de to your computer and use it in GitHub Desktop.
functions for enabling/disabling Website access via hosts file.
This file contains 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
#Requires -RunAsAdministrator | |
#Requires -Module @{ ModuleName = 'PSHosts'; | |
RequiredVersion = '1.2.2' } | |
Function New-WebSiteHostEntry { | |
[CmdletBinding()] | |
[Alias('NWA')] | |
param ( | |
# Parameter help description | |
[Parameter()] | |
[switch] | |
$SocialMediaSites, | |
[Parameter()] | |
[switch] | |
$NewsSites | |
) | |
If($SocialMediaSites) { | |
"t.co","twitter.com","facebook.com","messenger.com","linkedin.com" | ForEach-Object {Add-HostEntry -Name $_ -Address '0.0.0.0' -Enabled $true -Force} | |
} | |
If($NewsSites) { | |
"bbc.co.uk","vice.com","theguardian.com","msn.com","news.sky.com" | ForEach-Object {Add-HostEntry -Name $_ -Address '0.0.0.0' -Enabled $true -Force} | |
} | |
} | |
function Enable-WebsiteAccess { | |
[CmdletBinding()] | |
[Alias('EWA')] | |
param ( | |
# Parameter help description | |
[Parameter()] | |
[switch] | |
$SocialMediaSites, | |
[Parameter()] | |
[switch] | |
$NewsSites | |
) | |
If($SocialMediaSites) { | |
"t.co","twitter.com","facebook.com","messenger.com","linkedin.com" | ForEach-Object {Get-HostEntry -Name $_ | Disable-HostEntry} | |
} | |
If($NewsSites) { | |
"bbc.co.uk","vice.com","theguardian.com","msn.com","news.sky.com" | ForEach-Object {Get-HostEntry -Name $_ | Disable-HostEntry} | |
} | |
} | |
function Disable-WebsiteAccess { | |
[CmdletBinding()] | |
[Alias('DWA')] | |
param ( | |
# Parameter help description | |
[Parameter()] | |
[switch] | |
$SocialMediaSites, | |
[Parameter()] | |
[switch] | |
$NewsSites | |
) | |
If($SocialMediaSites) { | |
"t.co","twitter.com","facebook.com","messenger.com","linkedin.com" | ForEach-Object {Get-HostEntry -Name $_ | Enable-HostEntry} | |
} | |
If($NewsSites) { | |
"bbc.co.uk","vice.com","theguardian.com","msn.com","news.sky.com" | ForEach-Object {Get-HostEntry -Name $_ | Enable-HostEntry} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment