Skip to content

Instantly share code, notes, and snippets.

View mwallner's full-sized avatar
🧙

Manfred Wallner mwallner

🧙
View GitHub Profile
@mwallner
mwallner / Chocolatey.ps1.md
Created October 19, 2019 09:12
Boxstarter-Chocolatey-Param-Troubleshooting

I modified function 'choco' in Chocolatey.ps1 to include some additional logging:

function choco {
<#
.SYNOPSIS
Intercepts Chocolatey call to check for reboots
@mwallner
mwallner / fzf-posh.md
Created September 27, 2019 09:15
using fzf to nagive directories in PowerShell

using fzf to nagive directories in PowerShell

simplest way: 1-liner

Set-Location (Get-Item $(fzf)).Directory.FullName

creating a function

$script:_https_certs = @{}
function Add-HTTPSCertificateCheck {
param(
[string]$Url,
[TimeSpan]$ValidityTime
)
@mwallner
mwallner / ps-jenkins-incosistency.md
Created July 23, 2019 13:01
PowerShell RemoteException incosistency when run via Jenkins

NOTE: This seems to only affect Win10 1809 LTSC and/or PowerShell 5.1.17763.1

I've got this demo-script, which I put into a Jenkins job:

Write-Host "##############################################"
$ErrorActionPreference = "Stop"

Write-Host "ErrorActionPreference: $ErrorActionPreference"
Write-Host "whoami: $(whoami)"
$PSVersionTable | Format-Table
@mwallner
mwallner / Invoke-WithMockedEnv-Demo.ps1
Created July 4, 2019 19:20
"mocking" environment variables in a ScriptBlock
function Invoke-WithMockedEnv {
param(
[Parameter(ValueFromPipeline)]
[scriptblock]$ScriptBlock,
[Hashtable]$mockValues
)
@mwallner
mwallner / Install-SCCMUpdates.ps1
Last active November 21, 2023 02:42
install all available updates via SCCM
<#
.SYNOPSIS
Install all updates available via SCCM and WAIT for the installation to finish.
.PARAMETER Computer
the computer to install updates on
.OUTPUTS
a object containing information about the installed updates and the reboot state (if a reboot is required or not)
# IMPORTANT: Before releasing this package, copy/paste the next 2 lines into PowerShell to remove all comments from this file:
#   $f='c:\path\to\thisFile.ps1'
#   gc $f | ? {$_ -notmatch "^\s*#"} | % {$_ -replace '(^.*?)\s*?[^``]#.*','$1'} | Out-File $f+".~" -en utf8; mv -fo $f+".~" $f
 
# 1. See the _TODO.md that is generated top level and read through that
# 2. Follow the documentation below to learn how to create a package for the package type you are creating.
# 3. In Chocolatey scripts, ALWAYS use absolute paths - $toolsDir gets you to the package's tools directory.
$ErrorActionPreference = 'Stop'; # stop on all errors
$toolsDir   = "$(Split-Path -parent $MyInvocation.MyCommand.Definition)"
# Internal packages (organizations) or software that has redistribution rights (community repo)
@mwallner
mwallner / Get-LatestProcesses.ps1
Created March 20, 2019 10:47
get 'youngest' process with some filter possibilites
param(
[Parameter(Mandatory = $False)]
[int]$NumberOfProcesses = 1,
[Parameter(Mandatory = $False)]
[switch]$IncludeMicrosoftProcesses,
[Parameter(Mandatory = $False)]
[switch]$RequirePath,

Keybase proof

I hereby claim:

  • I am mwallner on github.
  • I am schusterfredl (https://keybase.io/schusterfredl) on keybase.
  • I have a public key ASBnJ0YHSv0R8lqvTRYiaaBiN2dvIJb2Xb1Odf6RUMVufwo

To claim this, I am signing this object:

@mwallner
mwallner / Get-CurrentlyPrereleasedPackages.ps1
Last active January 15, 2019 08:43
get list of all currently prereleased chocolatey packages for given feeds
$feeds = @(
"https://myorg.feeds/nuget/choco-dev",
"https://myorg.feeds/nuget/choco-prA",
"https://myorg.feeds/nuget/choco-prB"
)
$pkgs = @()
$prereleaseVersionRegex = [regex]"(?'ver'\d+\.\d+(\.\d+(\.\d+)?)?)\-"
$feeds | ForEach-Object {