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
| # ISE Addons | |
| if (-not ($psISE)){ | |
| throw 'Must run in PowerShell ISE' | |
| } | |
| #region Helper Functions | |
| $null = Add-Type -AssemblyName Microsoft.PowerShell.GPowerShell,WindowsBase,Microsoft.VisualBasic,PresentationCore |
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
| # Command to place id_rsa.pub file in the correct location on remote server | |
| cat ~/.ssh/id_rsa.pub | ssh username@remote_host "mkdir -p ~/.ssh && touch ~/.ssh/authorized_keys && chmod -R go= ~/.ssh && cat >> ~/.ssh/authorized_keys" |
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
| #!/bin/bash | |
| # Clone all github.com repositories for the specified user. | |
| # Validate username was specified | |
| if [ $# -eq 0 ] | |
| then | |
| echo "Usage: $0 <user_name> " | |
| exit; | |
| fi |
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 WshShell = CreateObject("WScript.Shell") | |
| Set objFSO = CreateObject("Scripting.FileSystemObject") | |
| WinLicKey = ConvertToKey(WshShell.RegRead("HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\DigitalProductId")) | |
| ' Change path in line below to save win-key.txt in another location | |
| outFile = WshShell.ExpandEnvironmentStrings("%UserProfile%") + "\Desktop\win-key.txt" | |
| Set objFile = objFSO.CreateTextFile(outFile,True) |
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.1 | |
| if (-NOT ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)) { | |
| Start-Process -FilePath powershell.exe -ArgumentList '-File',('"{0}"' -f $MyInvocation.MyCommand.Path) -Verb RunAs | |
| exit | |
| } | |
| $file = Join-Path -Path $PSScriptRoot -ChildPath 'Windows10Upgrade9252.exe' | |
| if (Test-Path -Path $file){ |
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
| # Error Management | |
| try { | |
| Made-to-Fail | |
| } | |
| catch { | |
| [System.Management.Automation.ErrorRecord]$e = $_ | |
| [PSCustomObject]@{ | |
| Type = $e.Exception.GetType().FullName | |
| Exception = $e.Exception.Message | |
| Reason = $e.CategoryInfo.Reason |
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 -RunAsAdministrator | |
| @( | |
| "$env:windir\System32\WindowsPowerShell\v1.0\profile.ps1", | |
| "$env:windir\System32\WindowsPowerShell\v1.0\Microsoft.PowerShell_profile.ps1", | |
| "$env:windir\System32\WindowsPowerShell\v1.0\Microsoft.PowerShellISE_profile.ps1", | |
| "$env:USERPROFILE\Documents\WindowsPowerShell\profile.ps1", | |
| "$env:USERPROFILE\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1", | |
| "$env:USERPROFILE\Documents\WindowsPowerShell\Microsoft.PowerShellISE_profile.ps1" | |
| ).ForEach({ |
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 | |
| using namespace System.Management.Automation | |
| using namespace System.Management.Automation.Language | |
| using namespace Microsoft.PowerShell | |
| #~~#~~#~~#~~#~#~~#~~#~~#~~#~#~~#~~#~~#~~#~#~~#~~#~~#~~# | |
| $FormatEnumerationLimit = -1 | |
| #~~#~~#~~#~~#~#~~#~~#~~#~~#~#~~#~~#~~#~~#~#~~#~~#~~#~~# | |
| # Chocolatey profile | |
| $ChocolateyProfile = Join-Path -Path $env:ChocolateyInstall -ChildPath 'helpers\chocolateyProfile.psm1' -Resolve -ErrorAction Ignore | |
| if ($ChocolateyProfile) { Import-Module -Global -Name $ChocolateyProfile -PassThru:$false -ErrorAction SilentlyContinue -WarningAction Ignore } |
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
| # https://www.myerrorsandmysolutions.com/how-to-uninstall-older-versions-of-a-powershell-module-installed/ | |
| param( | |
| [Parameter(Mandatory)] | |
| [string]$ModuleName | |
| ) | |
| $Latest = Get-InstalledModule -Name $ModuleName | |
| Get-InstalledModule -Name $ModuleName -AllVersions | Where-Object {$_.Version -ne $Latest.Version} | Uninstall-Module -Confirm |
OlderNewer