Recently Added

Notes & Bookmarks

  1. Quasars; power and metrics beyond all comprehension. Staggeringly beautiful information... and very well written.
  2. "I'm sorry. I can't come in today. Religious holiday. The feast of...Maximum Occupancy."pic.twitter.com/mkgxPWfNj2
  3. Verifying myself: I am sgnls on Keybase.io. UJa01G4v3YRJYB1LFjDRSf1Nh0bh1sOykCbq / https://keybase.io/sgnls/sigs/UJa01G4v3YRJYB1LFjDRSf1Nh0bh1sOykCbq
  4. Be sure to take care of your own infrastructure(s); purge dumps, tunnel and lock-down egress transit, encrypt and permission CORRECTLY!
  5. It really doesn't matter what else gets released; Sikth's 'The Future in Whose Eyes?' is THE album of 2017. #albumoftheyear @SikthOfficialpic.twitter.com/P5houdf1yx

Update Domain Workstations Hosts File

Updated : 12:29:47pm, 12th Mar 2016

Almost identical to the last nugget, you can use this as a tweak to update all the local hosts file on workstations in a domain;

## machine scope(s)
$comps_all_ws = get-adcomputer -searchbase "dc=domain,dc=local" -filter {OperatingSystem -notlike "*Server*"} | select Name -expandproperty Name | sort-object -descending

## globals
$log_file = "c:\host_change.txt"
$log_file_off = "c:\host_change-offline.txt"
$host_file = "\\$comp\c$\Windows\system32\Drivers\etc\hosts"
$ip = "10.3.1.6"
$host_record = "server    server.domain.local"

## update cycle
foreach($comp in $comps_test){

      ## check machine if online, else ignore
      if(test-connection $comp -count 1 -quiet){
                  
            $check_hosts = @(get-content $host_file | where-object {$_.Contains("$ip")}).count

            if($check_hosts -eq "1"){
                  write-host "Record exists in $comp"
                  add-content "$log_file" "Record exists in $comp"
            }
            else{
                  write-host "Record does not exist in $comp. Updating hosts file..."
                  add-content "$log_file" "Record does not exist in $comp. Updating hosts file..."

                  add-content "$host_file" "`n$ip `t $host_record"

                  $check_host = @(get-content $host_file | where-object {$_.Contains("$ip")}).count

                  if($check_host -eq "1"){
                        write-host "Record now exists in $comp"
                        add-content "$log_file" "Record now exists in $comp"
                  }
                  else{
                        write-host "Record does not exist in $comp and has not been added."
                        add-content "$log_file" "Record does not exist in $comp and has not been added."
                  }

            }
            
      }
      else{ 
            write-host "$comp is offline. `n"
            add-content "$log_file_off" "$comp is offline. `n"
      }

}

SGNLS.net © 2006-2017

Comments, submissions and errors to desk[at]sgnls.net.

Material and content adheres to the Creative Commons (NC-SA 4.0) license.

v12.01151