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
| # Copyright: (c) 2024, Jordan Borean (@jborean93) <jborean93@gmail.com> | |
| # MIT License (see LICENSE or https://opensource.org/licenses/MIT) | |
| Function New-ScheduledTaskSession { | |
| <# | |
| .SYNOPSIS | |
| Creates a PSSession for a process running as a scheduled task. | |
| .DESCRIPTION | |
| Creates a PSSession that can be used to run code inside a scheduled task |
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
| # zshenv path_helper issue script. | |
| # Source: https://gist.github.com/romanr/2c5ee2eafc284a2530cdb6b8d64d929c | |
| # Based on https://gist.github.com/Linerre/f11ad4a6a934dcf01ee8415c9457e7b2 | |
| # | |
| # if [ -f "/etc/zprofile" ] && grep -q "path_helper" "/etc/zprofile"; then | |
| # echo "WARNING: 'path_helper' in '/etc/zprofile', please remove it." >&2 | |
| # echo "Path helper 'path_helper' will execute after the one in this '~/.zshenv' file and" >&2 | |
| # echo "potentially reorder paths." >&2 | |
| # fi | |
| unsetopt GLOBAL_RCS |
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
| # PowerShell Script to Download and Install Python 3.10.11 | |
| # This script automates the process of downloading and installing Python 3.10.11. | |
| # It includes error handling, version checking, admin privilege checking, installer validation, and post-installation cleanup. | |
| # Check if Python 3.10.11 is already installed | |
| $installedVersion = & python --version 2>&1 | |
| if ($installedVersion -match "Python 3.10.11") { | |
| Write-Host "Python 3.10.11 is already installed. Exiting..." | |
| exit | |
| } |
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 -Module PSDetour | |
| [CmdletBinding()] | |
| param ( | |
| [Parameter(Mandatory)] | |
| [string] | |
| $LogPath | |
| ) | |
| $LogPath = $ExecutionContext.SessionState.Path.GetUnresolvedProviderPathFromPSPath($LogPath) |
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
| using namespace System.Management.Automation | |
| using namespace System.Management.Automation.Language | |
| if ($host.Name -eq 'ConsoleHost') | |
| { | |
| Import-Module PSReadLine | |
| } | |
| #Import-Module PSColors | |
| #Import-Module posh-git | |
| Import-Module -Name Terminal-Icons |
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 | |
| Requires powershell 5 or later | |
| Provides Get and Set functions for KnownFolders | |
| .EXAMPLE | |
| PS> Set-KnownFolderPath Desktop $ENV:USERPROFILE/Desktop | |
| .EXAMPLE | |
| PS> $Path="" | |
| PS> Get-KnownFolderPath Desktop ([ref]$Path) | |
| .LINK |
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
| # Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser | |
| # src: https://gist.github.com/apfelchips/62a71500a0f044477698da71634ab87b | |
| # New-Item $(Split-Path "$($PROFILE.CurrentUserCurrentHost)") -ItemType Directory -ea 0; Invoke-WebRequest -Uri "https://git.io/JYZTu" -OutFile "$($PROFILE.CurrentUserCurrentHost)" | |
| # ref: https://devblogs.microsoft.com/powershell/optimizing-your-profile/#measure-script | |
| # ref: Powershell $? https://stackoverflow.com/a/55362991 | |
| # ref: Write-* https://stackoverflow.com/a/38527767 | |
| # Write-Host wrapper for Write-Information -InformationAction Continue |
This is to try and document the behaviour around PowerShellGet/PSResourceGet code signing publisher behaviour.
The following code can be used to set up this scenario. This must be run as an administrator in Windows PowerShell.
Note: PowerShell uses implicit remoting for the New-SelfSignedCertificate which breaks the constains serialization. You must run this on Windows PowerShell.
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
| # Personal preference. I like landing on the Desktop | |
| Set-Location $Env:USERPROFILE\Desktop | |
| $currentPrincipal = New-Object Security.Principal.WindowsPrincipal([Security.Principal.WindowsIdentity]::GetCurrent()) | |
| # If the current session is elevated, prefix the prompt with '[Admin]' | |
| if ($currentPrincipal.IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)) { | |
| Set-Item -Path Function:\prompt -Value "`"[Admin] PS $($executionContext.SessionState.Path.CurrentLocation)$('>' * ($nestedPromptLevel + 1)) `"" | |
| } |
NewerOlder