Skip to content

Instantly share code, notes, and snippets.

View VMResumeReplication.ps1
$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
View AutoSlmgr.ps1
# 期限切れ状態を取得。
# 期限切れの場合は「通知」という文字列が現れるので、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
View GoogleChrome_Enable_Popup_AlwaysPermit.bat
reg add "HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Google\Chrome" /v "ExternalProtocolDialogShowAlwaysOpenCheckbox" /t "REG_DWORD" /d "1" /f
View ReplaceSSL.bat
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
View LineNotify.cs
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
View SendMail.vbs
Option Explicit
Dim mFrom
Dim mTo
Dim SmtpSvr
mFrom = "From@From.com"
mTo = "To@To.com"
SmtpSvr = "SmtpServer"
View GetDeadLock.bat
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
View WindowsUpdate.vbs
Option Explicit
Dim updateSession, updateSearcher, update, searchResult, downloader, updatesToDownload, updatesToInstall, installer, installationResult, InputKey, i
If Right((LCase(WScript.FullName)),11) <> "cscript.exe" then
WScript.Echo "このスクリプトはCSCRIPT.EXEを使用して実行して下さい。" & _
vbCRLF & "例: cscript WindowsUpdate.vbs"
WScript.Quit(0)
End if
WScript.Echo "------------------------------"
View SyncMyDNS.vbs
Option Explicit
On Error Resume Next
Const strURL = "http://www.mydns.jp/login.html"
Const strUser = "ユーザー名"
Const strPasswd = "パスワード"
Dim objXML
Dim strXMLDoc
Dim intRet