Skip to content

Instantly share code, notes, and snippets.

@rbleattler
rbleattler / Save-KBFile.ps1
Created January 14, 2020 21:02 — forked from potatoqualitee/Save-KBFile.ps1
Download Windows patch files / KB (patchid like KBxxxxx) and save them to disk using PowerShell
function Save-KBFile {
<#
.SYNOPSIS
Downloads patches from Microsoft
.DESCRIPTION
Downloads patches from Microsoft
.PARAMETER Name
The KB name or number. For example, KB4057119 or 4057119.
@rbleattler
rbleattler / Stop-SCCMOppression.ps1
Last active December 18, 2020 15:44
Stops SCCM Services and Scheduled tasks on local client to stop unannounced reboots
## Stop-SCCMOppression.ps1 ##
function Stop-SCCMOppression {
[CmdletBinding()]
param (
[switch]
$Enable
)
begin {
Write-Debug "Enter [$($PSCmdlet.MyInvocation.MyCommand.Name)]..."
$PSBoundParameters.Keys.ForEach{
@rbleattler
rbleattler / ChocoUpgrade.ps1
Last active February 16, 2021 21:27
This script will get ALL locally installed Chocolatey Packages, and upgrade ALL of them (assuming they have upgrades available) and log to $PWD\Logs\ChocoLog.txt
function Write-TimeStampOutput {
Param(
[Parameter()]
[String]
$InputObject,
[Parameter(ParameterSetName = 'LongDateTime', Mandatory)]
[switch]
$LongDateTime,
[Parameter(ParameterSetName = 'ShortDateTime', Mandatory)]
[switch]
@rbleattler
rbleattler / MouseScrollTools.ps1
Created February 17, 2021 16:04
PowerShell Mouse Scroll Wheel Tools
function Get-MouseScrollDirection {
[CmdletBinding()]
param (
)
begin {
Write-Debug "Enter [$($PSCmdlet.MyInvocation.MyCommand.Name)]..."
$PSBoundParameters.Keys.ForEach{
if ($PSBoundParameters.PSItem -is [string]) {
Write-Debug "$_ : $($PSBoundParameters.Item($_))"
} else {
@rbleattler
rbleattler / Set-NaturalScrolling.ps1
Last active February 17, 2021 16:27
Enable/Disable Natural Mouse Scrolling in Windows via PowerShell (requires restart to take effect)
param (
[Parameter(ParameterSetName = 'Enable', Mandatory)]
[switch]
$Enable,
[Parameter(ParameterSetName = 'Disable', Mandatory)]
[switch]
$Disable
)
function Set-MouseScrollDirection {
@rbleattler
rbleattler / Write-Verbose.ps1
Created February 18, 2021 14:57
PowerShell Write Verbose with Timestamp Parameter
function Write-Verbose {
[CmdletBinding()]
Param(
[Parameter(Mandatory, ValueFromPipeline, Position = 0)]
[string]
$Message,
[Parameter()]
[switch]
$TimeStamp
)
@rbleattler
rbleattler / Get-RepositoryStats.ps1
Created March 3, 2021 15:29
A useful tool that can determine Work Directory information such as number of files and directories, as well as the number of characters and lines in the files + some Easter Eggs ;)
function Get-RepositoryStats {
[CmdletBinding()]
param (
[string]
$WorkDirectory,
[switch]
$UseGitignore,
[switch]
$Novels
)
@rbleattler
rbleattler / Get-FileAttributes.ps1
Created March 8, 2021 15:35
PowerShell Function: Get Extended File Attributes
function Get-FileAttributes {
[CmdletBinding()]
param (
[string]
$FilePath
)
begin {
Write-Debug "Enter [$($PSCmdlet.MyInvocation.MyCommand.Name)]..."
$PSBoundParameters.Keys.ForEach{
if ($PSBoundParameters.PSItem -is [string]) {
@rbleattler
rbleattler / AdvancedFunction.powershell.snippet
Last active March 23, 2021 19:09
A VSCode PowerShell snippet that builds an advanced function template with begin/process/end, and transcript logging.
# @prefix Function Advanced
# @description Advanced Function Block
function Write-MyFunction {
[CmdletBinding()]
param (
$$MyVariable1
)
begin {
Write-Debug "Enter [$($$PSCmdlet.MyInvocation.MyCommand.Name)]..."
@rbleattler
rbleattler / ConvertFrom-HashTable.ps1
Last active March 23, 2021 18:58
Converts [HashTable]s to [PSCustomObject]s
function ConvertFrom-HashTable {
<#
.SYNOPSIS
This function will convert a hashtable to a [PSCustomObject]
.DESCRIPTION
This command will convert a hashtable to a [PSCustomObject]
.EXAMPLE
PS C:\> $HashTable
Name Value