<#PowerShell 2.0 을 기준으로 작성.#>
#디스크 체크
$DeviceID = Get-WmiObject win32_logicaldisk
$DRV = foreach ($Drive in $DeviceID) {$Drive.Name}
# 반복문을 이용하여 진행.
For($i=0; $i -lt 3; $i++){
#공백 없앰.
$DRV_So = $DRV[$i] -replace " ", ""
$drives = Get-WmiObject win32_logicaldisk -filter "DeviceID = \\\\\\\'$DRV_So\\\\\\\'"
#Gbyte 단위로 전환
$free = @{n="FreeSpace(GB)";e={"{0:N2}" -f ($_.FreeSpace/1GB)}}
# 파일로 저장.
$Source = $drives | select $free | FT -Auto | Out-File -FilePath H:\\\\\\\\Hanbiro_JOB\\\\\\\\Drive.txt
# 특정값만 불러오기
$InFile= Get-Content -Path H:\\\\\\\\Hanbiro_job\\\\\\\\Drive.txt | ForEach-Object{$_.Split("Freespace ---------")[0]}
#공백 없앰.
$File = $InFile -replace " ", ""
#브라우져로 확인
$ie=New-Object -ComObject internetexplorer.application
#공백 없앰.
$DRV_Name = $DRV_So -replace ":",""
#1G 이하면 발송으로
if($File -gt 1.00)
{
Write-host $DRV[$i] \\\\\\\'드라이브의 용량은\\\\\\\' $File \\\\\\\'입니다.\\\\\\\'
}
else
{
Write-host $DRV[$i] \\\\\\\'드라이브용량은\\\\\\\' $File \\\\\\\'1Gbyte\\\\\\\' \\\\\\\'이하입니다.\\\\\\\'
#페이지띄우기.
$ie.Visible=$true
#사용자 서버에서 사용되기 때문에 SMS 발송 페이지는 숨김.
#드라이브 명대로 띄우는 페이지 변경.
$ie.navigate("http://SMS_SERVER/sms/$DRV_Name.htm")
}
}
<#전체 과정 Start-Transcript 를 이용해서 파일 저장후 저장된 파일 메일로 발송할수도 있음#>
############################################################################################################################
* 보내는 서버 (ASP)
Dim Phone(1)
strConnect="Provider=SQLOLEDB.1;Password=;Persist Security Info=True;User ID=;Initial Catalog=;Data Source="
Set DbCon = Server.CreateObject("ADODB.Connection")
DbCon.Open strConnect
Phone(0) = "0123456789" Phone(1) = "0136654987"
Set Rs=Server.CreateObject("ADODB.RecordSet")
For each Item in Phone
Sql = "insert into SC_TRAN (TR_SENDDATE, TR_PHONE, TR_MSG) values (getdate(),\'"& Item &"\',\'현재 디스크 1G 미만입니다.\')"
Set RS = DbCon.Execute(Sql)
Next
DbCon.Close