Skip to content

Instantly share code, notes, and snippets.

View alexandair's full-sized avatar

Aleksandar Nikolić alexandair

  • Novi Sad, Serbia
View GitHub Profile
@JustinGrote
JustinGrote / StartVSCodeServer.ps1
Last active February 29, 2024 02:37
Powershell Bootstrap script for VSCode Server
#require -version 5.1
#Usage: iwr https://tinyurl.com/VSCodeServer | iex
#Parameterized usage: & ([ScriptBlock]::Create((iwr https://tinyurl.com/VSCodeServer))) -Your -Options
param(
#Path to install the vscode binary to. This defaults to a folder in your Local AppData path. Must be writable by your current user without sudo
[ValidateNotNullOrEmpty()]
[string]$InstallPath = $(Join-Path -Path ([System.Environment]::GetFolderPath('LocalApplicationData')) -ChildPath 'vscode-cli'),
#Installation architecture. This is normally autodetected.
$Arch,
$OS,
Event
| where EventID == "4104"
| extend ParsedEvent = parse_xml(strcat("<root>", ParameterXml, "</root>"))
| extend MessageNumber = tolong(ParsedEvent.root.Param[0])
| extend MessageTotal = tolong(ParsedEvent.root.Param[1])
| extend ScriptBlockElement = iff(
strlen(tostring(ParsedEvent.root.Param[2]["#text"])) > 0,
ParsedEvent.root.Param[2]["#text"],
ParsedEvent.root.Param[2])
| extend ScriptBlockId = tostring(ParsedEvent.root.Param[3])
@mattifestation
mattifestation / profile.ps1
Created March 28, 2020 22:16
PowerShell profile to add some functionality for Windows Terminal
# 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)) `""
}
@markjbrown
markjbrown / free-tier-arm-template-example
Last active January 30, 2024 20:11
Create a Cosmos DB free-tier account and database with 400 RU
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"databaseAccount_free_tier_name": {
"defaultValue": "my-cosmos-account-name",
"type": "String"
}
},
"variables": {},
$currentContext = Get-AzContext
$azureRmProfile = [Microsoft.Azure.Commands.Common.Authentication.Abstractions.AzureRmProfileProvider]::Instance.Profile
$azureRmProfileClient = [Microsoft.Azure.Commands.ResourceManager.Common.RMProfileClient]::new($azureRmProfile)
$azureRmProfileClient.AcquireAccessToken($currentContext.Subscription.TenantId)
@Francisco-Gamino
Francisco-Gamino / Az.Functions.md
Last active July 8, 2020 15:21
Az.Functions - Managing Azure Functions via PowerShell.
# Managing Azure Functions via PowerShell Cmdlets
# Prerequisites:
# - PowerShell Core 6 or greater --> https://github.com/PowerShell/PowerShell/releases
# - Core Tools --> https://github.com/Azure/azure-functions-core-tools#installing
# - Az.Functions preview module --> https://www.powershellgallery.com/packages/Az.Functions/0.0.2-preview

# Install Azure Functions PowerShell core module
Install-Module -Name Az.Functions -AllowPrerelease
@mattifestation
mattifestation / EnableAMSILogging.ps1
Last active October 29, 2022 14:28
Enables AMSI logging to the AMSI/Operational event log
$AutoLoggerName = 'MyAMSILogger'
$AutoLoggerGuid = "{$((New-Guid).Guid)}"
New-AutologgerConfig -Name $AutoLoggerName -Guid $AutoLoggerGuid -Start Enabled
Add-EtwTraceProvider -AutologgerName $AutoLoggerName -Guid '{2A576B87-09A7-520E-C21A-4942F0271D67}' -Level 0xff -MatchAnyKeyword ([UInt64] (0x8000000000000001 -band ([UInt64]::MaxValue))) -Property 0x41