Skip to content

Instantly share code, notes, and snippets.

@endoleg
endoleg / ExtractAllScripts.ps1
Created January 4, 2023 14:38 — forked from vikas891/ExtractAllScripts.ps1
A PowerShell script to re-construct a suspicious .PS1 from script-blocks recorded in Event ID 4104
#Usage:
#
#NOTE: Remember to include the path to Microsoft-Windows-PowerShell%4Operational.evtx below.
#
#C:\>ExtractAllScripts.ps1
#The default behavior of the script is to assimilate and extract every script/command to disk.
#
#C:\ExtractAllScripts -List
#This will only list Script Block IDs with associated Script Names(if logged.)
#
@endoleg
endoleg / Write-Log.ps1
Created January 3, 2022 12:53 — forked from markwragg/Write-Log.ps1
Simple PowerShell logging function with timestamp, redirects messages to a log file and the verbose stream.
function Write-Log {
Param(
$Message,
$Path = "$env:USERPROFILE\log.txt"
)
function TS {Get-Date -Format 'hh:mm:ss'}
"[$(TS)]$Message" | Tee-Object -FilePath $Path -Append | Write-Verbose
}
@endoleg
endoleg / Get-AdobeFlashMsi.ps1
Created May 1, 2021 15:05 — forked from jasonadsit/Get-AdobeFlashMsi.ps1
Get-AdobeFlashMsi.ps1
#Requires -Version 2
function Get-AdobeFlashMsi {
[CmdletBinding()]
param (
[string]
$Destination = $(Join-Path -Path $env:USERPROFILE -ChildPath 'Downloads' ),
<#
.SYNOPSIS
This script performs the installation or uninstallation of an application(s).
# LICENSE #
PowerShell App Deployment Toolkit - Provides a set of functions to perform common application deployment tasks on Windows.
Copyright (C) 2017 - Sean Lillis, Dan Cunningham, Muhammad Mashwani, Aman Motazedian.
This program is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU Lesser General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.
.DESCRIPTION
The script is provided as a template to perform an install or uninstall of an applica
@endoleg
endoleg / downloadTerraform.ps1
Created October 13, 2020 12:20 — forked from rchaganti/downloadTerraform.ps1
Download and Install Terraform - Windows (PowerShell)
[CmdletBinding(DefaultParameterSetName='Version')]
param
(
[Parameter(ParameterSetName='Latest', Mandatory = $true)]
[Parameter(ParameterSetName='Version', Mandatory = $true)]
[String]
$SaveToPath,
[Parameter(ParameterSetName='Version', Mandatory = $true)]
[String]
function Get-PSADTAppVersion {
<#
.SYNOPSIS
Gets the $appversion varible for a given PSADT package
.DESCRIPTION
Gets the $appversion varible for a given PSADT package
Queries the Deploy-Application.ps1 file for "appversion"
Takes the first string returned. I don't care about other occerences in the file
Converts it to a string
<#
.SYNOPSIS
This script performs the installation or uninstallation of an application(s).
.DESCRIPTION
The script is provided as a template to perform an install or uninstall of an application(s).
The script either performs an "Install" deployment type or an "Uninstall" deployment type.
The install deployment type is broken down into 3 main sections/phases: Pre-Install, Install, and Post-Install.
The script dot-sources the AppDeployToolkitMain.ps1 script which contains the logic and functions required to install or uninstall an application.
.PARAMETER DeploymentType
The type of deployment to perform. Default is: Install.
### "#region AND #endregion HELP MAKE SCRIPTS COLLAPSIBLE WITHIN THE ISE" ###
### FIND AND CHANGE THE <WHATEVER> PLACEHOLDERS I PUT AS I SCRUBBED THE FILE ###
### PLACE THIS FILE IN THE FOLLOWING FOLDER (CREATE IT IF IT DOESN'T EXIST) : C:\USERS\<USERNAME>\DOCUMENTS\WINDOWSPOWERSHELL ###
#region Console Customization
#ELEVATED CONSOLE?
[System.Security.Principal.WindowsPrincipal]$global:currentUser =
New-Object System.Security.Principal.WindowsPrincipal([System.Security.Principal.WindowsIdentity]::GetCurrent())
if($global:currentUser.IsInRole([System.Security.Principal.WindowsBuiltInRole]::Administrator)) {
@endoleg
endoleg / PSADT-Cheatsheet.ps1
Created July 24, 2020 08:52 — forked from leeramsay/PSADT-Cheatsheet.ps1
PSADT snippits/cheatsheet
## Commonly used PSADT env variables
$envCommonDesktop # C:\Users\Public\Desktop
$envCommonPrograms # C:\ProgramData\Microsoft\Windows\Start Menu\Programs
$envProgramFiles # C:\Program Files
$envProgramFilesX86 # C:\Program Files (x86)
$envProgramData # c:\ProgramData
$envUserDesktop # c:\Users\{user currently logged in}\Desktop
$envUserStartMenuPrograms # c:\Users\{user currently logged in}\AppData\Roaming\Microsoft\Windows\Start Menu\Programs
$envSystemDrive # c:
$envWinDir # c:\windows
<#
This snippet is for use in a PSADT script. It assumes you have added parameters, or hardcoded the following
* $DeploymentID - The deployment ID of the task sequence you want to check the cache for, and which will be invoked
* $CheckAC - A boolean (or switch) that determines if you want to force the user to plug in prior to upgrading. This step is only check if
the pre-caching has passed
#>
#region Validate that all content is pre-cached so we do not bother the user until the TS is ready to start
$TS = Get-WmiObject -Namespace ROOT\ccm\Policy\Machine\ActualConfig -Class CCM_SoftwareDistribution -Filter "ADV_AdvertisementID='$DeploymentID'" -Property PKG_PackageID, PKG_Name
if ($null -ne $TS) {