Skip to content

Instantly share code, notes, and snippets.

@whonion
Created December 27, 2023 04:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save whonion/9143f51859c0a9e4b829ce4fd8fd1966 to your computer and use it in GitHub Desktop.
Save whonion/9143f51859c0a9e4b829ce4fd8fd1966 to your computer and use it in GitHub Desktop.
$hostsFilePath = "%systemroot%\System32\drivers\etc\hosts"
$linesToAdd = @(
"127.0.0.1 activate.adobe.com",
"127.0.0.1 practivate.adobe.com",
"127.0.0.1 lmlicenses.wip4.adobe.com",
"127.0.0.1 lm.licenses.adobe.com",
"127.0.0.1 na1r.services.adobe.com",
"127.0.0.1 hlrcv.stage.adobe.com",
"127.0.0.1 genuine.adobe.com",
"127.0.0.1 prod.adobegenuine.com"
)
# Check if the file exists
if (Test-Path $hostsFilePath) {
# Read the existing content
$existingContent = Get-Content $hostsFilePath -Raw
# Check if the lines already exist in the file
$linesToAdd | ForEach-Object {
if ($existingContent -notcontains $_) {
# Append the line to the file
Add-Content -Path $hostsFilePath -Value $_
Write-Host "Line added to hosts file: $_"
} else {
Write-Host "Line already exists in hosts file: $_"
}
}
} else {
Write-Host "Error: Hosts file not found at $hostsFilePath"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment