{"id":269430,"date":"2015-12-02T01:09:02","date_gmt":"2015-12-01T22:09:02","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=269430"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=269430","title":{"rendered":"\u0421\u0435\u0440\u0432\u0435\u0440\u043d\u043e\u0435 \u0430\u0434\u043c\u0438\u043d\u0438\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435. \u0423\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0440\u0435\u0441\u0443\u0440\u0441\u0430\u043c\u0438 \u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0430\u043c\u0438 PowerShell"},"content":{"rendered":"<p>       \u0414\u043e\u0431\u0440\u043e\u0433\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0441\u0443\u0442\u043e\u043a.<\/p>\n<p>  \u0421\u0435\u0433\u043e\u0434\u043d\u044f \u043d\u0430\u0448\u0435\u043c\u0443 \u0430\u0434\u043c\u0438\u043d\u0438\u0441\u0442\u0440\u0430\u0442\u043e\u0440\u0443 \u043f\u043e\u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043b\u043e\u0441\u044c \u043e\u0442\u0441\u043b\u0435\u0436\u0438\u0432\u0430\u0442\u044c \u043d\u0430 \u0441\u0435\u0442\u0435\u0432\u044b\u0445 \u0440\u0435\u0441\u0443\u0440\u0441\u0430\u0445, \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0413\u0431 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0438 \u0441\u043e\u0442\u0440\u0443\u0434\u043d\u0438\u043a\u0438 \u0432 \u0441\u0432\u043e\u0438\u0445 \u043b\u0438\u0447\u043d\u044b\u0445 \u043a\u0430\u0442\u0430\u043b\u043e\u0433\u0430\u0445 (\u0434\u0438\u0441\u043a\u043e\u0432\u043e\u0435 \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u043e \u0432\u044b\u0434\u0435\u043b\u0435\u043d\u043e \u043f\u0443\u0442\u0435\u043c \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u0441\u0435\u0442\u0435\u0432\u043e\u0433\u043e \u0434\u0438\u0441\u043a\u0430). \u041f\u0440\u0435\u0434\u043f\u043e\u043b\u0430\u0433\u0430\u0435\u043c, \u0447\u0442\u043e \u043f\u0440\u0435\u0434\u0435\u043b\u044c\u043d\u043e \u0434\u043e\u043f\u0443\u0441\u0442\u0438\u043c\u044b\u0439 \u0440\u0430\u0437\u043c\u0435\u0440 \u043b\u0438\u0447\u043d\u043e\u0433\u043e \u0440\u0435\u0441\u0443\u0440\u0441\u0430 \u0440\u0430\u0432\u0435\u043d 1 \u0413\u0431. \u0412 \u0441\u043b\u0443\u0447\u0430\u0435 \u0435\u0441\u043b\u0438 \u044d\u0442\u043e\u0442 \u0440\u0430\u0437\u043c\u0435\u0440 \u043f\u0440\u0435\u0432\u044b\u0448\u0430\u0435\u0442 \u043f\u0440\u0435\u0434\u0435\u043b, \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0441\u043e\u043e\u0431\u0449\u0438\u0442\u044c \u0430\u0434\u043c\u0438\u043d\u0438\u0441\u0442\u0440\u0430\u0442\u043e\u0440\u0443. \u0422\u0430\u043a\u0436\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0440\u0435\u0437\u043a\u043e\u0435 \u0443\u0432\u0435\u043b\u0438\u0447\u0435\u043d\u0438\u0435 \u0440\u0430\u0437\u043c\u0435\u0440\u043e\u0432 \u043b\u0438\u0447\u043d\u044b\u0445 \u0440\u0435\u0441\u0443\u0440\u0441\u043e\u0432. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0435\u0441\u043b\u0438 \u043b\u0438\u0447\u043d\u044b\u0439 \u043a\u0430\u0442\u0430\u043b\u043e\u0433 \u0441\u043e\u0442\u0440\u0443\u0434\u043d\u0438\u043a\u0430 \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u0432 \u0440\u0430\u0437\u043c\u0435\u0440\u0435 \u043d\u0430 200 \u041c\u0431 \u0437\u0430 \u043d\u0435\u0434\u0435\u043b\u044e, \u0442\u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043e\u043f\u043e\u0432\u0435\u0441\u0442\u0438\u0442\u044c \u0430\u0434\u043c\u0438\u043d\u0438\u0441\u0442\u0440\u0430\u0442\u043e\u0440\u0430. <\/p>\n<p>  \u0418\u0442\u0430\u043a, \u043a\u043e\u0434 Powershell\u2019a, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043b \u0432\u0441\u0435 \u0432\u044b\u0448\u0435\u0443\u043a\u0430\u0437\u0430\u043d\u043d\u044b\u0435 \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043d\u0438\u044f:<\/p>\n<p>  \u0424\u0443\u043d\u043a\u0446\u0438\u044f \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0438 \u043f\u043e\u0447\u0442\u044b. \u0424\u0443\u043d\u043a\u0446\u0438\u044f \u043d\u0435 \u0443\u043d\u0438\u0432\u0438\u0440\u0441\u0430\u043b\u044c\u043d\u0430\u044f, \u043f\u043e\u0434\u0441\u0442\u0440\u043e\u0435\u043d\u0430 \u043f\u043e\u0434 \u0437\u0430\u0434\u0430\u0447\u0443. \u0422.\u0435. \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u043c \u0437\u0430 \u0444\u0430\u043a\u0442, \u0447\u0442\u043e \u0442\u0435\u043c\u0430 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f, \u043f\u043e\u043b\u0443\u0447\u0430\u0442\u0435\u043b\u044c \u043d\u0435 \u043c\u0435\u043d\u044f\u044e\u0442\u0441\u044f. \u041c\u0435\u043d\u044f\u0435\u0442\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u0442\u0435\u043b\u043e, \u0435\u0433\u043e \u0442\u043e \u043c\u044b \u0438 \u0437\u0430\u0434\u0430\u0435\u043c \u043a\u0430\u043a \u0432\u0445\u043e\u0434\u044f\u0449\u0438\u0439 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 \u0434\u043b\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u0438:<\/p>\n<pre><code class=\"bash\">function EmailNotification($Mail_body) {   $Sender = &quot;audit@...&quot;   $Receipt = &quot;levitskaks@gmail.com&quot;   $Server = &quot;gmail.com.ua&quot;   $Object = &quot;DirSize: &quot; + (Get-Date)   $SMTPclient = new-object System.Net.Mail.SmtpClient $Server   #Specify SMTP port if needed   $SMTPClient.port = 25   #Activate SSL if needed   #$SMTPclient.EnableSsl = $true   #Specify email account credentials if needed   $SMTPAuthUsername = &quot;levitskaks@gmail.com&quot;   $SMTPAuthPassword = &quot;pass&quot;   $SMTPClient.Credentials = New-Object System.Net.NetworkCredential($SMTPAuthUsername, $SMTPAuthPassword)   $Message = new-object System.Net.Mail.MailMessage $Sender, $Receipt, $Object, $Mail_body   #-$Message.IsBodyHtml = $true;   $SMTPclient.Send($Message) } <\/code><\/pre>\n<p>  \u041f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u043c \u043a \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438. \u0412\u0445\u043e\u0434\u044f\u0449\u0438\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b:<br \/>   \u2014 \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0439 \u043a\u0430\u0442\u0430\u043b\u043e\u0433. \u041a\u0430\u0442\u0430\u043b\u043e\u0433 \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u043f\u0435\u0440\u0435\u0447\u0435\u043d\u044c \u043a\u0430\u0442\u0430\u043b\u043e\u0433\u043e\u0432 \u043f\u043e\u0434 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0441\u043e\u0442\u0440\u0443\u0434\u043d\u0438\u043a\u0430;<br \/>   \u2014 \u043f\u0440\u0435\u0434\u0435\u043b\u044c\u043d\u043e-\u0434\u043e\u043f\u0443\u0441\u0442\u0438\u043c\u044b\u0439 \u0440\u0430\u0437\u043c\u0435\u0440 \u0432 \u0431\u0430\u0439\u0442\u0430\u0445;<br \/>   \u2014 \u043f\u0443\u0442\u044c \u0434\u043b\u044f \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u043b\u043e\u0433\u0430 \u0440\u0430\u0431\u043e\u0442\u044b;<\/p>\n<pre><code class=\"bash\">function Check-Size-Directory ($dir, $GB, $Logpath) { <\/code><\/pre>\n<p>  \u041e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u043c \u0434\u0435\u043d\u044c \u043d\u0435\u0434\u0435\u043b\u0438 \u0432 \u0433\u043e\u0434\u0443. \u041d\u0430 \u043c\u043e\u043c\u0435\u043d\u0442 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u0441\u043a\u0440\u0438\u043f\u0442\u0430 \u0431\u044b\u043b\u0430 47 \u043d\u0435\u0434\u0435\u043b\u044f. <br \/>  \u0422\u0430\u043a\u0436\u0435 \u043d\u0430\u0441 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u0443\u0435\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u2014 \u0440\u0430\u0437 \u0432 \u043d\u0435\u0434\u0435\u043b\u044e \u0432 \u043f\u043e\u043d\u0435\u0434\u0435\u043b\u044c\u043d\u0438\u043a. \u041b\u043e\u0433\u0438\u043a\u0430 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0430\u044f: \u0432 \u0447\u0435\u0442\u043d\u0443\u044e \u043d\u0435\u0434\u0435\u043b\u044e \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u0442\u0441\u044f \u043b\u043e\u0433 \u0440\u0430\u0431\u043e\u0442\u044b \u00ab0.log\u00bb. \u0412 \u043d\u0435\u0447\u0435\u0442\u043d\u0443\u044e \u043d\u0435\u0434\u0435\u043b\u044e \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u043c \u0444\u0430\u0439\u043b \u00ab1.log\u00bb. \u0415\u0441\u043b\u0438 \u0434\u0430\u0442\u0430 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u00ab0.log\u00bb \u0431\u043e\u043b\u044c\u0448\u0435 \u0434\u0430\u0442\u044b \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u00ab1.log\u00bb, \u0442\u043e \u043f\u043e \u043b\u043e\u0433\u0438\u0447\u0435\u0441\u043a\u0438 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u043c, \u0447\u0442\u043e \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u044f\u044f \u043d\u0435\u0434\u0435\u043b\u044f \u0431\u044b\u043b\u0430 \u0447\u0435\u0442\u043d\u0430\u044f. \u0438 \u0441\u0432\u0435\u0440\u044f\u0435\u043c \u0432 \u043a\u0430\u043a\u043e\u043c \u043a\u0430\u0442\u0430\u043b\u043e\u0433\u0435 \u0440\u0430\u0437\u043c\u0435\u0440 \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u043b\u0441\u044f \u0431\u043e\u043b\u0435\u0435 \u0447\u0435\u043c \u043d\u0430 200 \u041c\u0431.<\/p>\n<pre><code class=\"bash\">[Int32]$Monday = (Get-Date -UFormat &quot;%w&quot;)     $Monday     [Int32]$Week = (Get-Date -UFormat &quot;%W&quot;)     $Week     if ($week%2 -eq 0 -and $Monday -eq 1){                  $LogPathFile = $LogPath + &quot;\\&quot; + ($week%2).ToString() + &quot;.log&quot;             If (!(Test-Path -path $LogPathFile)){             Write-Host &quot;\u0421\u043e\u0437\u0434\u0430\u043b\u0438 \u044d\u043b\u0435\u043c\u0435\u043d\u0442&quot;             New-Item -Path $LogPathFile  -ItemType File         }         $ToFile = &quot;&quot; | Out-File $LogPathFile         Write-Host &quot;\u0427\u0435\u0442\u043d\u0430\u044f \u043d\u0435\u0434\u0435\u043b\u044f&quot;         Get-ChildItem -path $dir | %{             $dir_property = dir $_.FullName -recurse | where {-Not $_.PSIsContainer}| Measure-Object -Property length -Sum  <\/code><\/pre>\n<p>  \u041f\u0435\u0440\u0432\u0430\u044f \u0442\u0440\u0435\u0431\u0443\u0435\u043c\u0430\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430: \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c \u043a\u0430\u0442\u0430\u043b\u043e\u0433 \u043d\u0430 \u0440\u0430\u0437\u043c\u0435\u0440 \u0431\u043e\u043b\u044c\u0448\u0435, \u0447\u0435\u043c 1 \u0413\u0431.<\/p>\n<pre><code class=\"bash\"> if ($dir_property.Sum -gt $GB){                 $Mail_body+= &quot;\u0420\u0430\u0437\u043c\u0435\u0440 \u043a\u0430\u0442\u0430\u043b\u043e\u0433\u0430 &quot; + $_.FullName + &quot; \u043f\u0440\u0435\u0432\u044b\u0448\u0430\u0435\u0442 \u0440\u0430\u0437\u043c\u0435\u0440 \u0432 1 \u0413\u0431.`n&quot;                 $Mail_body+= &quot;\u0420\u0430\u0437\u043c\u0435\u0440 \u043a\u0430\u0442\u0430\u043b\u043e\u0433\u0430 &quot; + $_.FullName + &quot; \u0441\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 &quot; + (($dir_property.Sum)\/1024\/1024) + &quot; \u041c\u0431.`n&quot;                 $Mail_body+= &quot;------------------------------------------------------------------------------------------`n&quot;                 &lt;b&gt;$ToFile = $_.DirectoryName + &quot; &quot; + (($dir_property.Sum)\/1024\/1024) | Out-File $LogPathFile  -Append&lt;\/b&gt;             }             else {                 Write-Host &quot;\u0412\u0441\u0435 \u0445\u043e\u0440\u043e\u0448\u043e \u0441 \u043a\u0430\u0442\u0430\u043b\u043e\u0433\u043e\u043c: &quot; $_.FullName             }         }         EmailNotification -Mail_body $Mail_body <\/code><\/pre>\n<p>  \u0421\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u043c \u0438\u043c\u044f \u043a\u0430\u0442\u0430\u043b\u043e\u0433\u0430 \u0438 \u0435\u0433\u043e \u0440\u0430\u0437\u043c\u0435\u0440 \u0447\u0435\u0440\u0435\u0437 \u0440\u0430\u0437\u0434\u0435\u043b\u0438\u0442\u0435\u043b\u044c &quot;|&quot;, \u0432 \u043f\u043e\u0441\u043b\u0435\u0434\u0441\u0442\u0432\u0438\u0438 \u0447\u0435\u0440\u0435\u0437 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u043c \u043f\u0430\u0440\u0441\u0438\u0442\u044c \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0435 \u0444\u0430\u0439\u043b\u0430.<\/p>\n<pre><code class=\"bash\">&lt;b&gt;$ToFile = $_.DirectoryName + &quot; &quot; + (($dir_property.Sum)\/1024\/1024) | Out-File $LogPathFile  -Append&lt;\/b&gt; <\/code><\/pre>\n<p>  \u041e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u043c \u043a\u0430\u043a\u043e\u0439 \u0444\u0430\u0439\u043b \u0441\u0447\u0438\u0442\u0430\u0435\u043c \u043d\u043e\u0432\u044b\u043c, \u0447\u0442\u043e\u0431\u044b \u043f\u0440\u043e\u0432\u043e\u0434\u0438\u0442\u044c \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435 \u0441 \u0444\u0430\u0439\u043b\u043e\u043c \u043d\u0435\u0434\u0435\u043b\u044c\u043d\u043e\u0439 \u0434\u0430\u0432\u043d\u043e\u0441\u0442\u0438. <\/p>\n<pre><code class=\"bash\">$Mail_body = &quot;&quot;         If ((Get-Item -Path $LogPath\\0.log).LastWriteTime -gt (Get-Item -Path $LogPath\\1.log).LastWriteTime){                 $log_content = Get-Content (Get-ChildItem -Path $LogPath\\0.log)                 foreach ($data in $log_content)                  {                     $x = $data.split(&quot;|&quot;)                     $xc1 = $x[0]                     $xc2 = $x[1]                     $log_content = Get-Content (Get-ChildItem -Path $LogPath\\1.log)                     foreach ($data in $log_content)                      {                         $y = $data.split(&quot;|&quot;)                         if ($xc1 -eq $y[0]){                             if(([Int32]$xc2 - [Int32]$y[1]) -gt 200){                                 $Mail_body += &quot;\u0420\u0435\u0437\u043a\u043e\u0435 \u0443\u0432\u0435\u043b\u0438\u0447\u0435\u043d\u0438\u0435 \u0440\u0430\u0437\u043c\u0435\u0440\u0430 \u043a\u0430\u0442\u0430\u043b\u043e\u0433\u0430: &quot; + $xc1 + &quot;`n \u0420\u0430\u0437\u043c\u0435\u0440 \u043d\u0430 \u043f\u0440\u043e\u0448\u043b\u043e\u0439 \u043d\u0435\u0434\u0435\u043b\u0435 \u0441\u043e\u0441\u0442\u0430\u0432\u0438\u043b: &quot; + $y[1] + &quot; \u041c\u0431.&quot; + &quot;`n \u0420\u0430\u0437\u043c\u0435\u0440 \u043d\u0430 \u0442\u0435\u043a\u0443\u0449\u0435\u0439 \u043d\u0435\u0434\u0435\u043b\u0435 \u0441\u043e\u0441\u0442\u0430\u0432\u0438\u043b: &quot; + $xc2 + &quot; \u041c\u0431.`n&quot;                             }                          }                     }                  }             EmailNotification -Mail_body $Mail_body            }      } <\/code><\/pre>\n<p>  \u041f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u0447\u0435\u0442\u043d\u043e\u0441\u0442\u0438\\\u043d\u0435\u0447\u0435\u0442\u043d\u043e\u0441\u0442\u0438 \u043d\u0435\u0434\u0435\u043b\u044c \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442\u0441\u044f \u0434\u0435\u043b\u0435\u043d\u0438\u0435\u043c \u043f\u043e \u043c\u043e\u0434\u0443\u043b\u044e \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u043e\u0439 \u043d\u0435\u0434\u0435\u043b\u0438 \u0432 \u0433\u043e\u0434\u0443:<\/p>\n<pre><code class=\"bash\">&lt;b&gt;$week%2&lt;\/b&gt; <\/code><\/pre>\n<p>  \u0410\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u044b\u0435 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u0434\u043b\u044f \u043d\u0435\u0447\u0435\u0442\u043d\u043e\u0439 \u043d\u0435\u0434\u0435\u043b\u0438:<\/p>\n<pre><code class=\"bash\">    if ($week%2 -eq 1 -and $Monday -eq 1){         Write-Host &quot;\u041d\u0435\u0447\u0435\u0442\u043d\u0430\u044f \u043d\u0435\u0434\u0435\u043b\u044f&quot;         $LogPathFile = $LogPath + &quot;\\&quot; + ($week%2).ToString() + &quot;.log&quot;         If (!(Test-Path -path $LogPathFile)){             Write-Host &quot;\u0421\u043e\u0437\u0434\u0430\u043b\u0438 \u044d\u043b\u0435\u043c\u0435\u043d\u0442&quot;             New-Item -Path $LogPathFile  -ItemType File         }         $ToFile = &quot;&quot; | Out-File $LogPathFile                  Get-ChildItem -path $dir | %{             $dir_property = dir $_.FullName -recurse | where {-Not $_.PSIsContainer}| Measure-Object -Property length -Sum                   if ($dir_property.Sum -gt $GB){                 $Mail_body+= &quot;\u0420\u0430\u0437\u043c\u0435\u0440 \u043a\u0430\u0442\u0430\u043b\u043e\u0433\u0430 &quot; + $_.FullName + &quot; \u043f\u0440\u0435\u0432\u044b\u0448\u0430\u0435\u0442 \u0440\u0430\u0437\u043c\u0435\u0440 \u0432 1 \u0413\u0431.`n&quot;                 $Mail_body+= &quot;\u0420\u0430\u0437\u043c\u0435\u0440 \u043a\u0430\u0442\u0430\u043b\u043e\u0433\u0430 &quot; + $_.FullName + &quot; \u0441\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 &quot; + (($dir_property.Sum)\/1024\/1024) + &quot; \u041c\u0431.`n&quot;                 $Mail_body+= &quot;------------------------------------------------------------------------------------------`n&quot;                 $ToFile = $_.Name + &quot;|&quot; + (($dir_property.Sum)\/1024\/1024) | Out-File $LogPathFile  -Append             }             else {                 Write-Host &quot;\u0412\u0441\u0435 \u0445\u043e\u0440\u043e\u0448\u043e \u0441 \u043a\u0430\u0442\u0430\u043b\u043e\u0433\u043e\u043c: &quot; $_.FullName             }         }         EmailNotification -Mail_body $Mail_body         $Mail_body = &quot;&quot;         If ((Get-Item -Path $LogPath\\1.log).LastWriteTime -gt (Get-Item -Path $LogPath\\0.log).LastWriteTime){                 $log_content = Get-Content (Get-ChildItem -Path $LogPath\\1.log)                 foreach ($data in $log_content)                  {                     $x = $data.split(&quot;|&quot;)                     $xc1 = $x[0]                     $xc2 = $x[1]                     $log_content = Get-Content (Get-ChildItem -Path $LogPath\\0.log)                     foreach ($data in $log_content)                      {                         $y = $data.split(&quot;|&quot;)                         if ($xc1 -eq $y[0]){                             if(([Int32]$xc2 - [Int32]$y[1]) -gt 200){                                 $Mail_body += &quot;\u0420\u0435\u0437\u043a\u043e\u0435 \u0443\u0432\u0435\u043b\u0438\u0447\u0435\u043d\u0438\u0435 \u0440\u0430\u0437\u043c\u0435\u0440\u0430 \u043a\u0430\u0442\u0430\u043b\u043e\u0433\u0430: &quot; + $xc1 + &quot;`n \u0420\u0430\u0437\u043c\u0435\u0440 \u043d\u0430 \u043f\u0440\u043e\u0448\u043b\u043e\u0439 \u043d\u0435\u0434\u0435\u043b\u0435 \u0441\u043e\u0441\u0442\u0430\u0432\u0438\u043b: &quot; + $y[1] + &quot; \u041c\u0431.&quot; + &quot;`n \u0420\u0430\u0437\u043c\u0435\u0440 \u043d\u0430 \u0442\u0435\u043a\u0443\u0449\u0435\u0439 \u043d\u0435\u0434\u0435\u043b\u0435 \u0441\u043e\u0441\u0442\u0430\u0432\u0438\u043b: &quot; + $xc2 + &quot; \u041c\u0431.`n&quot;                                 $Mail_body                             }                          }                     }                  }             EmailNotification -Mail_body $Mail_body            }                       }          } <\/code><\/pre>\n<p>  \u0414\u043b\u044f \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u043c \u0432\u0445\u043e\u0434\u044f\u0449\u0438\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u0438 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0443. <\/p>\n<pre><code class=\"bash\">#\u041f\u0440\u043e\u0432\u0435\u0440\u0438\u044c \u043a\u0430\u0442\u0430\u043b\u043e\u0433: \u043d\u0435 \u043f\u0440\u0438\u0432\u044b\u0448\u0430\u0435\u0442 \u043b\u0438 \u043e\u043d \u0440\u0430\u0437\u043c\u0435\u0440 \u0432 1 \u0413\u0431 $GB = 1073741824 $dir = &quot;D:\\Program Files&quot; Check-Size-Directory -dir $dir -GB 107374 -Logpath &quot;D:&quot; <\/code><\/pre>\n<p>  \u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u043d\u0430 \u043f\u043e\u0447\u0442\u0443:<\/p>\n<p>  \u0422\u0435\u043c\u0430: DirSize: 11\/27\/2015 11:32:05<br \/>  \u0414\u0430\u0442\u0430: 27 Nov 2015 11:32:05 +0200<br \/>  \u041e\u0442: sizefoldres@gmail.com<br \/>  \u041a\u043e\u043c\u0443: levitskaks@gmail.com<\/p>\n<p>  \u0420\u0430\u0437\u043c\u0435\u0440 \u043a\u0430\u0442\u0430\u043b\u043e\u0433\u0430 F:\\Shared\\PrivateData\\BRU \u043f\u0440\u0435\u0432\u044b\u0448\u0430\u0435\u0442 \u0440\u0430\u0437\u043c\u0435\u0440 \u0432 1 \u0413\u0431.<br \/>  \u0420\u0430\u0437\u043c\u0435\u0440 \u043a\u0430\u0442\u0430\u043b\u043e\u0433\u0430 F:\\Shared\\PrivateData\\BRU \u0441\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 1239.06250095367 \u041c\u0431.<br \/>   \u2014 <\/p>\n<p>  \u0420\u0430\u0437\u043c\u0435\u0440 \u043a\u0430\u0442\u0430\u043b\u043e\u0433\u0430 F:\\Shared\\PrivateData\\Dan\u043f\u0440\u0435\u0432\u044b\u0448\u0430\u0435\u0442 \u0440\u0430\u0437\u043c\u0435\u0440 \u0432 1 \u0413\u0431.<br \/>  \u0420\u0430\u0437\u043c\u0435\u0440 \u043a\u0430\u0442\u0430\u043b\u043e\u0433\u0430 F:\\Shared\\PrivateData\\Dan \u0441\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 1670.62088680267 \u041c\u0431.<br \/>   \u2014 <\/p>\n<p>  \u0420\u0430\u0437\u043c\u0435\u0440 \u043a\u0430\u0442\u0430\u043b\u043e\u0433\u0430 F:\\Shared\\PrivateData\\DYA \u043f\u0440\u0435\u0432\u044b\u0448\u0430\u0435\u0442 \u0440\u0430\u0437\u043c\u0435\u0440 \u0432 1 \u0413\u0431.<br \/>  \u0420\u0430\u0437\u043c\u0435\u0440 \u043a\u0430\u0442\u0430\u043b\u043e\u0433\u0430 F:\\Shared\\PrivateData\\DYA \u0441\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 7456.12028884888 \u041c\u0431.<br \/>   \u2014 <\/p>\n<p>  \u0420\u0430\u0437\u043c\u0435\u0440 \u043a\u0430\u0442\u0430\u043b\u043e\u0433\u0430 F:\\Shared\\PrivateData\\GLU \u043f\u0440\u0435\u0432\u044b\u0448\u0430\u0435\u0442 \u0440\u0430\u0437\u043c\u0435\u0440 \u0432 1 \u0413\u0431.<br \/>  \u0420\u0430\u0437\u043c\u0435\u0440 \u043a\u0430\u0442\u0430\u043b\u043e\u0433\u0430 F:\\Shared\\PrivateData\\GLU \u0441\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 2198.93785953522 \u041c\u0431.<br \/>   \u2014 <br \/>  \u2026<\/p>\n<p>  \u0421\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0435 \u0444\u0430\u0439\u043b\u0430 0.log:<\/p>\n<pre><code class=\"bash\">ActiveX|2.8662109375 AvPinTool|0.5712890625 BDE|10.4070873260498 &lt;b&gt;drivers|6.512216567993&lt;\/b&gt; Drv for Secure\u0422oken 337|0.129350662231445 eclipse-standard-kepler-SR2-win32|545.861120223999 flash|122.166826248169 FTP_Drive|0.252327919006348 Install|431.435597419739 Jabber|55.9909982681274 LibreOffice_4_3_4|215.234375 Liga9|336.688585281372 Mail (address_book)|0.141551971435547 nkicntInit|0.166786193847656 powershell_3.0|14.0534420013428 PowerShell_4_0|46.8222227096558 single|630.298968315125 Total Commander|6.67717361450195 WinImage|1.12846660614014 zabbix|1.37527465820313 \u0414\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044f|0.584843635559 CSPKeyUtil.exe|0.89208984375 jdk-8u65-windows-i586.exe|181.22908782959 jre-8u65-windows-i586.exe|47.8077087402344 LimeActiveXCrypt.cab|5.14455604553223 npp.6.7.4.Installer.exe|7.59689044952393 SkypeSetupFull_6.21.exe|34.3624038696289 winapcupsd-3.14.12.exe|5.84123229980469 <\/code><\/pre>\n<p>  \u0421\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0435 \u0444\u0430\u0439\u043b\u0430 1.log:<\/p>\n<pre><code class=\"bash\">ActiveX|2.8662109375 AvPinTool|0.5712890625 BDE|10.4070873260498 &lt;b&gt;drivers|276.512216567993&lt;\/b&gt; Drv for Secure\u0422oken 337|0.129350662231445 eclipse-standard-kepler-SR2-win32|545.861120223999 flash|122.166826248169 FTP_Drive|0.252327919006348 Install|431.435597419739 Jabber|55.9909982681274 LibreOffice_4_3_4|215.234375 Liga9|336.688585281372 Mail (address_book)|0.141551971435547 nkicntInit|0.166786193847656 powershell_3.0|14.0534420013428 PowerShell_4_0|46.8222227096558 single|630.298968315125 Total Commander|6.67717361450195 WinImage|1.12846660614014 zabbix|1.37527465820313 \u0414\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044f|205.584843635559 CSPKeyUtil.exe|0.89208984375 jdk-8u65-windows-i586.exe|181.22908782959 jre-8u65-windows-i586.exe|47.8077087402344 LimeActiveXCrypt.cab|5.14455604553223 npp.6.7.4.Installer.exe|7.59689044952393 SkypeSetupFull_6.21.exe|34.3624038696289 winapcupsd-3.14.12.exe|5.84123229980469 <\/code><\/pre>\n<p>  \u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044f \u0434\u0432\u0443\u0445 \u0444\u0430\u0439\u043b\u043e\u0432:<\/p>\n<p>  \u0420\u0435\u0437\u043a\u043e\u0435 \u0443\u0432\u0435\u043b\u0438\u0447\u0435\u043d\u0438\u0435 \u0440\u0430\u0437\u043c\u0435\u0440\u0430 \u043a\u0430\u0442\u0430\u043b\u043e\u0433\u0430: D:\\Program Files\\drivers<br \/>  \u0420\u0430\u0437\u043c\u0435\u0440 \u043d\u0430 \u043f\u0440\u043e\u0448\u043b\u043e\u0439 \u043d\u0435\u0434\u0435\u043b\u0435 \u0441\u043e\u0441\u0442\u0430\u0432\u0438\u043b: 6.512216567993\u041c\u0431.<br \/>  \u0420\u0430\u0437\u043c\u0435\u0440 \u043d\u0430 \u0442\u0435\u043a\u0443\u0449\u0435\u0439 \u043d\u0435\u0434\u0435\u043b\u0435 \u0441\u043e\u0441\u0442\u0430\u0432\u0438\u043b: 276.512216567993 \u041c\u0431.<\/p>\n<p>  \u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u0435\u0442\u0441\u044f \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u0439, \u043f\u043e \u0436\u0435\u043b\u0430\u043d\u0438\u044e \u0430\u0434\u043c\u0438\u043d\u0438\u0441\u0442\u0440\u0430\u0442\u043e\u0440\u0430 \u0441 \u0440\u0435\u0441\u0443\u0440\u0441\u043e\u043c \u043c\u043e\u0436\u043d\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u043b\u044e\u0431\u044b\u0435 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0430\u0440\u0445\u0438\u0432\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0438 \u043f\u0435\u0440\u0435\u043d\u043e\u0441, \u0438\u043b\u0438 \u043e\u0442\u0431\u043e\u0440 \u0444\u0430\u0439\u043b\u043e\u0432 \u043f\u043e \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430\u043c \u0438 \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0443 \u0438\u0445 \u0432 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435.<\/p>\n<p>  \u0421\u043f\u0430\u0441\u0438\u0431\u043e \u0437\u0430 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435.<br \/>  <a name=\"habracut\"><\/a>               <\/p>\n<div class=\"clear\"><\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"http:\/\/habrahabr.ru\/post\/272107\/\"> http:\/\/habrahabr.ru\/post\/272107\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>       \u0414\u043e\u0431\u0440\u043e\u0433\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0441\u0443\u0442\u043e\u043a.<\/p>\n<p>  \u0421\u0435\u0433\u043e\u0434\u043d\u044f \u043d\u0430\u0448\u0435\u043c\u0443 \u0430\u0434\u043c\u0438\u043d\u0438\u0441\u0442\u0440\u0430\u0442\u043e\u0440\u0443 \u043f\u043e\u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043b\u043e\u0441\u044c \u043e\u0442\u0441\u043b\u0435\u0436\u0438\u0432\u0430\u0442\u044c \u043d\u0430 \u0441\u0435\u0442\u0435\u0432\u044b\u0445 \u0440\u0435\u0441\u0443\u0440\u0441\u0430\u0445, \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0413\u0431 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0438 \u0441\u043e\u0442\u0440\u0443\u0434\u043d\u0438\u043a\u0438 \u0432 \u0441\u0432\u043e\u0438\u0445 \u043b\u0438\u0447\u043d\u044b\u0445 \u043a\u0430\u0442\u0430\u043b\u043e\u0433\u0430\u0445 (\u0434\u0438\u0441\u043a\u043e\u0432\u043e\u0435 \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u043e \u0432\u044b\u0434\u0435\u043b\u0435\u043d\u043e \u043f\u0443\u0442\u0435\u043c \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u0441\u0435\u0442\u0435\u0432\u043e\u0433\u043e \u0434\u0438\u0441\u043a\u0430). \u041f\u0440\u0435\u0434\u043f\u043e\u043b\u0430\u0433\u0430\u0435\u043c, \u0447\u0442\u043e \u043f\u0440\u0435\u0434\u0435\u043b\u044c\u043d\u043e \u0434\u043e\u043f\u0443\u0441\u0442\u0438\u043c\u044b\u0439 \u0440\u0430\u0437\u043c\u0435\u0440 \u043b\u0438\u0447\u043d\u043e\u0433\u043e \u0440\u0435\u0441\u0443\u0440\u0441\u0430 \u0440\u0430\u0432\u0435\u043d 1 \u0413\u0431. \u0412 \u0441\u043b\u0443\u0447\u0430\u0435 \u0435\u0441\u043b\u0438 \u044d\u0442\u043e\u0442 \u0440\u0430\u0437\u043c\u0435\u0440 \u043f\u0440\u0435\u0432\u044b\u0448\u0430\u0435\u0442 \u043f\u0440\u0435\u0434\u0435\u043b, \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0441\u043e\u043e\u0431\u0449\u0438\u0442\u044c \u0430\u0434\u043c\u0438\u043d\u0438\u0441\u0442\u0440\u0430\u0442\u043e\u0440\u0443. \u0422\u0430\u043a\u0436\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0440\u0435\u0437\u043a\u043e\u0435 \u0443\u0432\u0435\u043b\u0438\u0447\u0435\u043d\u0438\u0435 \u0440\u0430\u0437\u043c\u0435\u0440\u043e\u0432 \u043b\u0438\u0447\u043d\u044b\u0445 \u0440\u0435\u0441\u0443\u0440\u0441\u043e\u0432. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0435\u0441\u043b\u0438 \u043b\u0438\u0447\u043d\u044b\u0439 \u043a\u0430\u0442\u0430\u043b\u043e\u0433 \u0441\u043e\u0442\u0440\u0443\u0434\u043d\u0438\u043a\u0430 \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u0432 \u0440\u0430\u0437\u043c\u0435\u0440\u0435 \u043d\u0430 200 \u041c\u0431 \u0437\u0430 \u043d\u0435\u0434\u0435\u043b\u044e, \u0442\u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043e\u043f\u043e\u0432\u0435\u0441\u0442\u0438\u0442\u044c \u0430\u0434\u043c\u0438\u043d\u0438\u0441\u0442\u0440\u0430\u0442\u043e\u0440\u0430. <\/p>\n<p>  \u0418\u0442\u0430\u043a, \u043a\u043e\u0434 Powershell\u2019a, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043b \u0432\u0441\u0435 \u0432\u044b\u0448\u0435\u0443\u043a\u0430\u0437\u0430\u043d\u043d\u044b\u0435 \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043d\u0438\u044f:<\/p>\n<p>  \u0424\u0443\u043d\u043a\u0446\u0438\u044f \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0438 \u043f\u043e\u0447\u0442\u044b. \u0424\u0443\u043d\u043a\u0446\u0438\u044f \u043d\u0435 \u0443\u043d\u0438\u0432\u0438\u0440\u0441\u0430\u043b\u044c\u043d\u0430\u044f, \u043f\u043e\u0434\u0441\u0442\u0440\u043e\u0435\u043d\u0430 \u043f\u043e\u0434 \u0437\u0430\u0434\u0430\u0447\u0443. \u0422.\u0435. \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u043c \u0437\u0430 \u0444\u0430\u043a\u0442, \u0447\u0442\u043e \u0442\u0435\u043c\u0430 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f, \u043f\u043e\u043b\u0443\u0447\u0430\u0442\u0435\u043b\u044c \u043d\u0435 \u043c\u0435\u043d\u044f\u044e\u0442\u0441\u044f. \u041c\u0435\u043d\u044f\u0435\u0442\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u0442\u0435\u043b\u043e, \u0435\u0433\u043e \u0442\u043e \u043c\u044b \u0438 \u0437\u0430\u0434\u0430\u0435\u043c \u043a\u0430\u043a \u0432\u0445\u043e\u0434\u044f\u0449\u0438\u0439 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 \u0434\u043b\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u0438:<\/p>\n<pre><code class=\"bash\">function EmailNotification($Mail_body) {   $Sender = &quot;audit@...&quot;   $Receipt = &quot;levitskaks@gmail.com&quot;   $Server = &quot;gmail.com.ua&quot;   $Object = &quot;DirSize: &quot; + (Get-Date)   $SMTPclient = new-object System.Net.Mail.SmtpClient $Server   #Specify SMTP port if needed   $SMTPClient.port = 25   #Activate SSL if needed   #$SMTPclient.EnableSsl = $true   #Specify email account credentials if needed   $SMTPAuthUsername = &quot;levitskaks@gmail.com&quot;   $SMTPAuthPassword = &quot;pass&quot;   $SMTPClient.Credentials = New-Object System.Net.NetworkCredential($SMTPAuthUsername, $SMTPAuthPassword)   $Message = new-object System.Net.Mail.MailMessage $Sender, $Receipt, $Object, $Mail_body   #-$Message.IsBodyHtml = $true;   $SMTPclient.Send($Message) } <\/code><\/pre>\n<p>  \u041f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u043c \u043a \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438. \u0412\u0445\u043e\u0434\u044f\u0449\u0438\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b:<br \/>   \u2014 \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0439 \u043a\u0430\u0442\u0430\u043b\u043e\u0433. \u041a\u0430\u0442\u0430\u043b\u043e\u0433 \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u043f\u0435\u0440\u0435\u0447\u0435\u043d\u044c \u043a\u0430\u0442\u0430\u043b\u043e\u0433\u043e\u0432 \u043f\u043e\u0434 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0441\u043e\u0442\u0440\u0443\u0434\u043d\u0438\u043a\u0430;<br \/>   \u2014 \u043f\u0440\u0435\u0434\u0435\u043b\u044c\u043d\u043e-\u0434\u043e\u043f\u0443\u0441\u0442\u0438\u043c\u044b\u0439 \u0440\u0430\u0437\u043c\u0435\u0440 \u0432 \u0431\u0430\u0439\u0442\u0430\u0445;<br \/>   \u2014 \u043f\u0443\u0442\u044c \u0434\u043b\u044f \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u043b\u043e\u0433\u0430 \u0440\u0430\u0431\u043e\u0442\u044b;<\/p>\n<pre><code class=\"bash\">function Check-Size-Directory ($dir, $GB, $Logpath) { <\/code><\/pre>\n<p>  \u041e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u043c \u0434\u0435\u043d\u044c \u043d\u0435\u0434\u0435\u043b\u0438 \u0432 \u0433\u043e\u0434\u0443. \u041d\u0430 \u043c\u043e\u043c\u0435\u043d\u0442 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u0441\u043a\u0440\u0438\u043f\u0442\u0430 \u0431\u044b\u043b\u0430 47 \u043d\u0435\u0434\u0435\u043b\u044f. <br \/>  \u0422\u0430\u043a\u0436\u0435 \u043d\u0430\u0441 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u0443\u0435\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u2014 \u0440\u0430\u0437 \u0432 \u043d\u0435\u0434\u0435\u043b\u044e \u0432 \u043f\u043e\u043d\u0435\u0434\u0435\u043b\u044c\u043d\u0438\u043a. \u041b\u043e\u0433\u0438\u043a\u0430 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0430\u044f: \u0432 \u0447\u0435\u0442\u043d\u0443\u044e \u043d\u0435\u0434\u0435\u043b\u044e \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u0442\u0441\u044f \u043b\u043e\u0433 \u0440\u0430\u0431\u043e\u0442\u044b \u00ab0.log\u00bb. \u0412 \u043d\u0435\u0447\u0435\u0442\u043d\u0443\u044e \u043d\u0435\u0434\u0435\u043b\u044e \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u043c \u0444\u0430\u0439\u043b \u00ab1.log\u00bb. \u0415\u0441\u043b\u0438 \u0434\u0430\u0442\u0430 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u00ab0.log\u00bb \u0431\u043e\u043b\u044c\u0448\u0435 \u0434\u0430\u0442\u044b \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u00ab1.log\u00bb, \u0442\u043e \u043f\u043e \u043b\u043e\u0433\u0438\u0447\u0435\u0441\u043a\u0438 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u043c, \u0447\u0442\u043e \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u044f\u044f \u043d\u0435\u0434\u0435\u043b\u044f \u0431\u044b\u043b\u0430 \u0447\u0435\u0442\u043d\u0430\u044f. \u0438 \u0441\u0432\u0435\u0440\u044f\u0435\u043c \u0432 \u043a\u0430\u043a\u043e\u043c \u043a\u0430\u0442\u0430\u043b\u043e\u0433\u0435 \u0440\u0430\u0437\u043c\u0435\u0440 \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u043b\u0441\u044f \u0431\u043e\u043b\u0435\u0435 \u0447\u0435\u043c \u043d\u0430 200 \u041c\u0431.<\/p>\n<pre><code class=\"bash\">[Int32]$Monday = (Get-Date -UFormat &quot;%w&quot;)     $Monday     [Int32]$Week = (Get-Date -UFormat &quot;%W&quot;)     $Week     if ($week%2 -eq 0 -and $Monday -eq 1){                  $LogPathFile = $LogPath + &quot;\\&quot; + ($week%2).ToString() + &quot;.log&quot;             If (!(Test-Path -path $LogPathFile)){             Write-Host &quot;\u0421\u043e\u0437\u0434\u0430\u043b\u0438 \u044d\u043b\u0435\u043c\u0435\u043d\u0442&quot;             New-Item -Path $LogPathFile  -ItemType File         }         $ToFile = &quot;&quot; | Out-File $LogPathFile         Write-Host &quot;\u0427\u0435\u0442\u043d\u0430\u044f \u043d\u0435\u0434\u0435\u043b\u044f&quot;         Get-ChildItem -path $dir | %{             $dir_property = dir $_.FullName -recurse | where {-Not $_.PSIsContainer}| Measure-Object -Property length -Sum  <\/code><\/pre>\n<p>  \u041f\u0435\u0440\u0432\u0430\u044f \u0442\u0440\u0435\u0431\u0443\u0435\u043c\u0430\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430: \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c \u043a\u0430\u0442\u0430\u043b\u043e\u0433 \u043d\u0430 \u0440\u0430\u0437\u043c\u0435\u0440 \u0431\u043e\u043b\u044c\u0448\u0435, \u0447\u0435\u043c 1 \u0413\u0431.<\/p>\n<pre><code class=\"bash\"> if ($dir_property.Sum -gt $GB){                 $Mail_body+= &quot;\u0420\u0430\u0437\u043c\u0435\u0440 \u043a\u0430\u0442\u0430\u043b\u043e\u0433\u0430 &quot; + $_.FullName + &quot; \u043f\u0440\u0435\u0432\u044b\u0448\u0430\u0435\u0442 \u0440\u0430\u0437\u043c\u0435\u0440 \u0432 1 \u0413\u0431.`n&quot;                 $Mail_body+= &quot;\u0420\u0430\u0437\u043c\u0435\u0440 \u043a\u0430\u0442\u0430\u043b\u043e\u0433\u0430 &quot; + $_.FullName + &quot; \u0441\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 &quot; + (($dir_property.Sum)\/1024\/1024) + &quot; \u041c\u0431.`n&quot;                 $Mail_body+= &quot;------------------------------------------------------------------------------------------`n&quot;                 &lt;b&gt;$ToFile = $_.DirectoryName + &quot; &quot; + (($dir_property.Sum)\/1024\/1024) | Out-File $LogPathFile  -Append&lt;\/b&gt;             }             else {                 Write-Host &quot;\u0412\u0441\u0435 \u0445\u043e\u0440\u043e\u0448\u043e \u0441 \u043a\u0430\u0442\u0430\u043b\u043e\u0433\u043e\u043c: &quot; $_.FullName             }         }         EmailNotification -Mail_body $Mail_body <\/code><\/pre>\n<p>  \u0421\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u043c \u0438\u043c\u044f \u043a\u0430\u0442\u0430\u043b\u043e\u0433\u0430 \u0438 \u0435\u0433\u043e \u0440\u0430\u0437\u043c\u0435\u0440 \u0447\u0435\u0440\u0435\u0437 \u0440\u0430\u0437\u0434\u0435\u043b\u0438\u0442\u0435\u043b\u044c &quot;|&quot;, \u0432 \u043f\u043e\u0441\u043b\u0435\u0434\u0441\u0442\u0432\u0438\u0438 \u0447\u0435\u0440\u0435\u0437 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u043c \u043f\u0430\u0440\u0441\u0438\u0442\u044c \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0435 \u0444\u0430\u0439\u043b\u0430.<\/p>\n<pre><code class=\"bash\">&lt;b&gt;$ToFile = $_.DirectoryName + &quot; &quot; + (($dir_property.Sum)\/1024\/1024) | Out-File $LogPathFile  -Append&lt;\/b&gt; <\/code><\/pre>\n<p>  \u041e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u043c \u043a\u0430\u043a\u043e\u0439 \u0444\u0430\u0439\u043b \u0441\u0447\u0438\u0442\u0430\u0435\u043c \u043d\u043e\u0432\u044b\u043c, \u0447\u0442\u043e\u0431\u044b \u043f\u0440\u043e\u0432\u043e\u0434\u0438\u0442\u044c \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435 \u0441 \u0444\u0430\u0439\u043b\u043e\u043c \u043d\u0435\u0434\u0435\u043b\u044c\u043d\u043e\u0439 \u0434\u0430\u0432\u043d\u043e\u0441\u0442\u0438. <\/p>\n<pre><code class=\"bash\">$Mail_body = &quot;&quot;         If ((Get-Item -Path $LogPath\\0.log).LastWriteTime -gt (Get-Item -Path $LogPath\\1.log).LastWriteTime){                 $log_content = Get-Content (Get-ChildItem -Path $LogPath\\0.log)                 foreach ($data in $log_content)                  {                     $x = $data.split(&quot;|&quot;)                     $xc1 = $x[0]                     $xc2 = $x[1]                     $log_content = Get-Content (Get-ChildItem -Path $LogPath\\1.log)                     foreach ($data in $log_content)                      {                         $y = $data.split(&quot;|&quot;)                         if ($xc1 -eq $y[0]){                             if(([Int32]$xc2 - [Int32]$y[1]) -gt 200){                                 $Mail_body += &quot;\u0420\u0435\u0437\u043a\u043e\u0435 \u0443\u0432\u0435\u043b\u0438\u0447\u0435\u043d\u0438\u0435 \u0440\u0430\u0437\u043c\u0435\u0440\u0430 \u043a\u0430\u0442\u0430\u043b\u043e\u0433\u0430: &quot; + $xc1 + &quot;`n \u0420\u0430\u0437\u043c\u0435\u0440 \u043d\u0430 \u043f\u0440\u043e\u0448\u043b\u043e\u0439 \u043d\u0435\u0434\u0435\u043b\u0435 \u0441\u043e\u0441\u0442\u0430\u0432\u0438\u043b: &quot; + $y[1] + &quot; \u041c\u0431.&quot; + &quot;`n \u0420\u0430\u0437\u043c\u0435\u0440 \u043d\u0430 \u0442\u0435\u043a\u0443\u0449\u0435\u0439 \u043d\u0435\u0434\u0435\u043b\u0435 \u0441\u043e\u0441\u0442\u0430\u0432\u0438\u043b: &quot; + $xc2 + &quot; \u041c\u0431.`n&quot;                             }                          }                     }                  }             EmailNotification -Mail_body $Mail_body            }      } <\/code><\/pre>\n<p>  \u041f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u0447\u0435\u0442\u043d\u043e\u0441\u0442\u0438\\\u043d\u0435\u0447\u0435\u0442\u043d\u043e\u0441\u0442\u0438 \u043d\u0435\u0434\u0435\u043b\u044c \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442\u0441\u044f \u0434\u0435\u043b\u0435\u043d\u0438\u0435\u043c \u043f\u043e \u043c\u043e\u0434\u0443\u043b\u044e \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u043e\u0439 \u043d\u0435\u0434\u0435\u043b\u0438 \u0432 \u0433\u043e\u0434\u0443:<\/p>\n<pre><code class=\"bash\">&lt;b&gt;$week%2&lt;\/b&gt; <\/code><\/pre>\n<p>  \u0410\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u044b\u0435 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u0434\u043b\u044f \u043d\u0435\u0447\u0435\u0442\u043d\u043e\u0439 \u043d\u0435\u0434\u0435\u043b\u0438:<\/p>\n<pre><code class=\"bash\">    if ($week%2 -eq 1 -and $Monday -eq 1){         Write-Host &quot;\u041d\u0435\u0447\u0435\u0442\u043d\u0430\u044f \u043d\u0435\u0434\u0435\u043b\u044f&quot;         $LogPathFile = $LogPath + &quot;\\&quot; + ($week%2).ToString() + &quot;.log&quot;         If (!(Test-Path -path $LogPathFile)){             Write-Host &quot;\u0421\u043e\u0437\u0434\u0430\u043b\u0438 \u044d\u043b\u0435\u043c\u0435\u043d\u0442&quot;             New-Item -Path $LogPathFile  -ItemType File         }         $ToFile = &quot;&quot; | Out-File $LogPathFile                  Get-ChildItem -path $dir | %{             $dir_property = dir $_.FullName -recurse | where {-Not $_.PSIsContainer}| Measure-Object -Property length -Sum                   if ($dir_property.Sum -gt $GB){                 $Mail_body+= &quot;\u0420\u0430\u0437\u043c\u0435\u0440 \u043a\u0430\u0442\u0430\u043b\u043e\u0433\u0430 &quot; + $_.FullName + &quot; \u043f\u0440\u0435\u0432\u044b\u0448\u0430\u0435\u0442 \u0440\u0430\u0437\u043c\u0435\u0440 \u0432 1 \u0413\u0431.`n&quot;                 $Mail_body+= &quot;\u0420\u0430\u0437\u043c\u0435\u0440 \u043a\u0430\u0442\u0430\u043b\u043e\u0433\u0430 &quot; + $_.FullName + &quot; \u0441\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 &quot; + (($dir_property.Sum)\/1024\/1024) + &quot; \u041c\u0431.`n&quot;                 $Mail_body+= &quot;------------------------------------------------------------------------------------------`n&quot;                 $ToFile = $_.Name + &quot;|&quot; + (($dir_property.Sum)\/1024\/1024) | Out-File $LogPathFile  -Append             }             else {                 Write-Host &quot;\u0412\u0441\u0435 \u0445\u043e\u0440\u043e\u0448\u043e \u0441 \u043a\u0430\u0442\u0430\u043b\u043e\u0433\u043e\u043c: &quot; $_.FullName             }         }         EmailNotification -Mail_body $Mail_body         $Mail_body = &quot;&quot;         If ((Get-Item -Path $LogPath\\1.log).LastWriteTime -gt (Get-Item -Path $LogPath\\0.log).LastWriteTime){                 $log_content = Get-Content (Get-ChildItem -Path $LogPath\\1.log)                 foreach ($data in $log_content)                  {                     $x = $data.split(&quot;|&quot;)                     $xc1 = $x[0]                     $xc2 = $x[1]                     $log_content = Get-Content (Get-ChildItem -Path $LogPath\\0.log)                     foreach ($data in $log_content)                      {                         $y = $data.split(&quot;|&quot;)                         if ($xc1 -eq $y[0]){                             if(([Int32]$xc2 - [Int32]$y[1]) -gt 200){                                 $Mail_body += &quot;\u0420\u0435\u0437\u043a\u043e\u0435 \u0443\u0432\u0435\u043b\u0438\u0447\u0435\u043d\u0438\u0435 \u0440\u0430\u0437\u043c\u0435\u0440\u0430 \u043a\u0430\u0442\u0430\u043b\u043e\u0433\u0430: &quot; + $xc1 + &quot;`n \u0420\u0430\u0437\u043c\u0435\u0440 \u043d\u0430 \u043f\u0440\u043e\u0448\u043b\u043e\u0439 \u043d\u0435\u0434\u0435\u043b\u0435 \u0441\u043e\u0441\u0442\u0430\u0432\u0438\u043b: &quot; + $y[1] + &quot; \u041c\u0431.&quot; + &quot;`n \u0420\u0430\u0437\u043c\u0435\u0440 \u043d\u0430 \u0442\u0435\u043a\u0443\u0449\u0435\u0439 \u043d\u0435\u0434\u0435\u043b\u0435 \u0441\u043e\u0441\u0442\u0430\u0432\u0438\u043b: &quot; + $xc2 + &quot; \u041c\u0431.`n&quot;                                 $Mail_body                             }                          }                     }                  }             EmailNotification -Mail_body $Mail_body            }                       }          } <\/code><\/pre>\n<p>  \u0414\u043b\u044f \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u043c \u0432\u0445\u043e\u0434\u044f\u0449\u0438\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u0438 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0443. <\/p>\n<pre><code class=\"bash\">#\u041f\u0440\u043e\u0432\u0435\u0440\u0438\u044c \u043a\u0430\u0442\u0430\u043b\u043e\u0433: \u043d\u0435 \u043f\u0440\u0438\u0432\u044b\u0448\u0430\u0435\u0442 \u043b\u0438 \u043e\u043d \u0440\u0430\u0437\u043c\u0435\u0440 \u0432 1 \u0413\u0431 $GB = 1073741824 $dir = &quot;D:\\Program Files&quot; Check-Size-Directory -dir $dir -GB 107374 -Logpath &quot;D:&quot; <\/code><\/pre>\n<p>  \u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u043d\u0430 \u043f\u043e\u0447\u0442\u0443:<\/p>\n<p>  \u0422\u0435\u043c\u0430: DirSize: 11\/27\/2015 11:32:05<br \/>  \u0414\u0430\u0442\u0430: 27 Nov 2015 11:32:05 +0200<br \/>  \u041e\u0442: sizefoldres@gmail.com<br \/>  \u041a\u043e\u043c\u0443: levitskaks@gmail.com<\/p>\n<p>  \u0420\u0430\u0437\u043c\u0435\u0440 \u043a\u0430\u0442\u0430\u043b\u043e\u0433\u0430 F:\\Shared\\PrivateData\\BRU \u043f\u0440\u0435\u0432\u044b\u0448\u0430\u0435\u0442 \u0440\u0430\u0437\u043c\u0435\u0440 \u0432 1 \u0413\u0431.<br \/>  \u0420\u0430\u0437\u043c\u0435\u0440 \u043a\u0430\u0442\u0430\u043b\u043e\u0433\u0430 F:\\Shared\\PrivateData\\BRU \u0441\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 1239.06250095367 \u041c\u0431.<br \/>   \u2014 <\/p>\n<p>  \u0420\u0430\u0437\u043c\u0435\u0440 \u043a\u0430\u0442\u0430\u043b\u043e\u0433\u0430 F:\\Shared\\PrivateData\\Dan\u043f\u0440\u0435\u0432\u044b\u0448\u0430\u0435\u0442 \u0440\u0430\u0437\u043c\u0435\u0440 \u0432 1 \u0413\u0431.<br \/>  \u0420\u0430\u0437\u043c\u0435\u0440 \u043a\u0430\u0442\u0430\u043b\u043e\u0433\u0430 F:\\Shared\\PrivateData\\Dan \u0441\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 1670.62088680267 \u041c\u0431.<br \/>   \u2014 <\/p>\n<p>  \u0420\u0430\u0437\u043c\u0435\u0440 \u043a\u0430\u0442\u0430\u043b\u043e\u0433\u0430 F:\\Shared\\PrivateData\\DYA \u043f\u0440\u0435\u0432\u044b\u0448\u0430\u0435\u0442 \u0440\u0430\u0437\u043c\u0435\u0440 \u0432 1 \u0413\u0431.<br \/>  \u0420\u0430\u0437\u043c\u0435\u0440 \u043a\u0430\u0442\u0430\u043b\u043e\u0433\u0430 F:\\Shared\\PrivateData\\DYA \u0441\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 7456.12028884888 \u041c\u0431.<br \/>   \u2014 <\/p>\n<p>  \u0420\u0430\u0437\u043c\u0435\u0440 \u043a\u0430\u0442\u0430\u043b\u043e\u0433\u0430 F:\\Shared\\PrivateData\\GLU \u043f\u0440\u0435\u0432\u044b\u0448\u0430\u0435\u0442 \u0440\u0430\u0437\u043c\u0435\u0440 \u0432 1 \u0413\u0431.<br \/>  \u0420\u0430\u0437\u043c\u0435\u0440 \u043a\u0430\u0442\u0430\u043b\u043e\u0433\u0430 F:\\Shared\\PrivateData\\GLU \u0441\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 2198.93785953522 \u041c\u0431.<br \/>   \u2014 <br \/>  \u2026<\/p>\n<p>  \u0421\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0435 \u0444\u0430\u0439\u043b\u0430 0.log:<\/p>\n<pre><code class=\"bash\">ActiveX|2.8662109375 <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-269430","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/269430","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=269430"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/269430\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=269430"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=269430"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=269430"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}