Skip to content

Instantly share code, notes, and snippets.

Avatar

Shannon Graybrook realslacker

View GitHub Profile
@realslacker
realslacker / Invoke-GPOScriptReport.ps1
Created May 20, 2019
Get all Group Policy Objects with scripts
View Invoke-GPOScriptReport.ps1
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' } |
@realslacker
realslacker / mRemoteNG-Password-Util.psm1
Last active Nov 15, 2020
Work with mRemoteNG passwords... Functionality has been rolled into https://github.com/realslacker/PSmRemoteNG
View mRemoteNG-Password-Util.psm1
Add-Type -Path 'C:\Program Files (x86)\mRemoteNG\BouncyCastle.Crypto.dll'
function ConvertFrom-MRNGSecurePassword {
param(
[Parameter(Mandatory)]
[ValidateNotNullOrEmpty()]
[string]
$EncryptedMessage,
@realslacker
realslacker / WmiNameSpaceSecurity.psm1
Created Apr 16, 2019
A module with expanded functionality base on original work by Steve Lee and Graeme Bray. See Set-WMINameSpaceSecurity.ps1 for original.
View WmiNameSpaceSecurity.psm1
<#
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
View wmi_filters.ps1
# 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 Feb 22, 2019
Schedule a restart at a specific time
View Restart-ComputerWhen.ps1
# 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 Jan 12, 2019
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.
View PowerShell Menu Fixes.reg
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
View webserver cert-req.cmd
@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 Oct 31, 2018
Clear the icon cache to fix Windows 10 start menu icons
View clear icon cache.cmd
ie4uinit.exe -ClearIconCache
taskkill /IM explorer.exe /F
DEL "%localappdata%\IconCache.db" /A
explorer
@realslacker
realslacker / Reset-OutlookProfile.ps1
Last active Oct 31, 2018
This script will remove all present outlook profiles and associated files, allowing an out-of-box experience.
View Reset-OutlookProfile.ps1
[CmdletBinding(SupportsShouldProcess, ConfirmImpact='High')]
param(
[string]
$NewProfileName = 'Outlook'
)
Add-Type -AssemblyName PresentationFramework -Verbose:$false
View Add-SignatureToScript.ps1
<#
.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'.