Skip to content

Instantly share code, notes, and snippets.

@theagreeablecow
theagreeablecow / setupnewuser.ps1
Created May 24, 2012 10:30
Setup New User in AD, Exchange and Lync
# This script will set up AD, User Directories, Exchange and Lync, using basic data retrived from a CSV file
# Requires the Active Directory module for Windows Powershell and appropriate credentials
# CSV file with corresponding header and user(s) info:
# Office,UserName,FirstName,LastName,Initial,Department,Role,Title,SetupSameAs,Manager,MailboxAccess,Extension,Mobile
#LOAD POWERSHELL SESSIONS
#------------------------
$exchangeserver = "exchange1.domain.com"
$Lyncserver = "lync1.domain.com.au"
@theagreeablecow
theagreeablecow / DepartingUser.ps1
Created May 26, 2012 00:55
Disable a user is AD, Exchange and Lync
# This script manages the process for a departing user, using data retrived from a CSV file
# Requires the Active Directory module for Windows Powershell and appropriate credentials
# CSV file with corresponding header and user(s) info:
# UserName,DisableWindows,ArchiveFiles,DisableVoice,ArchiveMailbox,MailboxAccessTo,DisableEmailAddress,AutoReplyContact,ReminderInDays
#LOAD POWERSHELL SESSIONS
#------------------------
@theagreeablecow
theagreeablecow / SetupPrinters.hta
Created May 26, 2012 07:28
Network Printers App
<html>
<head>
<meta http-equiv="Content-Language" content="en-us">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<!-- Printer Installation -->
<title>Printers App</title>
<HTA:APPLICATION ID="PrintHta"
@theagreeablecow
theagreeablecow / ServerInventory.ps1
Created May 26, 2012 22:52
Server Inventory from Active Directory
# This script will generate a list of all servers in AD, collect inventory items and export to Excel
# Requires the Active Directory module for Windows Powershell and appropriate credentials
#LOAD POWERSHELL SESSIONS
#------------------------
$DC = "dc1.maydomain.com.au"
$usercredential= get-credential -credential mydomain\admin
$Path = "\\mydomain.com.au\Scripts\Data\"
$ExportFile = $Path + "ServerInventory.csv"
@theagreeablecow
theagreeablecow / PsListKill.vbs
Created May 28, 2012 03:45
Process List and Kill
' Produces list of process info from a remote computer. Optionally kill a running process based on PID.
' Requires PsList and PsKill from PsTools http://technet.microsoft.com/en-us/sysinternals/bb896649.aspx
' TheAgreeableCow 2012
dim objShell : Set objShell = WScript.CreateObject ("WScript.shell")
dim fileSys : Set fileSys = CreateObject("Scripting.FileSystemObject")
dim strComputer, strCMD, strLog, intAnswer, strProcess, strBatchFile, strDate
strComputer = InputBox("Enter name of Server/PC to capture process list")
@theagreeablecow
theagreeablecow / Print_ServerJobLogs.ps1
Created June 2, 2012 01:00
Print Server Job Logs from Event Viewer to CSV using Get-WinEvent and XML queries
<#
.SYNOPSIS
Print server job logs from Event Viewer to csv file
.DESCRIPTION
This script uses Get-WinEvent and XML queries to retrieve EventID 307 job logs from print servers.
Specifically querying the Microsoft-Windows-PrintService/Operational log.
Log is extracted to a CSV file and optionally emailed.
.PARAMETER FileName
@theagreeablecow
theagreeablecow / filterxml.ps1
Created June 2, 2012 02:23
Event Log XML Filter
$filterxml = '<QueryList>
<Query Id="0" Path="Microsoft-Windows-PrintService/Operational">
<Select Path="Microsoft-Windows-PrintService/Operational">*[System[(EventID=307)]]</Select>
</Query>
</QueryList>'
$EventLog = Get-WinEvent -Filterxml $filterXml
@theagreeablecow
theagreeablecow / logparameters.ps1
Created June 2, 2012 02:27
Event log Parameters
ForEach ($LogEntry in $EventLog)
{
$entry = [xml]$LogEntry.ToXml()
$docName = $entry.Event.UserData.DocumentPrinted.Param2
}
@theagreeablecow
theagreeablecow / Lync_GetUnassignedNumbers.ps1
Created June 6, 2012 05:09
Get Unassigned Numbers in Lync 2010
<#
.SYNOPSIS
Find assigned or unassigned numbers in Lync
.DESCRIPTION
This script uses uses the 'Unassigned Number' ranges in Lync to look number usage, including:
- User numbers (including Private Number)
- Analogue Devices
- Common Area Phones
- AutoAttendant numbers
@theagreeablecow
theagreeablecow / MultiRobocopy.vbs
Created June 6, 2012 11:31
Multiple Robocopy Streams
Option Explicit
On Error Resume Next
Dim Source1, Source2, Source3, Destination1, Destination2, Destination3, BatchFile1, BatchFile2, BatchFile3
'******************************************
'Root Source folders to parse
Source1 = "\\server1\c$\folder1"
Source2 = "\\server1\share1"
Source3 = "\\server1\share2"