$ip=get-serverip
$loginedUser=get_login_user
$operateUser=cut-string $message '????:' '??????:'
$operateUser=cut-string $operateUser '?????:' '?????:'
$operateUser=$operateUser -replace('?????:'??'')
$delUser=$message.substring($message.indexof('??????:'))
$delUser=cut-string $delUser '?????:' '?????:'
$delUser=$delUser -replace('?????:'??'')
$Body="<table width='700' border='1' cellpadding='0' cellspacing='0' style='font-size:13px;'>
<tr  style='background:#39F'>
<td>??????</td>
<td>???????</td>
<td>????????</td>
<td>???????</td>
<td>???????</td>
</tr>
<tr>
<td>$ip</td>
<td>$operateUser</td>
<td>$delUser</td>
<td>$time</td>
<td>$loginedUser</td>
</tr>
</table>"
try
{
Send-Mail "Delete on $ip" $Body
}
catch
{
ac -Path c:UserNotice.log -Value "[ $time Delete] $error[0]"
}
}
#endregion
#region Software-Setup-Notice ?????????
function Software-Setup-Notice
{
$softinfo=Get-WinEvent -logname setup -maxevents 10 | ? {$_.id -eq 1610} | select timecreated??message
if($softinfo -eq $null)
{
break
}
if(($softinfo.gettype()).isarray)
{
$time=$softinfo[0].timecreated
$time=$softinfo[0].tostring()
$message=$softinfo[0].message
}
else
{
$time=$softinfo.timecreated
$time=$time.tostring()
$message=$softinfo.message
}
$ip=get-serverip
$loginedUser=get_login_user
$Body="<table width='700' border='1' cellpadding='0' cellspacing='0' style='font-size:13px;'>
<tr  style='background:#39F'>
<td>??????</td>
<td>???????</td>
<td>??????</td>
<td>??????</td>
</tr>
<tr>
<td>$ip</td>
<td>$loginedUser</td>
<td>$time</td>
<td>$message</td>
</tr>
</table>"
try
{
Send-Mail 'Setup on $ip' $Body
}
catch
{
ac -Path c:UserNotice.log -Value "[ $time Setup] $error[0]"
}
}
#endregion
#region Main ??????
function Main{
param(
$str??
$script:code
)
if($str -eq $null)
{
Write-Warning ???????!
sleep 2
break
}
if($str -eq 'login')
{
Login-Succ-Notice
}
if($str -eq 'cancel')
{
Cancel-Succ-Notice
}
if($str -eq 'add')
{
Create-User-Notice
}
if($str -eq 'delete')
{
Delete-User-Notice
}
if($str -eq 'setup')
{
Software-Setup-Notice
}
}
#endregion
main $args[0] $args[1]