Skip to content

Instantly share code, notes, and snippets.

@the-takeo
the-takeo / ConnectBastionForRDP.ps1
Created October 18, 2023 04:29
踏み台サーバー経由でRDPするPowershell
ssh -L 任意のポート番号:RDPするサーバーのIP:3389 踏み台サーバー
# Ex) ssh -L 33389:10.1.0.1:3389 user@10.1.0.2
# このコマンドを実行後、「localhost:33389」に対しRDP接続することで10.1.0.2経由で10.1.0.1にRDPすることができる。
@the-takeo
the-takeo / Config_Server.bat
Created September 17, 2022 16:30
リモートのWindows Serverに対し、コンピュータの管理で接続するbat
start compmgmt.msc /computer=サーバー名
@the-takeo
the-takeo / Monitoring.ps1
Last active August 23, 2021 06:40
WebMonitoring
#**********************************
# 監視URLを指定してください。
#**********************************
$Urls = New-Object System.Collections.Generic.List[string]
$Urls.Add("https://test1.co.jp")
$Urls.Add("https://test2.co.jp")
#**********************************
# メールの送信情報を設定してください。
#**********************************
@the-takeo
the-takeo / VMResumeReplication.ps1
Created November 11, 2020 02:44
VMResumeReplication
$HostServers=@("HostSvr1","HostSvr2","HostSvr3","HostSvr4","HostSvr5")
foreach($HostServer in $HostServers){
Get-vm -ComputerName $HostServer | Where-Object {$_.ReplicationHealth -ne "NotApplicable"} | Where-Object {$_.ReplicationHealth -ne "Normal"} | ForEach-Object{
$attempts=3
$sleepInSeconds=60
do
{
try
@the-takeo
the-takeo / AutoSlmgr.ps1
Created November 10, 2020 10:15
AutoSlmgr
# 期限切れ状態を取得。
# 期限切れの場合は「通知」という文字列が現れるので、resultが0以外になる。
$result = (cscript //Nologo C:\Windows\System32\slmgr.vbs /dli | Where-Object{$_ -Like "*通知*" }).length
if($result -ne 0)
{
slmgr -rearm
Restart-Computer -Force
}
else
reg add "HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Google\Chrome" /v "ExternalProtocolDialogShowAlwaysOpenCheckbox" /t "REG_DWORD" /d "1" /f
@the-takeo
the-takeo / ReplaceSSL.bat
Created September 9, 2019 01:45
ReplaceSSL
REM Powershellで「dir cert:\LocalMachine\My」を実行し、証明書の拇印を取得して下記に設定する。
REM 新しいもの(差し替えるもの)と古いもの(差し替えられるもの)の両方の捺印が必要。
set OldThumbprint="XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
set NewThumbprint="YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY"
set pfxFileName="ssl.pfx"
certutil -f -p パスワード -importpfx "WebHosting" "%~dp0%pfxFileName%"
cd %windir%\system32\inetsrv
@the-takeo
the-takeo / LineNotify.cs
Created June 29, 2019 11:50
LineNotify
using System;
using System.Collections.Generic;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Text;
using System.Threading.Tasks;
namespace LineNotifyForFamily
{
public static class LineNotify
Option Explicit
Dim mFrom
Dim mTo
Dim SmtpSvr
mFrom = "From@From.com"
mTo = "To@To.com"
SmtpSvr = "SmtpServer"
@the-takeo
the-takeo / GetDeadLock.bat
Last active May 7, 2018 09:01
CheckDeadLock
SET FLD=%~dp0
SET TXT_DEADLOCK=DeadLock.txt
If not Exist %FLD% mkdir %FLD%
del %FLD%\%TXT_DEADLOCK%
bcp "SELECT * FROM sys.fn_xe_file_target_read_file('C:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\Log\DeadLock*.xel', 'C:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\Log\DeadLock*.xem', null, null)" queryout "%FLD%\%TXT_DEADLOCK%" -T -c