Skip to content

Instantly share code, notes, and snippets.

@MasayukiOzawa
MasayukiOzawa / Convert-PfxToPem.ps1
Created December 3, 2024 10:48 — forked from rmbolger/Convert-PfxToPem.ps1
Convert-PfxToPem.ps1
# Adapted from Vadims Podāns' amazing work here.
# https://www.sysadmins.lv/blog-en/how-to-convert-pkcs12pfx-to-pem-format.aspx
#
# Also, if you need a more complete PKI PowerShell module, he has authored one here:
# https://github.com/Crypt32/PSPKI
#
# This version of the function includes a few fixes from the module's version of the
# function and changes up the output options so you get separate .crt/.key files by
# default named the same as the pfx file (or thumbprint if directly referencing a cert).
# -IncludeChain adds an additional -chain.pem. Relative paths are now
@MasayukiOzawa
MasayukiOzawa / UUID v7 の TimeStamp を 5 グループに移動するための関数.sql
Last active December 8, 2024 02:14
SQL Server の UUID v7 のデータ格納について
CREATE OR ALTER FUNCTION dbo.convertuuid(@v uniqueidentifier)
RETURNS uniqueidentifier
AS
BEGIN
DECLARE @r uniqueidentifier
SELECT
@r =
SUBSTRING(CAST(@v AS varbinary(16)),14,1) +
SUBSTRING(CAST(@v AS varbinary(16)),13,1) +
SUBSTRING(CAST(@v AS varbinary(16)),12,1) +
@MasayukiOzawa
MasayukiOzawa / Check for any problems in the database.
Last active August 19, 2024 00:31
Microsoft Copilot skills in Azure SQL Database (SQLExternalMonitoring_Copilot)
SELECT
@@SERVERNAME AS Server,
@@VERSION AS SQLServerVersion,
d.name AS DBName,
d.recovery_model_Desc AS RecoveryModel,
d.Compatibility_level AS CompatiblityLevel,
d.create_date,
d.state_desc,
slo.*
FROM sys.databases AS d
@MasayukiOzawa
MasayukiOzawa / 01.sys.sp_MSactivate_auto_sub.sql
Last active August 15, 2024 22:39
Replication にアーティクルを追加した際に実行されるストアド
create procedure sys.sp_MSactivate_auto_sub
(
@publication sysname,
@article sysname,
@status sysname = 'active',
@skipobjectactivation int = 0,
@publisher sysname = null
)
AS
BEGIN
USE master
GO
ALTER DATABASE gocowboys SET ACCELERATED_DATABASE_RECOVERY = ON
BACKUP DATABASE gocowboys TO DISK=N'NUL'
BACKUP LOG gocowboys TO DISK=N'NUL'
GO
USE gocowboys
GO
package main
import (
"context"
"database/sql"
"encoding/json"
"fmt"
"log"
"os"
"time"
# https://support.microsoft.com/ja-jp/help/4466511/cannot-configure-language-pack-for-windows-server-2019
$lp_uri = "https://software-download.microsoft.com/download/pr/17763.1.180914-1434.rs5_release_SERVERLANGPACKDVD_OEM_MULTI.iso"
Invoke-WebRequest -Uri $lp_uri -OutFile (Join-Path $ENV:temp ($lp_uri -split "/")[-1])
Mount-DiskImage (Join-Path $ENV:temp ($lp_uri -split "/")[-1])
$drive = Get-PSDrive | ? Description -like "*SL1_X64FRE*"
Set-Location ($drive.Name + ":\")
lpksetup.exe /i ja-jp /r /f /s /p ".\x64\langpacks"
-- バックアップによるスループットの発生の確認
SELECT GETDATE(), instance_name, cntr_value
FROM sys.dm_os_performance_counters
WHERE counter_name LIKE '%Backup%' AND instance_name = '_Total'
-- 完全バックアップの発生タイミングの確認 (完全バックアップが発生すると 値が減る)
SELECT modified_extent_page_count
FROM sys.dm_db_file_space_usage
@MasayukiOzawa
MasayukiOzawa / 00-query.conf
Last active August 1, 2018 14:04
Elastick Stack + SQL Server
input {
jdbc {
jdbc_driver_library => "/usr/lib/jvm/java-8-openjdk-amd64/jre/bin/mssql-jdbc-6.4.0.jre8.jar"
jdbc_driver_class => "com.microsoft.sqlserver.jdbc.SQLServerDriver"
jdbc_connection_string => "jdbc:sqlserver://192.168.0.7;databaseName=master"
jdbc_user => "<User Id>"
jdbc_password => "<Password>"
schedule => "15 00 * * *"
statement => "exec usp_Get_Cache"
# columns_charset => {"query_hash" => "UTF-8"}
contents Azure services and related products
App modernization - Xamarin
- Web APIs
- PowerApps
- Flow
- Azure Storage
- Azure Search
- Azure Redis
- Azure SQL Database
- Azure Active Directory
- API Management
Azure Blockchain - Blockchain Workbench
- IoT Hub
- Service Bus
- SQL Database
- Key Vault
- Event Grid
- Application Insights
Azure security and management - Azure Automation
- Azure Monitor
- Azure Log Analytics
- Change Tracking
- Update Management
- Security Center
- Service Map
- Application Insights
- Virtual machines
Azure security, privacy, and compliance - Azure Virtual Machines and Networks with Network Security Groups- Virtual Private Networks (Point to