Skip to content

Instantly share code, notes, and snippets.

@ddhahn
ddhahn / AddComptoGPOACL.ps1
Created February 1, 2013 16:52
Add a Computers directly to a GPO ACL with Read and Apply permissions. May be useful for ad-hoc testing of GPO's
$names = Get-Content c:\temp\gpolist.txt
foreach ($name in $names) {
set-gppermissions -name "GPOName" -permissionlevel gpoRead -targetname "$name" -targettype computer
set-gppermissions -name "GPOName" -permissionlevel gpoapply -targetname "$name" -targettype computer
}
@ddhahn
ddhahn / GetDebugs.ps1
Created February 1, 2013 16:58
Get a file from a servers in a list
function WriteLog($info, $errormsg=$false)
{
#Funtion will write log entries along with a time and date stamp
$nowdate = date -format G
if ($errormsg) {
Write-Host "[$nowdate] $info" -foregroundcolor Red
}
else {
Write-Host "[$nowdate] $info"
@ddhahn
ddhahn / StopFLMM.ps1
Created February 1, 2013 17:01
Stop a few services on a list of computers
function WriteLog($info, $errormsg=$false)
{
#Funtion will write log entries along with a time and date stamp
$nowdate = date -format G
if ($errormsg) {
Write-Host "[$nowdate] $info" -foregroundcolor Red
}
else {
Write-Host "[$nowdate] $info"
@ddhahn
ddhahn / PSTSearch.ps1
Created February 1, 2013 17:08
Count PST files in a list of paths
$pstcount =0
$totalsize=0
$totalsizegb=0
$officepstcount=0
$officepstaverage=0
$officepsttotal=0
$file = new-item -type file -path "c:\temp\pstsearch-stats.txt" -force
$detailfile = new-item -type file -path "c:\temp\pstsearch-details.txt" -force
##Get List of servers from the input file
@ddhahn
ddhahn / FixVMWareNic.ps1
Created February 1, 2013 17:13
Script to change VMWare's NIC adapter types so that it doesn't influence the Windows Firewall's understanding of how the machine is connected to the network. This can be useful when using VMWare workstation. I found it on the web somewhere.. can't remember where.
# see http://msdn2.microsoft.com/en-us/library/bb201634.aspx
#
# *NdisDeviceType
#
# The type of the device. The default value is zero, which indicates a standard
# networking device that connects to a network.
#
# Set *NdisDeviceType to NDIS_DEVICE_TYPE_ENDPOINT (1) if this device is an
# endpoint device and is not a true network interface that connects to a network.
# For example, you must specify NDIS_DEVICE_TYPE_ENDPOINT for devices such as
@ddhahn
ddhahn / KillProcess.au3
Created February 3, 2013 01:12
Kills all processes matching a name.
#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Icon=..\Users\ddhahn\Downloads\scb.ico
#AutoIt3Wrapper_Res_requestedExecutionLevel=asInvoker
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
;Kill Outlooks script
$pid = processexists("outlook.exe")
while $pid <> 0
MsgBox(1,"Outlook Killed","Outlook.exe (" & $pid & ") has been killed")
@ddhahn
ddhahn / SwitchtoSpareDesktop.au3
Created February 3, 2013 01:29
Switch to a desktop named sparedesktop
#include <winapiex.au3>
#include <apiconstants.au3>
;+--- switch to the desktop named sparedesktop
; Switch to the newly created desktop
_WinAPI_SwitchDesktop($hDesktop)
$hPrev = _WinAPI_GetThreadDesktop(_WinAPI_GetCurrentThreadID())
$hDesktop = _WinAPI_CreateDesktop('MyDesktop', BitOR($DESKTOP_CREATEWINDOW, $DESKTOP_SWITCHDESKTOP))
If Not $hDesktop Then
sgBox(16, 'Error', 'Unable to create desktop.')
Exit
@ddhahn
ddhahn / ElevateThis.au3
Last active December 12, 2015 02:38
Envoke UAC to elevate a command
#NoTrayIcon
#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Outfile=elevate_this.exe
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
;Run a script using shellexecute runas. This will run the application/script
;at the highest available privilege level. Depending on UAC settings, this may
;cause a UAC prompt.
;Examples:
@ddhahn
ddhahn / WMItoOEMINFO.au3
Created February 3, 2013 01:33
Writes data from WMI to OEMINFO.ini
;Generate oeminfo.ini from wmi
;WMI stuff taken from: http://cyrusbuilt.net/wordpress/?p=79
$objWMI = ObjGet("winmgmts:\\localhost\root\CIMV2")
$wbemFlagReturnImmediately = 0x10
$wbemFlagForwardOnly = 0x20
$objItems = $objWMI.ExecQuery("SELECT * FROM Win32_ComputerSystem", "WQL", 0x10 + 0x20)
If IsObj($objItems) Then
@ddhahn
ddhahn / Progress.au3
Created February 3, 2013 01:59
Sample progress meter in AutoIT
ProgressOn("Progress Meter", "Increments every second", "0 percent")
For $i = 10 to 100 step 10
sleep(1000)
ProgressSet( $i, $i & " percent")
Next
ProgressSet(100 , "Done", "Complete")
sleep(500)
ProgressOff()