Skip to content

Instantly share code, notes, and snippets.

View ebibibi's full-sized avatar

Masahiko Ebisuda ebibibi

View GitHub Profile
@ebibibi
ebibibi / PowerShell Samples.ps1
Created February 12, 2014 03:48
PowerShell Samples
#test
@ebibibi
ebibibi / Set-PowerPlanHigh.ps1
Created November 15, 2013 08:01
電源プランを「高パフォーマンス」に設定します。
$p = Get-CimInstance -Name root\cimv2\power -Class win32_PowerPlan -Filter "ElementName = '高パフォーマンス'"
Invoke-CimMethod -InputObject $p[0] -MethodName Activate
@ebibibi
ebibibi / Install-SCOMAgents.ps1
Created November 12, 2013 07:14
This script installs SCOM agents to several clients. ex) .\Install-SCOMAgent.ps1 -ServerName scomserver.domain.name -Targets @("client1.domain.name", "client2.domain.name")
#This script installs SCOM agents to several clients.
#
#ex)
#.\Install-SCOMAgent.ps1 -ServerName scomserver.domain.name -Targets @("client1.domain.name", "client2.domain.name")
Param(
[parameter(mandatory=$true)]$ServerName,
[parameter(mandatory=$true)]$Targets
)
@ebibibi
ebibibi / gist:5342892
Created April 9, 2013 04:12
Change image size and location fit to powerpoint slide macro.
Sub ImageSizeFit()
On Error Resume Next
w = 720
h = 768
shapeNo = 3
For i = 56 To ActivePresentation.Slides.Count
Set Slide = ActivePresentation.Slides(i)
Slide.Shapes(shapeNo).Width = w
@ebibibi
ebibibi / is_sccm_installed.bat
Created February 15, 2013 01:46
detect sccm client is installed or not.
sc query CcmExec |findstr /I "SERVICE_NAME: CcmExec"
if %errorlevel%==0 goto Installed
:Not_Installed
echo sccm client is not installed.
goto end
:Installed
echo sccm client is installed.
goto end
@ebibibi
ebibibi / kick_sccm_actions.vbs
Created February 13, 2013 07:26
Kick all sccm client actions by PowerShell.
Set cpApplet = CreateObject("CPAPPLET.CPAppletMgr")
Set actions = cpApplet.GetClientActions
For Each action In actions
action.PerformAction
'WScript.Echo "Performed '" & action.name & "'"
Next
@ebibibi
ebibibi / kick_sccm_actions.ps1
Created February 13, 2013 07:26
Kick all sccm client actions by PowerShell.
$a = New-Object -comobject cpapplet.cpappletmgr
$a.GetClientActions() |% {$_.PerformAction()}
$b = New-Object –COMObject CPApplet.cpappletmgr
$b.GetClientActions() |% {$_.PerformAction()}
@ebibibi
ebibibi / osdetect.bat
Created February 6, 2013 14:00
this is os detect batchfile. this file uses only ver command and this can't detect server or client. This is because of speed. systeminfo.exe can detect server or client but that is very slow. "ver" comannd returns result very fast.
@ECHO off
VER | find "95" > nul
IF not errorlevel 1 GOTO Win_95
VER | find "98" > nul
IF not errorlevel 1 GOTO Win_98
VER | find "NT" > nul
IF not errorlevel 1 GOTO Win_NT
@ebibibi
ebibibi / rename_pictures.ps1
Created November 30, 2012 14:01
デジカメ、スマートフォンなどで撮影した画像、動画ファイルをリネーム後月ごとのフォルダに移動するスクリプト
#--------------------------------------------------------------------------------------------------
# デジカメ、スマートフォンなどで撮影した画像、動画ファイルをリネーム後月ごとのフォルダに移動するスクリプトです。
# 以下のようにリネームします。exif情報があればそれを使って。無ければファイルの作成日時を使います。
# yyyy.mm.dd-hh.mm.ss + オリジナルの拡張子
# リネーム後、指定されたフォルダ内にyyyymmフォルダを作成し、その中に移動します。
# 移動先に同一名称のファイルがあり、同一内容(MD5ハッシュで判断)であれば移動元ファイルを削除します。
#
# -SourceDir 移動元ディレクトリを入力します。再帰的にサブディレクトリも対象になります。
# -DestinationDir 移動先ディレクトリを入力します。このディレクトリの下に月ごとのディレクトリが作成され、そこに移動されます。
# -$Filter 対象とするファイルをフィルタで指定します。Get-ChildItemのFilterパラメータにそのまま渡されます。
@ebibibi
ebibibi / Restart-And-RunOnce.ps1
Created October 31, 2012 14:12
Windowsを強制的に再起動した上で、次回ログオン時に指定したPowerShellスクリプトを1度だけ実行させます。
#第一引数にスクリプト名をフルパスで記述
#第二引数以降にスクリプトへの引数(複数指定可能)
$RegRunOnceKey = "HKLM:\Software\Microsoft\Windows\CurrentVersion\RunOnce"
$powershell = (Join-Path $env:windir "system32\WindowsPowerShell\v1.0\powershell.exe")
$restartKey = "Restart-And-RunOnce"
$script = $args[0]
$newArgs = ""
for($i = 1; $i -le $args.Length; $i++)