This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # filename: Lock_and_power_off_display.ps1 | |
| # | |
| # This script turns off the display and locks the workstation using the Windows API. | |
| # | |
| # Warning: This script will turn off the display and lock the workstation indefinitely until stopped manually. | |
| # | |
| # Import the necessary libraries for interacting with the Windows API | |
| Add-Type @" | |
| using System; | |
| using System.Runtime.InteropServices; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <# | |
| .SYNOPSIS | |
| Get the volumes attached to the EC2 instances. | |
| .DESCRIPTION | |
| This function retrieves the volumes attached to the specified EC2 instances in the | |
| specified region. It returns a list of volume details including the instance ID, | |
| instance name, instance type, volume ID, device name, state, availability zone, | |
| volume type, IOPS, throughput, and size. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $files = Get-ChildItem -Path "A:\Phoenix" | |
| # Define the comment start and end markers | |
| $commentStart = '/*' | |
| $commentEnd = '*/' | |
| foreach ($file in $files) { | |
| # Open the file and read the first 1024 bytes | |
| $maxBytes = 1024 | |
| $buffer = New-Object byte[] $maxBytes |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <# Table Export #> | |
| $someTables = @" | |
| TBL_A_FOO | |
| TBL_B_BAR | |
| TBL_C_BAZ | |
| TBL_D_QUX | |
| TBL_E_QUUX | |
| TBL_F_CORGE | |
| "@.split("`n").TrimEnd("`r") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| -- database_role_securables_query.sql | |
| -- modeled after SSMS Securables page of Database Roles properties | |
| DECLARE @RoleName NVARCHAR(128); | |
| SET @RoleName = ''; -- Replace with role name or leave empty for testing | |
| IF @RoleName = '' | |
| BEGIN | |
| SELECT 'Please provide a valid role name to query securables' AS Message; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Store TimeSpan object in variable $timespan | |
| $timespan = New-TimeSpan -Start (Get-Date) -End (Get-Date).AddHours(5) #(Get-Date).AddDays(1).Date.AddHours(5) #careful with this - syntax is weird | |
| # Print a message to the console in magenta color indicating the time the script will resume execution | |
| Write-Host -ForegroundColor magenta "Sleeping until $((Get-date).AddSeconds($timespan.TotalSeconds)) ..." | |
| # Pause the execution of the script for a number of seconds equal to the total seconds of the $timespan | |
| Start-Sleep -Seconds $timespan.TotalSeconds |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #requires -version 5.0 | |
| #Requires -RunAsAdministrator | |
| <# DANGER REBOOTING! | |
| This is meant for a local machine in a scheduled task | |
| and is not handling remoting or remote credentials | |
| #> | |
| [CmdletBinding()] | |
| param ( | |
| [Parameter()][int]$DelayMinutes = 15 #default to 15 minute delay if this parameter is not supplied | |
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function Get-ExplicitLogonEvents { | |
| <# | |
| .SYNOPSIS | |
| Gets 4648 Explicit Logon Events from Windows Event Log | |
| Author: Lee Christensen (@tifkin_) | |
| # https://github.com/threatexpress/red-team-scripts/blob/3121db5d53a25d66afa01afb3bf0487d919d1846/HostEnum.ps1#L1552 | |
| #> | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| | File: ServiceBrokerLogNoiseReductionEndpoint.sql | |
| | Description: 🚦 Creates a Service Broker endpoint to reduce SQL Server log noise. | |
| | Purpose: Sets up a dedicated endpoint for Service Broker on a user-chosen | |
| | port (default 4022), with checks for port conflicts and robust | |
| | logging. Useful for DBAs who want to keep error logs clean and | |
| | avoid noisy Service Broker errors. Includes optional code to drop | |
| | the endpoint. For test/dev use or advanced troubleshooting. 😎 | |
| | Created: 2024-05-21 | |
| | Modified: 2025-05-22 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <# | |
| .SYNOPSIS | |
| Finds the recommended N-1 cumulative update for SQL Server based on patching strategy that avoids intermediate releases | |
| .DESCRIPTION | |
| This script queries a Google Sheets document containing SQL Server cumulative update information | |
| and determines the recommended N-1 cumulative update based on a patching strategy that avoids | |
| intermediate releases (e.g., hotfixes, security updates) between cumulative updates. | |
| The script outputs the recommended cumulative update, its release date, and a link to more details. | |
| The patching strategy is defined as follows: |