Skip to content

Instantly share code, notes, and snippets.

View micmaher's full-sized avatar

Michael Maher micmaher

  • Home
  • Dublin, Ireland
View GitHub Profile
# PowerShell 2.0 Compatible Web Call deployed as an SCCM Package
$h = get-hotfix | where {$_.HotFixID -eq 'KB3050265'}
If ($h){
# Already Installed
$uri = "http://webserver/winupdate/wuaccept.asp?installed='$env:COMPUTERNAME','Yes'"
(New-Object System.Net.WebClient).DownloadString($uri)
Exit
}
@micmaher
micmaher / enableContosoUser.ps1
Last active April 22, 2016 13:44
PowerShell Script - Enables user account, creates home drive, creates DFS link, sets permissions on home drive, sets 2GB quota
#Requires RunAsAdministrator
<######################################################################################
.AUTHOR
Michael Maher
.DATE
08/01/16
.NOTE
Expects CSV in format of username, new password, old username
#Requires RunAsAdministrator
Function Create-WindowsForm(){
<#
.DATE
11/3/16
.NOTE
Send username, new password, old
Enables user account, creates home drive
@micmaher
micmaher / signScript.ps1
Last active April 20, 2016 12:57
Sign Scripts
# Michael Maher
# 25/9/15
# Sign Script
# Usage: signScript.ps1 <path to script>
param (
$myScript = $(throw "Please specify a path to the script
For Example: .\signScript c:\scripts\archiveSecLog.ps1")
)
@micmaher
micmaher / CitrixPermstoAGDLP.ps1
Last active April 15, 2016 09:40
Change Citrix Permissions to meet AGDLP rule
$csvFile = "C:\temp\CtxGroups2.csv"
import-module activeDirectory
############################### 1. Get the Citrix Groups ################################
# Run in MWTRADERS Domain
Get-ADGroup -Filter * -SearchBase "ou=Retail,ou=Dublin,dc=contoso,dc=com" | Select Name, distinguishedName | Export-Csv $csvFile
break
################################ 2. Create a Domain Local equivalent on IE ################################
@micmaher
micmaher / putACESonSharedMBX.ps1
Created April 10, 2016 19:29
Change Shared Mailbox Permissons
# Michael Maher
# 22/5/13
# Get ACLs from CSV and write to AD
$arrRecord = @()
$spreadsheet = Import-Csv C:\scripts\ACLs2.csv
# Get just the mailbox name which will be used to create group names later
# Store this in an array so we can sort it and get unique values later
# Also need a second array with the full email address and ACL for applying permissions later
@micmaher
micmaher / getLastLoginDatefromEPO.sql
Created April 10, 2016 19:19
Get Last Login Date from EPO
USE [build]
GO
/****** Object: StoredProcedure [dbo].[EPOLastLogon2] ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- ================================================================
-- Author: Michael Maher
-- Create date: 12th June 2014
@micmaher
micmaher / getForwardingAddr.ps1
Created March 31, 2016 20:56
Gets mailboxes that have forwarders in place, the contact they use, the contacts address and if Store and Forward is on
# Gets mailboxes that have forwarders in place, the contact they use, the contacts address and if Store and Forward is on
$fwds = get-mailbox -ResultSize Unlimited | Where-Object { $_.ForwardingAddress -ne $null } | select Name, Alias, ForwardingAddress
foreach ($fwd in $fwds) {
$fwd | add-member -membertype noteproperty -name "ContactAddress" -value (get-contact $fwd.ForwardingAddress).WindowsEmailAddress
}
Write-Output $fwds | Format-Table -Autosize | Out-String -Width 10000 | Out-File -FilePath c:\temp\output.txt
#Requires -Modules ConfigurationManager
# Needs Configuration Manager Cmdlets from . . .
# https://technet.microsoft.com/en-us/library/dn958404%28v=sc.20%29.aspx
$list = Invoke-Sqlcmd -Query "SELECT host FROM BUILD.DBO.SCCMBLOCK;" -ServerInstance "MYSQLSVR"
$collectionname = 'Blocked Clients'
Set-Location IRL:
foreach($c in $list.host) {
@micmaher
micmaher / noEPOcontact5Days.sql
Created March 30, 2016 10:51
Workstations on the network having not contacted EPO in 5 days
USE [build]
GO
/****** Object: StoredProcedure [dbo].[AVRule1] Script Date: 30/03/2016 11:45:37 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author: Michael Maher
-- Create date: 10 January 2012