Guest User

Torguard Netflix Launcher/Updater

a guest
May 6th, 2016
635
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. $DedicatedIPPath  = ('HKCU:\SOFTWARE\VPNetworkLLC\TorGuard\server-sites\dedicated-ip')
  2. $DedicatedIPSize  = (Get-ItemProperty -Path $DedicatedIPPath |
  3.                      Select-Object -ExpandProperty 'Size')
  4. $RemoveStaleKeys  = (Get-ChildItem $DedicatedIPPath |
  5.                      Where-Object `
  6.                      {
  7.                         $_.PSChildname -gt "$DedicatedIPSize"
  8.                      } |
  9.                      Remove-Item -Force -InformationAction SilentlyContinue)
  10. $NetflixIPKey     = (Get-ChildItem $DedicatedIPPath -Recurse |
  11.                      ForEach-Object {Get-ItemProperty -Path Registry::$_} |
  12.                      Where-Object {$_.Comment -Contains "Netflix"} |
  13.                      Select-Object -First 1)
  14. $DedicatedIPCount = (Get-ChildItem $DedicatedIPPath -Recurse ).Count
  15. $NewNetflixIP     = (Resolve-Dnsname -DnsOnly -Name 'watch.torguard.org' -Server '8.8.8.8' |
  16.                      Select-Object -ExpandProperty 'IP4Address')
  17. $Registrykeys     = @{'Country-Code' = 'USA';
  18.                       'Comment'      = 'Netflix';
  19.                       'IP-Address'   = "$NewNetflixIP"}
  20. $TorguardLocation = (Get-ItemProperty -Path ('HKLM:\software\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\VPNetwork LLC TorGuard\') |
  21.                      Select-Object -ExpandProperty 'InstallLocation').Trim('""') + '\TorguardDesktopQt.exe'
  22.  
  23. IF ($DedicatedIPSize -gt 0)
  24. {
  25.     IF ($NetflixIPKey -eq $Null)
  26.     {
  27.         $DedicatedIPCount++
  28.         New-Item         -Path $DedicatedIPPath -Name $DedicatedIPCount -Force | Out-Null
  29.         Set-ItemProperty -Path $DedicatedIPPath -Name Size -Value $DedicatedIPCount -Force | Out-Null
  30.  
  31.         ForEach ($Value in $Registrykeys.GetEnumerator())
  32.         {
  33.         New-ItemProperty -Path $DedicatedIPPath\$DedicatedIPCount -Name $Value.Name -Value $Value.Value -PropertyType String -Force | Out-Null
  34.         }
  35.     }
  36.     ELSE
  37.     {
  38.         ForEach ($Value in $Registrykeys.GetEnumerator())
  39.         {
  40.         New-ItemProperty -Path $NetflixIPKey.PSPath -Name $Value.Name -Value $Value.Value -PropertyType String -Force | Out-Null
  41.         }
  42.     }
  43. }
  44. ELSE
  45. {
  46.     $DedicatedIPCount++
  47.     New-Item         -Path $DedicatedIPPath -Name $DedicatedIPCount -Force | Out-Null
  48.     Set-ItemProperty -Path $DedicatedIPPath -Name Size -Value $DedicatedIPCount -Force | Out-Null
  49.  
  50.     ForEach ($Value in $Registrykeys.GetEnumerator())
  51.     {
  52.         New-ItemProperty -Path $DedicatedIPPath\$DedicatedIPCount -Name $Value.Name -Value $Value.Value -PropertyType String -Force | Out-Null
  53.     }
  54. }
  55.  
  56. & $TorGuardLocation
Add Comment
Please, Sign In to add comment