Guest User

Untitled

a guest
Jun 24th, 2018
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.22 KB | None | 0 0
  1. & {
  2. $wid=[System.Security.Principal.WindowsIdentity]::GetCurrent()
  3. $prp=new-object System.Security.Principal.WindowsPrincipal($wid)
  4. $adm=[System.Security.Principal.WindowsBuiltInRole]::Administrator
  5. $IsAdmin=$prp.IsInRole($adm)
  6. if (-not $IsAdmin)
  7. {
  8. Write-Host -ForegroundColor Yellow "This needs to be run as administrator."
  9. Write-Host -ForegroundColor Yellow "Please open a new powershell as administrator, and try again."
  10. exit 2
  11. }
  12. else
  13. {
  14. $install = "acrylic-dns-proxy poshgit vagrant-manager"
  15. foreach ($program in @("git", "vagrant", "virtualbox", "vim")) {
  16. if (Get-Command -Name "${program}.exe" -ErrorAction SilentlyContinue) {
  17. Write-Host "Not installing ${program} bc it appears to already be installed."
  18. } else {
  19. $install = "${install} ${program}"
  20. }
  21. }
  22.  
  23. foreach ($program in @("github", "googlechrome", "vscode")) {
  24. $doIt = Read-Host -Prompt "Shall I install the ${program} App? (y/N)"
  25. if ($doIt -match "^y") { $install = "${install} ${program}" }
  26. }
  27.  
  28. Write-Host -ForegroundColor DarkMagenta "Point DNS settings at localhost? (Y/n)"
  29. $changeDns = Read-Host -Prompt "Choose yes if you don't know the answer."
  30. Write-Host ""
  31. Write-Host "Now is a good time to get a cup of coffee."
  32. Invoke-Expression -Command "choco.exe install -y $install"
  33.  
  34. $hostsFile = "C:\Program Files (x86)\Acrylic DNS Proxy\AcrylicHosts.txt"
  35. '192.168.56.4 >dev' | Out-File -Encoding ASCII -Append $hostsFile
  36.  
  37. if (-not ($changeDns -match "^(n|N)")) {
  38. $connection = netsh interface ip show interfaces |
  39. Where-Object {$_ -match " connected"} |
  40. Where-Object {(-not ($_ -match "Loopback")) -and (-not ($_ -match "VirtualBox"))} |
  41. Select-Object -First 1
  42. $connectionName = [regex]::Match($connection, "connected (.*)$").captures.groups[1].value
  43. netsh.exe interface ip set dns "${connectionName}" static 127.0.0.1
  44. Write-Host -ForegroundColor DarkYellow "Done."
  45. }
  46.  
  47. Write-Host "Done. Woo hoo! Better restart your computer now."
  48. }
  49. }
Add Comment
Please, Sign In to add comment