$PsHome\Profile.ps1でEncodedCommandをとめる
if (Test-Path $PROFILE) {
return
}
if ([System.Environment]::CommandLine -match '-EncodedCommand')
{
trap {
continue
}
$Source = 'SecureMyPowerShell'
if ([System.Diagnostics.EventLog]::SourceExists($SecureMyPowerShell)) {
# イベントソースがなかったら登録
New-EventLog -LogName Application -Source $Source
}
$Messge = @"
PowerShellがEncodedCommandで実行されています
$([System.Environment]::CommandLine)
PID: $($PID)
強制終了します
"@
# イベントログに出力
Write-EventLog -LogName Application -Source $Source -EntryType Warning -EventId 1 -Message $Messge
# 自身をころす
kill $PID
}