Skip to content

Instantly share code, notes, and snippets.

View markekraus's full-sized avatar
😀

Mark Kraus markekraus

😀
View GitHub Profile
@markekraus
markekraus / Change prefix or suffix to Editor ID.pas
Created February 1, 2022 21:49
xEdit script that will change prefixes or suffixes on the EditorID field of every selected record.
{
This script will change prefixes or suffixes on the EditorID field
of every selected record.
Doesn't modify records that already have the correct prefix/suffix.
}
unit UserScript;
var
DoPrepend: boolean;
@markekraus
markekraus / HttpClient-Example.ps1
Created November 25, 2020 21:03
Example using HttpClient in PowerShell
# Create single HttpClient
$client = [System.Net.Http.HttpClient]::new()
# Perform multiple GETs
foreach ($url in $urls) {
$clientResult = $client.GetStringAsync($url).
GetAwaiter().
GetResult()
$clientResult | ConvertFrom-Json
}
@markekraus
markekraus / examples.ps1
Created July 15, 2020 15:11
PowerShell Core HTTP Redircet Capture
# PowerShell 7
$uri = 'https://microsoft.com'
$result = Invoke-WebRequest -SkipHttpErrorCheck -Uri $uri -MaximumRedirection 0 -ErrorAction SilentlyContinue -ErrorVariable $err
$location = $result.Headers.Location
# PowerShell 6
$uri = 'https://microsoft.com'
try {
Invoke-WebRequest -Uri $uri -MaximumRedirection 0 -ErrorAction Stop
} catch {
@markekraus
markekraus / README.md
Last active May 22, 2020 14:41
PSConfBook3 Author Expectations

PSConfBook3 Author Expectations

While we want this to be a fun, collaborative, and creative process, we still wish to produce a high-quality book we can all be proud of, and readers will be happy to purchase. Editing large numbers of chapters, each from different authors is a significant effort. We have the following expectations of our authors to ease the editing process and ensure a baseline of quality.

What does the project expect of the authors?

  • The authors must follow our style and writing guidelines we publish in the GitHub repository.
  • The authors must proofread their chapters at least three (3) times before submitting their final draft.
@markekraus
markekraus / README.md
Last active March 5, 2020 01:54
PSConfBook3 Copyright Information

Copyright Agreement

This document sets forth an understanding of copyright related issues between you, Contributor and the editors of the Book, tentatively titled The PowerShell Conference Book Volume 3. The Book is being developed and sold as a charitable, not-for-profit, venture. Your participation is considered entirely voluntary. Your contributions to the project, which includes your time, written material, and PowerShell code are to be considered charitable contributions. The only Contributor compensation will be one (1) free electronic copy of the Book from the original publisher.

All royalties and income generated from sales of the Book will be contributed to charitable cause. That cause is currently designated to support scholarships as part of the OnRamp program sponsored by The DevOps Collective.

@markekraus
markekraus / ExampleBracketFileUpload.ps1
Created March 6, 2019 02:45
Example of uploading a file with brackets in the name
New-Item -ItemType File -Path 'c:\temp\[a].txt' -value 'Test' -Force
Invoke-RestMethod -InFile 'c:\temp\`[a`].txt' -Method Post -Uri https://httpbin.org/post -ContentType 'text/plain'
<#
Result:
args :
data : Test
files :
@markekraus
markekraus / BustedEnumerator.ps1
Created January 16, 2019 02:12
Busted Enumerator
class MyEnumerator : System.Collections.IEnumerator {
hidden static [bool]$toggle = $true
hidden static [bool]$toggle2 = $true
MyEnumerator (){}
[bool] MoveNext()
{
if([MyEnumerator]::toggle) {
[MyEnumerator]::toggle = $false
@markekraus
markekraus / ARM-Logic.txt
Created January 8, 2019 15:21
Perform Conditional Operations on Parameters in Azure ARM templates
[
if(
equals(
parameters('settings')[copyIndex('settings')].type,
'static'
),
parameters('settings')[copyIndex('settings')].value,
if(
equals(
parameters('settings')[copyIndex('settings')].type,
@markekraus
markekraus / AzCmdletMapping.md
Last active February 18, 2024 17:34
Az to AzureRm Cmdlet Mappings

Az to AzureRM command Mappings

Source

Az.Aks

Az Command AzureRm Command
Get-AzAks Get-AzureRmAks
New-AzAks New-AzureRmAks
@markekraus
markekraus / Out-Default.ps1
Created June 15, 2018 19:05
Cheap Screen reader code for PowerShell
Function Out-Default {
[CmdletBinding()]
Param(
[Parameter(ValueFromPipeline)]
[PSObject]
$InputObject,
[switch]
$Transcript
)