Skip to content

Instantly share code, notes, and snippets.

View yooakim's full-sized avatar
⌨️
Focusing

Joakim Westin yooakim

⌨️
Focusing
View GitHub Profile
@yooakim
yooakim / Extensions.cs
Created February 1, 2016 11:19
Add timestamp to filename
public static class Extensions
{
/// <summary>
/// Add a timestamp to the filename, before the extension.
/// </summary>
/// <param name="fileName">any filename for which you want to add a timestamp, including file extension.</param>
/// <returns>filename with added timestamp</returns>
/// <example>
/// <c>var file = "myfile.txt".AddTimeStamp();</c>
@yooakim
yooakim / template-step-2.json
Last active October 23, 2018 09:13
Template using hyperv-vmcx builder
{
"builders": [
{
"type": "hyperv-vmcx",
"clone_from_vmcx_path": "C:\\Users\\yooak\\source\\Basefarm\\packer-templates\\output-base\\Virtual Machines\\983A3EDE-0624-4A5C-A0BE-91FA050F68A5.vmcx",
"output_directory": "./output-updates/",
"communicator": "winrm",
"winrm_username": "vagrant",
"winrm_password": "vagrant",
"winrm_timeout": "12h",
{
"builders": [
{
"type": "hyperv-iso",
"output_directory": "./output-win2016-base/",
"vm_name": "win2016-base",
"iso_url": "{{ user `iso_url` }}",
"iso_checksum_type": "{{user `iso_checksum_type`}}",
"iso_checksum": "{{user `iso_checksum`}}",
"disk_size": "60000",
$Installer = "GoogleChromeStandaloneEnterprise64.msi"; Invoke-WebRequest "https://dl.google.com/edgedl/chrome/install/GoogleChromeStandaloneEnterprise64.msi" -OutFile $env:TEMP\$Installer; Start-Process -FilePath msiexec -ArgumentList "/quiet /package $env:TEMP\$Installer" -Verb RunAs -Wait; Remove-Item $env:TEMP\$Installer
@yooakim
yooakim / update-azcopy.sh
Last active February 4, 2020 12:19
Update AzCopy to latest version
#!/bin/bash
#
# Simple bash script for downloading and updating AzCopy to the latest available version.
#
# Go home
cd $HOME
# Download AzCopy
wget https://aka.ms/downloadazcopy-v10-linux --no-verbose
@yooakim
yooakim / Update-Sysinternals.ps1
Created March 13, 2021 09:54
Update SysinternalsSuite
Invoke-WebRequest -Uri https://download.sysinternals.com/files/SysinternalsSuite.zip -OutFile ~\Downloads\SysinternalsSuite.zip
Unblock-File ~\Downloads\SysinternalsSuite.zip
Expand-Archive ~\Downloads\SysinternalsSuite.zip -DestinationPath ~\OneDrive\Util -Force
Remove-Item ~\Downloads\SysinternalsSuite.zip
Invoke-WebRequest -Uri https://aka.ms/downloadazcopy-v10-windows -OutFile ~\Downloads\azcopy.zip
Unblock-File ~\Downloads\azcopy.zip
Expand-Archive ~\Downloads\azcopy.zip
Copy-Item ~\Downloads\azcopy\*\azcopy.exe C:\apps\tools -Force
Remove-Item ~\Downloads\azcopy -Recurse -Force
Set-MpPreference -ExclusionPath @('\\wsl$\Ubuntu',"$ENV:USERPROFILE\source") -ExclusionProcess @('devenv','Code','sqlservr','msbuild') -ExclusionExtension @('vhdx','vhd','bacpac','dacpac','wsl','wslhost')
@yooakim
yooakim / tenant-roles.bicep
Last active August 18, 2021 08:06
Assign roles Owner and Contributor to Azure AD groups at the tenant level
targetScope = 'tenant'
// Groups defined in Azure AD
var AzureAdmininstrators = '<ourprivateguidfortheADgroup>'
var AzureSubscriptionOwners = '<ourprivateguidfortheADgroup>'
// Azure built-in role IDs (see: https://docs.microsoft.com/en-us/azure/role-based-access-control/built-in-roles)
var OwnerRoleDefinitionId = '8e3af657-a8ff-443c-a75c-2fe8c4bcb635'
var ContributorRoleDefinitionId = 'b24988ac-6180-42a0-ab88-20f7382dd24c'
https://management.azure.com/subscriptions/{{subscriptionId}}/providers/Microsoft.Billing/billingPeriods/{{billingPeriod}}/providers/Microsoft.Consumption/usageDetails?$apply=filter(properties/usageEnd ge '{{startDate}}' AND properties/usageEnd le '{{endDate}}')/groupby((tags/Customer),aggregate(properties/cost with sum as TotalCost))&api-version=2021-10-01