Skip to content

Instantly share code, notes, and snippets.

View zailleh's full-sized avatar

Tim Caldwell zailleh

View GitHub Profile
@zailleh
zailleh / Service-WiFi-LAN-Autoswitch.ps1
Last active May 4, 2018 01:50
Script to be compiled into a Service that will automatically switch off Wi-Fi when an Ethernet connection is detected and switch it back on when no Ethernet connection is detected.
#"Running" | Out-File "C:\Temp\Service.log" -append
Do {
#"Start Of Loop" | Out-File "C:\Temp\Service.log" -append
$Adaptors = Get-WmiObject -query "SELECT * FROM Win32_NetworkAdapter WHERE PhysicalAdapter = 1 AND NOT Description LIKE '%Virtual%' AND (NetConnectionID LIKE '%Wireless Network Connection%' OR NetConnectionID LIKE '%Local Area Connection%' OR NetConnectionID LIKE '%Wi-Fi%' OR NetConnectionID LIKE '%Ethernet%')"
$NetEnabledAdaptors = @($Adaptors | Where {$_.NetEnabled -eq $true}).Count
#"Adaptors Found: $($Adaptors.Count)" | Out-File "C:\Temp\Service.log" -append
#"Net Enabled Adaptors: $NetEnabledAdaptors" | Out-File "C:\Temp\Service.log" -append
if ($NetEnabledAdaptors -gt 1)
{
#"WiFi and LAN Connected. Disabling WiFi..." | Out-File "C:\Temp\Service.log" -append
<###############################################################################
Import-ADSites
################################################################################
DEPENDENCIES: Powershell Module - ActiveDirectory
SQL Access to referenced SQL server and Database
DESCRIPTION: Adds new AD Sites to LANSweeper and schedules a scan of
their IP subnets.
  CHANGE LOG:
@zailleh
zailleh / Create-ADUser
Last active May 16, 2022 04:59
Automated AD User Account Creation
<#
.SYNOPSIS
Creates new users via PIPS K2
.DESCRIPTION
This script takes input from variables given to it by K2 and creates
a new user to Lion spec
.PARAMETER <paramName>
$firstName - First name of the New Starter
$lastName - Last name of the New Starter
$middleName - Middle Name of the New Starter
@zailleh
zailleh / ArchiveFileServer.ps1
Created February 22, 2013 04:36
This script takes your command-line input for the root source and dest. folders and will copy (archive) any files older than the $days specified. By doing it folder by folder (not using the recursive parameter and piping results to copy individual files) we build a relatively small list of files and process those before moving to the next folder…
################################################################################
# FILE ARCHIVING SCRIPT #
#*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*&&*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*#
# AUTHOR: Tim Caldwell DATE: 22/02/2013 #
# DESCRIPTION: #
# This script takes your command-line input for the root source and dest. #
# folders and will copy (archive) any files older than the $days specified #
################################################################################
################################################################################