Skip to content

Instantly share code, notes, and snippets.

View realslacker's full-sized avatar

Shannon Graybrook realslacker

View GitHub Profile
@realslacker
realslacker / WmiNameSpaceSecurity.psm1
Created April 16, 2019 20:01
A module with expanded functionality base on original work by Steve Lee and Graeme Bray. See Set-WMINameSpaceSecurity.ps1 for original.
<#
Disclaimer:
This module is provided AS IS without warranty of any kind. This work is based off work by
other talented individuals, and should not be considered an original work.
Modified into module by Shannon Graybrook
Modified by Graeme Bray
Original Content by Steve Lee
@realslacker
realslacker / wmi_filters.ps1
Created February 23, 2019 22:12
WMI Filters
# filter for server core
$Query = 'SELECT * FROM Win32_OptionalFeature WHERE Caption = "Microsoft-Windows-Server-Gui-Shell-Package-DisplayName" AND InstallState = "2"'
Get-WmiObject -Query $Query
@realslacker
realslacker / Restart-ComputerWhen.ps1
Created February 22, 2019 16:47
Schedule a restart at a specific time
# the same script as a one liner:
# shutdown -r -t ( [math]::Ceiling( ([datetime]"1PM").Subtract((Get-Date)).TotalSeconds )
param(
[Parameter(Mandatory=$true)]
[datetime]
$When
)
$Now = Get-Date
@realslacker
realslacker / PowerShell Menu Fixes.reg
Created January 12, 2019 01:39
Changes PowerShell right click menu items so that it (1) doesn't try to change the execution policy and (2) add's run as and run as user options for scripts.
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\Microsoft.PowerShellScript.1]
"EditFlags"=dword:00020000
"FriendlyTypeName"=hex(2):40,00,22,00,25,00,73,00,79,00,73,00,74,00,65,00,6d,\
00,72,00,6f,00,6f,00,74,00,25,00,5c,00,73,00,79,00,73,00,74,00,65,00,6d,00,\
33,00,32,00,5c,00,77,00,69,00,6e,00,64,00,6f,00,77,00,73,00,70,00,6f,00,77,\
00,65,00,72,00,73,00,68,00,65,00,6c,00,6c,00,5c,00,76,00,31,00,2e,00,30,00,\
5c,00,70,00,6f,00,77,00,65,00,72,00,73,00,68,00,65,00,6c,00,6c,00,2e,00,65,\
00,78,00,65,00,22,00,2c,00,2d,00,31,00,30,00,33,00,00,00
@ECHO OFF
SET mytime=%time: =0%
SET dtstamp=%date:~-4%%date:~4,2%%date:~7,2%%mytime:~0,2%%time:~3,2%%time:~6,2%
notepad %TEMP%\cert_%dtstamp%.req
certreq -submit -attrib "CertificateTemplate:WebServer10Y" %TEMP%\cert_%dtstamp%.req %TEMP%\cert_%dtstamp%.cer
notepad %TEMP%\cert_%dtstamp%.cer
SET /P answer=Save the generated certificate? (y/N)
@realslacker
realslacker / clear icon cache.cmd
Created October 31, 2018 15:29
Clear the icon cache to fix Windows 10 start menu icons
ie4uinit.exe -ClearIconCache
taskkill /IM explorer.exe /F
DEL "%localappdata%\IconCache.db" /A
explorer
@realslacker
realslacker / Reset-OutlookProfile.ps1
Last active October 31, 2018 15:24
This script will remove all present outlook profiles and associated files, allowing an out-of-box experience.
[CmdletBinding(SupportsShouldProcess, ConfirmImpact='High')]
param(
[string]
$NewProfileName = 'Outlook'
)
Add-Type -AssemblyName PresentationFramework -Verbose:$false
<#
.SYNOPSIS
Signs a PS1 script with the local users code signing certificate.
.DESCRIPTION
Takes a PS1 file as an argument and signs with the local user's code signing certificate.
Optionally allows specification of a timestamp server.
.PARAMETER Path
A PS1 file to sign. Accepts pipeline input.
.PARAMETER TimestampServer
An optional parameter specifying a timestamp server. The default is 'http://timestamp.comodoca.com/authenticode'.
@realslacker
realslacker / Get-CurrentUserCompatibilityModeSettingForGPP.ps1
Last active October 2, 2018 17:50
Pulls the current user's Compatibility Mode settings from the registry and creates a Group Policy Registry Preference XML string for pasting into Group Policy Manager.
<#PSScriptInfo
.VERSION 2018.10.02.1248
.GUID 75bfca34-ff9c-4cac-beab-51a685d42c44
.AUTHOR Shannon Brooks
.COMPANYNAME Brooksworks
@realslacker
realslacker / Submit-OutlookMessageToHelpdesk.ps1
Created September 17, 2018 18:48
Sends selected messages from Outlook through an SMTP relay to your helpdesk email. Allows redirecting arbitrary emails to a helpdesk email for ZenDesk.
# compile command:
# ps2exe.ps1 -inputFile .\Submit-OutlookMessageToHelpdesk.ps1 -outputFile .\Submit-OutlookMessageToHelpdesk.exe -runtime40 -x86 -noConsole -iconFile .\forward_email.ico
$ForwardTo = "Help Desk <helpdesk@domain.com>"
$SmtpServer = "smtp.corp.domain.com"
$SmtpUseSSL = $true
[void][System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms")
Add-Type -AssemblyName System.Drawing
Add-Type -AssemblyName Microsoft.Office.Interop.Outlook