Skip to content

Instantly share code, notes, and snippets.

View micmaher's full-sized avatar

Michael Maher micmaher

  • Home
  • Dublin, Ireland
View GitHub Profile
@micmaher
micmaher / ArchiveEvtLogs.ps1
Created March 19, 2016 08:44
Move Security Logs to Archive Point
<#
.DESCRIPTION
Move Security Logs to Archive Point
.REQUIREMENTS
1. Create Shares
Invoke-Command -ComputerName dc1,dc3,dc4,dc5,dc2 -ScriptBlock {
New-SmbShare Seclog$ -Path E:\Seclog -fullaccess "CONTOSO\Domain Admins"}
@micmaher
micmaher / Format Numbers
Created March 22, 2016 13:10
.NET Framework formatting
$a = 348
"{0:N2}" -f $a # Numeric to 2 decimal places = 348.00
"{0:D8}" -f $a # Decimal 8 places = 00000348
"{0:C2}" -f $a # Currency to two places = €348.00
"{0:P0}" -f $a # Percentage x 100 = 34,800 %
"{0:X0}" -f $a # Hex = 15C
@micmaher
micmaher / RemoveOldHomeDir.ps1
Created March 24, 2016 14:18
Remove Old home Directories
<######################################################################################
.AUTHOR
Michael Maher
.DATE
14/01/16
.NOTE
Removes old home drives
@micmaher
micmaher / Connect-Camera.ps1
Created March 28, 2016 18:49
FTP Module for managing Foscam Recordings
#Requires -Modules PSFTP
Function Connect-Camera
{
<#
.SYNOPSIS
Connects to Security Camera to get video
.DESCRIPTION
Can wipe videos or download
@micmaher
micmaher / packageMgmt.ps1
Created March 28, 2016 19:10
A collection of Package Management commands
# Get through proxy challenge
$wc = New-Object System.Net.WebClient
$wc.Proxy.Credentials = [System.Net.CredentialCache]::DefaultNetworkCredentials
$wc.DownloadString('http://microsoft.com')
Install-PackageProvider -Name NuGet -Force
Get-PackageProvider
Find-Package *MVA* -Source psgallery
Find-Package *MVA* -Source psgallery | select -Property summary
# M.Maher
# 3/3/16
# Check out all 'Get-' network cmdlets
$commands = Get-Command *net* |
where {$_.commandtype -eq 'Function' -or $_.commandtype -eq 'Cmdlet' -and $_.Name -like "Get-*" }|
select name
foreach ($c in $commands){
$c.Name
@micmaher
micmaher / noEPOcontact30Days.sql
Created March 30, 2016 10:42
Workstations on the network having not contacted EPO in 30 days
USE [build]
GO
/****** Object: StoredProcedure [dbo].[AVRule5] ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author: Michael Maher
-- Create date: 25 August 2015
@micmaher
micmaher / outDateDATFiles.sql
Created March 30, 2016 10:48
Find Outdated DAT files
USE [build]
GO
/****** Object: StoredProcedure [dbo].[AVRule3] Script Date: 30/03/2016 11:45:34 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- ================================================================
-- Author: Michael Maher
-- Create date: 12th January 2012
@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
#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) {