Skip to content

Instantly share code, notes, and snippets.

View TravisEz13's full-sized avatar
🎯
Focusing

Travis Plunk TravisEz13

🎯
Focusing
View GitHub Profile
f13d5fd1-fa6a-4f9e-88d4-8b15ea0dba4c
@TravisEz13
TravisEz13 / VerifyModulePublisher.ps1
Last active October 29, 2020 18:41
Script to verify module publisher
param(
[string]
$ModuleName = 'nimbus'
)
$module = Get-Module -ListAvailable $ModuleName | Sort-Object -Descending Version | Select-object -First 1
if(!$module)
{
throw "Module $module not found"
}
@TravisEz13
TravisEz13 / instructions.md
Created May 11, 2020 22:59
Instruction to install test for latest snap fix

Instructions

If you haven't installed the powershell snap

sudo snap install powershell --classic --channel=edge/useedge

If you have installed the powershell snap

param(
[parameter(Mandatory)]
[string]$Url,
[parameter(Mandatory)]
[string]$Pat,
[parameter(Mandatory)]
[string]$Pool
)
$ErrorActionPreference = 'stop'
Set-ExecutionPolicy -ExecutionPolicy Bypass -Scope Process
Invoke-WebRequest -Uri https://raw.githubusercontent.com/PowerShell/PowerShell/master/tools/install-powershell.ps1 -OutFile install-powershell.ps1
./install-powershell.ps1
param(
[uri] $sasUrl,
[string] $path,
[string] $container = 'signing-upload'
)
$filename = split-path -leaf $path
$newurl=[System.UriBuilder]::new($sasurl)
$newurl.path="/$container/$filename"

An Introduction to Error Handling in PowerShell

Originally by Keith Babinec, published a MSDN.

Current version is moved to by blog here

Today’s post (and this blog's inaugural post!) is An Introduction to Error Handling in PowerShell. We will discuss error types, the $error variable, error action preferences, try/catch blocks, and $lastexitcode.

The first requirement is to understand the types of errors that can occur during execution.

Describe 'verify testdrive:' {
BeforeAll {
$testPath = 'TestDrive:/test.txt'
'test' | out-file -path $testPath
}
it 'verify file' {
Get-Content -path $testPath | should -be 'test'
}
@TravisEz13
TravisEz13 / snapd-classic.md
Last active February 1, 2018 19:31
Classic mode support on snapd
Operatinig System Status Version Notes
Ubuntu 14.04 LTS+ Supported 2.23
Debian (testing and unstable) Supported 2.23
Gentoo Supported 2.15 Not verified
Fedora 25+ No Classic Support 2.28.5 no-classic
CentOS 7 No Classic Support N/A no-classic
RHEL 7 No Classic Support N/A N/A
Arch Linux No Classic Support 2.30 no-classic
openSUSE Unsupported 2.23.5
#This is intended for Win7/Windows Server 2008 R2 sysprep issues with WMF 5.x
$Path ='HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Setup\Sysprep\Generalize'
$acl=Get-Acl -Path $Path
$rights = $acl.Access|?{$_.IdentityReference -eq 'BUILTIN\Administrators'} | Select-Object -ExpandProperty RegistryRights
if($rights -ne 'FullControl')
{
throw "Please give administrators full control to $Path"
}