@{
int x = 123;
string y = "because.";
}
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Edit-XmlNodes { | |
param ( | |
[xml] $doc = $(throw "doc is a required parameter"), | |
[string] $xpath = $(throw "xpath is a required parameter"), | |
[string] $value = $(throw "value is a required parameter"), | |
[bool] $condition = $true | |
) | |
if ($condition -eq $true) { | |
$nodes = $doc.SelectNodes($xpath) | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<# | |
.SYNOPSIS | |
Converts files to the given encoding. | |
Matches the include pattern recursively under the given path. | |
.EXAMPLE | |
Convert-FileEncoding -Include *.js -Path scripts -Encoding UTF8 | |
#> | |
function Convert-FileEncoding([string]$Include, [string]$Path, [string]$Encoding='UTF8') { | |
$count = 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.IO; | |
using System.Linq; | |
using System.Web; | |
/* | |
MIT License | |
Copyright (c) 2014 Christian Weyer |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Windows Subsystem for Linux | |
wsl --install -d Ubuntu | |
# winget | |
# work / tools | |
winget install -s winget --id Microsoft.Powershell | |
winget install -s winget --id Git.Git | |
winget install -s winget --id 7zip.7zip | |
winget install -s winget --id Foxit.FoxitReader | |
# winget install -s winget --id Microsoft.EdgeWebView2Runtime |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Add a domain user to a remote server local group, if your current user has admin over the remote machine | |
powershell -c ([ADSI]'WinNT://SERVER/Administrators,group').add('WinNT://DOMAIN/USER,user') | |
# Get all local groups on a remote server | |
powershell -c "([ADSI]'WinNT://SERVER,computer').psbase.children | where { $_.psbase.schemaClassName -eq 'group' } | foreach { ($_.name)[0]}" | |
# Find members of the local Administrators group on a remote server | |
powershell -c "$([ADSI]'WinNT://SERVER/Administrators,group').psbase.Invoke('Members') | foreach { $_.GetType().InvokeMember('ADspath', 'GetProperty', $null, $_, $null).Replace('WinNT://', '') }" | |
# Enable the local Administrator account on a remote server |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Microsoft.AspNetCore.Identity; | |
using Microsoft.AspNetCore.Identity.EntityFrameworkCore; | |
using System.Linq; | |
namespace My.App.Data | |
{ | |
public class DbInitializer : IDbInitializer | |
{ | |
private readonly ApplicationDbContext _context; | |
private readonly UserManager<ApplicationUser> _userManager; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$type = [System.Security.Cryptography.X509Certificates.X509ContentType]::Cert | |
get-childitem -path cert:\LocalMachine\AuthRoot | ForEach-Object { | |
$hash = $_.GetCertHashString() | |
[System.IO.File]::WriteAllBytes("$hash.der", $_.export($type) ) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
param($global:RestartRequired=0, | |
$global:MoreUpdates=0, | |
$global:MaxCycles=10) | |
function Check-ContinueRestartOrEnd() { | |
$RegistryKey = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Run" | |
$RegistryEntry = "InstallWindowsUpdates" | |
switch ($global:RestartRequired) { | |
0 { | |
$prop = (Get-ItemProperty $RegistryKey).$RegistryEntry |