Skip to content

Instantly share code, notes, and snippets.

View stknohg's full-sized avatar

Takuya Shibata stknohg

View GitHub Profile
@stknohg
stknohg / Install-LatestWinGet.ps1
Last active October 23, 2023 13:24
Windows Server 2022にWindows Terminal, WinGetをインストールする関数
function Install-LatestWinGet ([switch]$SkipInstallVCLibs) {
# Install prerequisites
if (-not $SkipInstallVCLibs) {
$vcLibsUrl = 'https://aka.ms/Microsoft.VCLibs.x64.14.00.Desktop.appx'
Write-Host -ForegroundColor Green "Download $vcLibsUrl"
Add-AppxPackage -Path $vcLibsUrl
}
# Find the latest assets url
$latest = Invoke-RestMethod -Uri 'https://api.github.com/repos/microsoft/winget-cli/releases/latest'
@stknohg
stknohg / GitHub-GraphQLAPISample.ps1
Created April 26, 2018 06:37
GitHub GraphQL APIのサンプル
#
# PowerShell/PowerShellリポジトリのリリース情報を取得するクエリ
# 取得件数は適当
#
$header = @{
'content-type' = 'application/json';
Authorization = 'bearer YOUR_GITHUB_API_TOKEN'
}
$query = @'
{
@stknohg
stknohg / Update-EC2Launch.ps1
Last active June 1, 2023 04:53
最新バージョンのEC2Launchをインストールするスクリプト
#
# 最新バージョンの EC2Launch をインストールするスクリプト
# Ref : https://docs.aws.amazon.com/AWSEC2/latest/WindowsGuide/ec2launch-download.html
#
# ※ EC2Launch 設定ファイルのバックアップには対応していません。
#
<#
.SYNOPSIS
EC2Launchの最新バージョンを取得します
@stknohg
stknohg / windows-server-setup-japanese-ui.yaml
Last active April 9, 2023 00:29
EC2 Image BuilderでWindows Serverを日本語化するコンポーネント
name: windows-server-setup-japanese-ui
description: Install Japanese Language pack and Update UI configurations.
schemaVersion: 1.0
parameters:
- S3BucketName:
type: string
default: 'your-bucket-name'
description: Set your S3 bucket name.
- S3BucketPath:
@stknohg
stknohg / Install-PgCommandLineTools.ps1
Created March 14, 2023 05:14
Windows環境にPostgreSQLのコマンドラインツールをインストールするスクリプト
# Download Installer
$ProgressPreference = 'SilentlyContinue'
$installerUrl = 'https://get.enterprisedb.com/postgresql/postgresql-15.2-1-windows-x64.exe'
$installerLocalPath = Join-Path $env:TEMP 'postgresql-windows-x64.exe'
Invoke-WebRequest -Uri $installerUrl -OutFile $installerLocalPath
# Invoke Installer
$params = @{
FilePath = $installerLocalPath # InstallBuilder
ArgumentList = @('--mode unattended', '--unattendedmodeui none', '--disable-components server,pgAdmin,stackbuilder')
@stknohg
stknohg / Write-BOMlessUTF8Sample.ps1
Last active February 3, 2023 02:05
PowerShellでBOM無しUTF8を書くサンプル
# 例1
"書き込み内容" `
| % { [Text.Encoding]::UTF8.GetBytes($_) } `
| Set-Content -Path ".\BOMlessUTF8.txt" -Encoding Byte
# 例2
Get-Content -Path ".\Source.txt" -Raw -Encoding Default `
| % { [Text.Encoding]::UTF8.GetBytes($_) } `
| Set-Content -Path ".\BOMlessUTF8.txt" -Encoding Byte
@stknohg
stknohg / Start-FileWatch.ps1
Last active November 29, 2022 07:01
FileSystemWatcherを使ってファイルの変更監視する簡単なファンクション。
<#
.Synopsis
指定したパスにあるファイルの変更を監視します。
.DESCRIPTION
指定したパスにあるファイルの変更を監視します。
監視を止める場合はCtrl+Cを押してください。
.PARAMETER Path
監視するディレクトリを指定します。
.PARAMETER Filter
監視するファイル名(に対するフィルタ)を指定します。
@stknohg
stknohg / install_powershell_on_arm_linux.sh
Created November 1, 2022 07:44
Arm版LinuxにPowerShell 7をインストールするスクリプト
#!/usr/bin/env bash
# Download Arm PowerShell tar.gz
ver_name=$(curl -s https://api.github.com/repos/PowerShell/PowerShell/releases/latest | grep tag_name | sed -e 's/^\s*"tag_name".*"v\(.*\)".*$/\1/')
curl -L -o /tmp/powershell.tar.gz "https://github.com/PowerShell/PowerShell/releases/download/v${ver_name}/powershell-${ver_name}-linux-arm64.tar.gz"
# Create the target folder and expand PowerShell
sudo mkdir -p /opt/microsoft/powershell/7
sudo tar zxf /tmp/powershell.tar.gz -C /opt/microsoft/powershell/7
# Set pwsh binary executable
@stknohg
stknohg / AzureVM_Nested_Virtualization.md
Created June 26, 2022 03:06
Azure VMで入れ子の仮想化をサポートしているシリーズ

Azure VMで入れ子の仮想化をサポートしているシリーズ

元ネタは以下のDocs。

流石に全部を動作検証するのは無理。

一覧表

@stknohg
stknohg / 00-provider.tf
Last active May 21, 2022 04:08
S3サーバーアクセスログを試すTerraformサンプル
terraform {
required_version = "~> 1.2.0"
required_providers {
aws = {
source = "hashicorp/aws"
version = "~> 4.15.1"
}
}
}