Skip to content

Instantly share code, notes, and snippets.

View realslacker's full-sized avatar

Shannon Graybrook realslacker

View GitHub Profile
<#
.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 / 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
@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
@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 / 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
@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 / 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 / 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 / mRemoteNG-Password-Util.psm1
Last active November 15, 2020 18:59
Work with mRemoteNG passwords... Functionality has been rolled into https://github.com/realslacker/PSmRemoteNG
Add-Type -Path 'C:\Program Files (x86)\mRemoteNG\BouncyCastle.Crypto.dll'
function ConvertFrom-MRNGSecurePassword {
param(
[Parameter(Mandatory)]
[ValidateNotNullOrEmpty()]
[string]
$EncryptedMessage,
@realslacker
realslacker / Invoke-GPOScriptReport.ps1
Created May 20, 2019 19:49
Get all Group Policy Objects with scripts
Import-Module GroupPolicy -ErrorAction Stop
Get-GPO -All |
ForEach-Object { Write-Host ( 'Processing GPO ''{0}''...' -f $_.DisplayName ); $_ } -pv 'GPO' |
Get-GPOReport -ReportType Xml |
ForEach-Object { [xml]$_ } |
foreach-Object {
$_.GPO.User.ExtensionData |
Where-Object { $_.Name -eq 'Scripts' } |