{"id":285888,"date":"2017-05-04T08:30:03","date_gmt":"2017-05-04T04:30:03","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=285888"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=285888","title":{"rendered":"3 \u0430\u0434\u043c\u0438\u043d\u0438\u0441\u0442\u0440\u0430\u0442\u0438\u0432\u043d\u044b\u0445 \u0441\u043a\u0440\u0438\u043f\u0442\u0430"},"content":{"rendered":"<p>\u043d\u0443\u0436\u043d\u043e \u043e\u0436\u0438\u0432\u0438\u0442\u044c \u043f\u0430\u0431\u043b\u0438\u043a \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0430\u0434\u043c\u0438\u043d\u0438\u0441\u0442\u0440\u0430\u0442\u0438\u0432\u043d\u044b\u0445 \u0441\u043a\u0440\u0438\u043f\u0442\u043e\u0432<br \/>  1. \u041f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0441\u0435\u0442\u0435\u0432\u044b\u0435 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u0438 \u043a\u043e\u043d\u0444\u0438\u0433\u0438 \u0434\u043e\u043c\u0435\u043d\u043d\u044b\u0445 \u043a\u043e\u043c\u043f\u043e\u0432<br \/>  2. \u041f\u043e\u043c\u0435\u043d\u044f\u0442\u044c \u0448\u043b\u044e\u0437 \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u043d\u0430 \u0434\u043e\u043c\u0435\u043d\u043d\u044b\u0445 \u043a\u043e\u043c\u043f\u0430\u0445<br \/>  3. \u041f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0441\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u043a\u0443 \u043f\u043e \u043f\u043e\u0447\u0442\u043e\u0432\u044b\u043c \u044f\u0449\u0438\u043a\u0430\u043c<\/p>\n<h3>1. \u041f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0441\u0435\u0442\u0435\u0432\u044b\u0435 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u0438 \u043a\u043e\u043d\u0444\u0438\u0433\u0438 \u0434\u043e\u043c\u0435\u043d\u043d\u044b\u0445 \u043a\u043e\u043c\u043f\u043e\u0432.<\/h3>\n<p>  \u041e\u0431\u0445\u043e\u0434\u0438\u0442 \u0434\u043e\u043c\u0435\u043d\u043d\u044b\u0435 \u043a\u043e\u043c\u043f\u044c\u044e\u0442\u0435\u0440\u044b \u0438 \u0441\u043e\u0431\u0438\u0440\u0430\u0435\u0442 \u0441 \u043d\u0438\u0445 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e. \u041d\u0430 \u0432\u044b\u0445\u043e\u0434\u0435 \u0432\u044b\u0431\u0440\u0430\u0441\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043f\u043e\u043b\u043d\u043e\u0446\u0435\u043d\u043d\u044b\u0439 \u043e\u0431\u044a\u0435\u043a\u0442. \u041a\u043e\u043c\u043f\u044c\u044e\u0442\u0435\u0440 \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u0442\u044c \u0432\u043a\u043b\u044e\u0447\u0435\u043d \u043a\u043e\u043d\u0435\u0447\u043d\u043e \u0436\u0435. \u0421\u0446\u0435\u043d\u0430\u0440\u0438\u0439 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u043f\u0440\u0438\u043c\u0435\u0440 \u0440\u0430\u0431\u043e\u0442\u044b \u0447\u0435\u0440\u0435\u0437 WMI. \u0417\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u0441 \u0434\u043e\u043c\u0435\u043d\u0430.  <\/p>\n<pre><code># \u0437\u0430\u043f\u0440\u0430\u0448\u0438\u0432\u0430\u0435\u043c \u043a\u0440\u0435\u0434\u0438\u0442\u0430\u043b\u044b \u0434\u043e\u043c\u0435\u043d\u043d\u043e\u0433\u043e \u0430\u0434\u043c\u0438\u043d\u0430 $cred = Get-Credential &lt;anchor&gt;habracut&lt;\/anchor&gt; $Clients = Get-ADComputer -Filter * | Sort-Object name | Select-Object name $CompData = @()  foreach ($cli in $Clients)    {     if (( Test-Connection $cli.Name -Count 2 -Quiet ) -eq 'True')       {         if ($cli.name -ne $env:COMPUTERNAME)        {             #\u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043f\u043e WMI             $os = Get-WmiObject -ComputerName $cli.name Win32_OperatingSystem -Credential $cred             $net = Get-WmiObject -Class Win32_NetWorkAdapterConfiguration -Filter IPEnabled=TRUE -ComputerName $cli.name  -Credential $cred             $nic = Get-WmiObject -Class Win32_NetWorkAdapter -ComputerName $cli.name  -Credential $cred | where {$_.adaptertype -eq 'Ethernet 802.3'} | where { $_.NetEnabled -eq 'True'}             $disk = Get-WmiObject -Class Win32_DiskDrive -ComputerName $cli.name -Credential $cred               $props = [ordered]@{ Name=$os.CSName                         OSName=$os.Caption                         OSSN=$os.SerialNumber                         OSVersion=$os.Version                         OSSystemDirectory=$os.SystemDirectory                         OSBuild=$os.BuildNumber                         OSMUI=$os.MUILanguages                         OSBootDevice=$os.BootDevice                         NICNetConnectionID=$nic.NetConnectionID                         NICName=$nic.Name                         NICDeviceID=$nic.DeviceID                         NICAdapterType=$nic.AdapterType                         NICIndex=$nic.Index                         NICInterfaceIndex=$nic.InterfaceIndex                         NICMAC=$nic.MACAddress                         NICManufacturer=$nic.Manufacturer                         NICNetEnabled=$nic.NetEnabled                         NICPhysical=$nic.PhysicalAdapter                         NICProductName=$nic.ProductName                         NICServiceName=$nic.ServiceName                         NICSpeed=$nic.Speed                         NetDHCPEnabled=$net.DHCPEnabled                         NetIPAddress=$net.IPAddress                         NetDefaultGateway=$net.DefaultIPGateway                         DiskName=$disk.Caption                          DiskStatus=$disk.Status                          DiskDeviceId=$disk.deviceid                          DiskSerialNumber=$disk.serialnumber                          DiskSize=$disk.size                          }              $obj = New-Object -TypeName PSObject -Property $props             $CompData += $obj         }     } }  $CompData <\/code><\/pre>\n<h3>2. \u041f\u043e\u043c\u0435\u043d\u044f\u0442\u044c \u0448\u043b\u044e\u0437 \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e<\/h3>\n<p>  \u041c\u043e\u0434\u0438\u0444\u0438\u0446\u0438\u0440\u0443\u0435\u043c \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u0439 \u0441\u043a\u0440\u0438\u043f\u0442 \u0442\u0430\u043a \u0447\u0442\u043e\u0431\u044b \u043e\u043d \u043c\u0435\u043d\u044f\u043b \u0448\u043b\u044e\u0437 \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e. (\u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u0432\u0441\u0435 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0439\u0442\u0435 \u0432 \u0441\u0432\u043e\u0435\u0439 \u0441\u0440\u0435\u0434\u0435 \u043f\u0435\u0440\u0435\u0434 \u0437\u0430\u043f\u0443\u0441\u043a\u043e\u043c \u043d\u0430 \u0436\u0438\u0432\u043e\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u0435!) \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u0432 \u0434\u043b\u044f \u0441\u043c\u0435\u043d\u044b \u0448\u043b\u044e\u0437\u0430 \u0432\u044b\u0437\u043e\u0432\u044b WMI \u0442.\u043a. \u0447\u0435\u0440\u0435\u0437 \u043f\u043e\u0432\u0435\u0440\u0448\u0435\u043b\u043b \u043d\u0443\u0436\u043d\u043e \u0443\u0434\u0430\u043b\u0438\u0442\u044c \u0438 \u0441\u043d\u043e\u0432\u0430 \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0430\u0434\u0430\u043f\u0442\u0435\u0440, \u0447\u0442\u043e \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u0442 \u043a \u043f\u043e\u0442\u0435\u0440\u0438 \u0441\u0432\u044f\u0437\u0438 \u0441 \u043a\u043e\u043c\u043f\u044c\u044e\u0442\u0435\u0440\u043e\u043c. \u041f\u0440\u043e\u0432\u0435\u0440\u044f\u043b\u0441\u044f \u043d\u0430 Powershell 4 \u0438 3, win 2012 \u0438 8  <\/p>\n<pre><code>$cred = Get-Credential  $OldGateway = '192.168.30.1' $NewGateway = '192.168.30.50'  $Clients = Get-ADComputer -Filter * | Sort-Object name | Select-Object name $CompData = @()  foreach ($cli in $Clients) {     if (( Test-Connection $cli.Name -Count 2 -Quiet ) -eq 'True')     {         if ($cli.name -ne $env:COMPUTERNAME)         {             $os = Get-WmiObject -ComputerName $cli.name Win32_OperatingSystem -Credential $cred             $net = Get-WmiObject -Class Win32_NetWorkAdapterConfiguration -Filter IPEnabled=TRUE -ComputerName $cli.name  -Credential $cred             $nic = Get-WmiObject -Class Win32_NetWorkAdapter -ComputerName $cli.name  -Credential $cred | where {$_.adaptertype -eq 'Ethernet 802.3'} | where { $_.NetEnabled -eq 'True'}             $disk = Get-WmiObject -Class Win32_DiskDrive -ComputerName $cli.name -Credential $cred               $props = [ordered]@{ Name=$os.CSName                         OSName=$os.Caption                         OSSN=$os.SerialNumber                         OSVersion=$os.Version                         OSSystemDirectory=$os.SystemDirectory                         OSBuild=$os.BuildNumber                         OSMUI=$os.MUILanguages                         OSBootDevice=$os.BootDevice                         NICNetConnectionID=$nic.NetConnectionID                         NICName=$nic.Name                         NICDeviceID=$nic.DeviceID                         NICAdapterType=$nic.AdapterType                         NICIndex=$nic.Index                         NICInterfaceIndex=$nic.InterfaceIndex                         NICMAC=$nic.MACAddress                         NICManufacturer=$nic.Manufacturer                         NICNetEnabled=$nic.NetEnabled                         NICPhysical=$nic.PhysicalAdapter                         NICProductName=$nic.ProductName                         NICServiceName=$nic.ServiceName                         NICSpeed=$nic.Speed                         NetDHCPEnabled=$net.DHCPEnabled                         NetIPAddress=$net.IPAddress                         NetDefaultGateway=$net.DefaultIPGateway                         DiskName=$disk.Caption                          DiskStatus=$disk.Status                          DiskDeviceId=$disk.deviceid                          DiskSerialNumber=$disk.serialnumber                          DiskSize=$disk.size                          }              $obj = New-Object -TypeName PSObject -Property $props              $CompData += $obj         }     } }  #$CompData ################################################################  # \u041c\u0435\u043d\u044f\u0435\u043c \u0448\u043b\u044e\u0437 foreach($Co in $CompData) {          if ($Co.NetDefaultGateway = $OldGateway)       {             $Co.Name             $Co.netdefaultgateway              $NWCards = Get-WmiObject Win32_NetworkAdapterConfiguration -ComputerName $co.Name -Credential $cred | where{ $_.ipenabled -eq $true }             foreach ($nwc in $NWCards)       {                 $gateway = $nwc.defaultipgateway                 if ($gateway -eq $OldGateway)       {                     $nwc.setgateways($NewGateway)                 }             }          } } <\/code><\/pre>\n<p>  <\/p>\n<h3>3. \u041f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0441\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u043a\u0443 \u043f\u043e \u043f\u043e\u0447\u0442\u043e\u0432\u044b\u043c \u044f\u0449\u0438\u043a\u0430\u043c<\/h3>\n<p>  \u0421\u043e\u0431\u0438\u0440\u0430\u0435\u0442 \u0441\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u043a\u0443 \u0442\u043e\u043f \u044f\u0449\u0438\u043a\u043e\u0432 \u043f\u043e \u0440\u0430\u0437\u043c\u0435\u0440\u0443, \u0442\u043e\u043f \u044f\u0449\u0438\u043a\u043e\u0432 \u043f\u043e \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0443 \u043f\u0438\u0441\u0435\u043c, \u0442\u043e\u043f \u044f\u0449\u0438\u043a\u043e\u0432 \u043f\u043e \u0443\u0434\u0430\u043b\u0435\u043d\u044b\u043c \u0430\u0439\u0442\u0435\u043c\u0430\u043c (purge \u043a\u043e\u0440\u0437\u0438\u043d\u044b 2 \u0435\u0449\u0435 \u043d\u0435 \u043f\u0440\u043e\u0438\u0437\u043e\u0448\u0435\u043b, \u0442\u043e\u043b\u044c\u043a\u043e \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u0435 \u043f\u0438\u0441\u0435\u043c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u043c), \u043f\u043e\u0441\u043b\u0435 \u0444\u043e\u0440\u043c\u0438\u0440\u0443\u0435\u0442 \u00ab\u043a\u0440\u0430\u0441\u0438\u0432\u044b\u0439\u00bb \u043e\u0442\u0447\u0435\u0442 \u0432 HTML \u0438 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442 \u043d\u0430 \u043f\u043e\u0447\u0442\u0443 \u0438 \u0441\u043a\u043b\u0430\u0434\u044b\u0432\u0430\u0435\u0442 \u0432 \u043f\u0430\u043f\u043e\u0447\u043a\u0443. \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0441\u044f \u043a\u0430\u043a \u0435\u0436\u0435\u043c\u0435\u0441\u044f\u0447\u043d\u044b\u0439 \u0440\u0435\u043f\u043e\u0440\u0442\u0435\u0440 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f \u0431\u0430\u0437\u044b, \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u043b\u0441\u044f \u0432 \u0442\u0430\u0441\u043a \u0448\u0435\u0434\u0430\u043b\u0435\u0440. \u0417\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u043d\u0430 \u0441\u0435\u0440\u0432\u0435\u0440\u0435 exchange. \u041f\u0440\u043e\u0432\u0435\u0440\u044f\u043b\u043e\u0441\u044c \u043d\u0430 Exchange 2010.  <\/p>\n<pre><code>&lt;#      \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u0432\u044b\u0431\u0438\u0440\u0430\u0435\u0442 \u043f\u043e 25 \u0442\u043e\u043f \u043c\u044d\u0439\u043b\u0431\u043e\u043a\u0441\u043e\u0432     \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u0435 \u043e\u0442\u0447\u0435\u0442\u0430 \u043d\u0430 \u0434\u0438\u0441\u043a \u043e\u0442\u043a\u043b\u044e\u0447\u0435\u043d\u043e #&gt;  Param (  [int]$TopCount = 25,         [boolean]$SaveReport = $false,         [string]$ReportPath = 'C:\\Reports\\MailboxReport.html',         [boolean]$SendReport = $true,         [string]$ReportMail1 = 'admin@mail.local'     )  # check snapin present $EX2010 = $false  $snaps = Get-PSSnapin foreach( $snap in $snaps )  {     if ($snap.Name -eq 'Microsoft.Exchange.Management.PowerShell.E2010')   {         $EX2010 = $true     } }  if ($EX2010 -eq $false) {     Add-PSSnapin Microsoft.Exchange.Management.PowerShell.E2010 }  $boxes = Get-Mailbox | Get-MailboxStatistics | sort TotalItemSize -Descending $TotalSize = $boxes | sort TotalItemSize -Descending | select -First $TopCount  # \u0441\u0430\u043c\u044b\u0435 \u0442\u043e\u043b\u0441\u0442\u044b\u0435 \u044f\u0449\u0438\u043a\u0438 $Size = @() foreach ($box in $TotalSize)  {     $propsTotalSize = [ordered]@{   DisplayName=$box.DisplayName                                     User=$box.LastLoggedOnUserAccount                                     Database=$box.Database                                     TotalSize=$box.TotalItemSize                                     ItemCount=$box.ItemCount                                     DeletedItemCount=$box.DeletedItemCount                                     TotalDeletedSize=$box.TotalDeletedItemSize                         }             $obj = New-Object -TypeName PSObject -Property $propsTotalSize             $Size += $obj }  # \u0442\u043e\u043f \u0443\u0434\u0430\u043b\u0435\u043d\u044b\u0445 \u0431\u0435\u0437 purge $Deleted = $boxes | sort TotalDeletedItemSize -Descending | select -First $TopCount $Del = @() foreach ($box in $Deleted)   {     $propsDeleted = [ordered]@{   DisplayName=$box.DisplayName                                   User=$box.LastLoggedOnUserAccount                                   Database=$box.Database                                   TotalSize=$box.TotalItemSize                                   ItemCount=$box.ItemCount                                   DeletedItemCount=$box.DeletedItemCount                                   TotalDeletedSize=$box.TotalDeletedItemSize                         }             $obj = New-Object -TypeName PSObject -Property $propsDeleted             $Del += $obj }  # \u0442\u043e\u043f \u043f\u043e \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0443 \u043f\u0438\u0441\u0435\u043c, \u0441\u043b\u0438\u0448\u043a\u043e\u043c \u043c\u043d\u043e\u0433\u043e \u0438\u043d\u0434\u0438\u043a\u0430\u0442\u043e\u0440 \u0447\u0442\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u0441\u0432\u0430\u043b\u0438\u0432\u0430\u0435\u0442 \u0432\u0441\u0435 \u0432 \u043a\u0443\u0447\u0443 \u0438 \u043d\u0443\u0436\u0434\u0430\u0435\u0442\u0441\u044f \u0432 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u043f\u0440\u0430\u0432\u0438\u043b\u0430\u0445 $Top = $boxes | sort ItemCount -Descending | select -First $TopCount $TopItems = @() foreach ($box in $Top)  {     $propsTopItems = [ordered]@{   DisplayName=$box.DisplayName                                    User=$box.LastLoggedOnUserAccount                                    Database=$box.Database                                    TotalSize=$box.TotalItemSize                                    ItemCount=$box.ItemCount                                    DeletedItemCount=$box.DeletedItemCount                                    TotalDeletedSize=$box.TotalDeletedItemSize                         }             $obj = New-Object -TypeName PSObject -Property $propsTopItems             $TopItems += $obj }  ##### HTML generating Write-Verbose 'HTML fragment producing' $fragTopItems = $TopItems | ConvertTo-Html -As table -Fragment -PreContent '&lt;h2&gt;\u0422\u043e\u043f \u044f\u0449\u0438\u043a\u043e\u0432 \u043f\u043e \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0443 \u043f\u0438\u0441\u0435\u043c (items count)&lt;\/h2&gt;' | Out-String $fragTopSizes =     $Size | ConvertTo-Html -As table -Fragment -PreContent '&lt;h2&gt;\u0422\u043e\u043f \u044f\u0449\u0438\u043a\u043e\u0432 \u043f\u043e \u0440\u0430\u0437\u043c\u0435\u0440\u0443&lt;\/h2&gt;' | Out-String $fragTopDelItems =   $Del | ConvertTo-Html -As table -Fragment -PreContent '&lt;h2&gt;\u0422\u043e\u043f \u044f\u0449\u0438\u043a\u043e\u0432 \u043f\u043e \u0443\u0434\u0430\u043b\u0435\u043d\u043d\u044b\u043c \u043f\u0438\u0441\u044c\u043c\u0430\u043c (purge \u0435\u0449\u0435 \u043d\u0435 \u0431\u044b\u043b\u043e)&lt;\/h2&gt;' | Out-String  Write-Verbose 'definiting CSS' $head = @' &lt;style&gt; body { background-color:#ffffff; font-family:Tahoma; font-size:12pt; } td, th { border:1px solid black; border-collapse:collapse; } th { color:white; background-color:black; } table, tr, td, th { padding: 2px; margin: 0px } table { font-family: &quot;Lucida Sans Unicode&quot;, &quot;Lucida Grande&quot;, Sans-Serif; font-size: 14px; border-radius: 10px; border-spacing: 0; text-align: center; } th { background: #BCEBDD; color: white; text-shadow: 0 1px 1px #2D2020; padding: 10px 20px; } th, td { border-style: solid; border-width: 0 1px 1px 0; border-color: white; } th:first-child, td:first-child { text-align: left; } th:first-child { border-top-left-radius: 10px; } th:last-child { border-top-right-radius: 10px; border-right: none; } td { padding: 10px 20px; background: #F8E391; } tr:last-child td:first-child { border-radius: 0 0 0 10px; } tr:last-child td:last-child { border-radius: 0 0 10px 0; } tr td:last-child { border-right: none; } &lt;\/style&gt; '@  Write-Verbose 'HTML producing' $Date = Get-Date  if ($SaveReport = $true) {     $rep = ConvertTo-HTML -head $head -PostContent $fragTopSizes, $fragTopDelItems, $fragTopItems -PreContent &quot;&lt;h1&gt;\u041e\u0442\u0447\u0435\u0442 \u043f\u043e \u043f\u043e\u0447\u0442\u043e\u0432\u044b\u043c \u044f\u0449\u0438\u043a\u0430\u043c $Date&lt;\/h1&gt;&quot; | Out-String     $rep | Out-File $ReportPath }  # Sending Email to admins if ($SendReport = $true) {     $encoding = [System.Text.Encoding]::UTF8     $body = ConvertTo-HTML -head $head -PostContent $fragTopSizes, $fragTopDelItems, $fragTopItems -PreContent &quot;&lt;h1&gt;\u041e\u0442\u0447\u0435\u0442 \u043f\u043e \u043f\u043e\u0447\u0442\u043e\u0432\u044b\u043c \u044f\u0449\u0438\u043a\u0430\u043c $Date&lt;\/h1&gt;&quot; | Out-String      Write-Verbose &quot;Sending e-mail&quot;     $params = @{'To'=$ReportMail1                'From'='bot@geomex.local'                'Subject'=&quot;Mailbox report $Date&quot;                'Body'=$Body                'BodyAsHTML'=$True                'SMTPServer'='DC01.geomex.local'}     Send-MailMessage @params -Encoding $encoding } <\/code><\/pre>\n<p>  \u0432\u0441\u0435\u0445 \u0441 \u043c\u0430\u0439\u0441\u043a\u0438\u043c\u0438 \u043f\u0440\u0430\u0437\u0434\u043d\u0438\u043a\u0430\u043c\u0438<br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habrahabr.ru\/post\/327980\/\"> https:\/\/habrahabr.ru\/post\/327980\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u043d\u0443\u0436\u043d\u043e \u043e\u0436\u0438\u0432\u0438\u0442\u044c \u043f\u0430\u0431\u043b\u0438\u043a \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0430\u0434\u043c\u0438\u043d\u0438\u0441\u0442\u0440\u0430\u0442\u0438\u0432\u043d\u044b\u0445 \u0441\u043a\u0440\u0438\u043f\u0442\u043e\u0432<br \/>  1. \u041f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0441\u0435\u0442\u0435\u0432\u044b\u0435 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u0438 \u043a\u043e\u043d\u0444\u0438\u0433\u0438 \u0434\u043e\u043c\u0435\u043d\u043d\u044b\u0445 \u043a\u043e\u043c\u043f\u043e\u0432<br \/>  2. \u041f\u043e\u043c\u0435\u043d\u044f\u0442\u044c \u0448\u043b\u044e\u0437 \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u043d\u0430 \u0434\u043e\u043c\u0435\u043d\u043d\u044b\u0445 \u043a\u043e\u043c\u043f\u0430\u0445<br \/>  3. \u041f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0441\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u043a\u0443 \u043f\u043e \u043f\u043e\u0447\u0442\u043e\u0432\u044b\u043c \u044f\u0449\u0438\u043a\u0430\u043c<\/p>\n<h3>1. \u041f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0441\u0435\u0442\u0435\u0432\u044b\u0435 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u0438 \u043a\u043e\u043d\u0444\u0438\u0433\u0438 \u0434\u043e\u043c\u0435\u043d\u043d\u044b\u0445 \u043a\u043e\u043c\u043f\u043e\u0432.<\/h3>\n<p>  \u041e\u0431\u0445\u043e\u0434\u0438\u0442 \u0434\u043e\u043c\u0435\u043d\u043d\u044b\u0435 \u043a\u043e\u043c\u043f\u044c\u044e\u0442\u0435\u0440\u044b \u0438 \u0441\u043e\u0431\u0438\u0440\u0430\u0435\u0442 \u0441 \u043d\u0438\u0445 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e. \u041d\u0430 \u0432\u044b\u0445\u043e\u0434\u0435 \u0432\u044b\u0431\u0440\u0430\u0441\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043f\u043e\u043b\u043d\u043e\u0446\u0435\u043d\u043d\u044b\u0439 \u043e\u0431\u044a\u0435\u043a\u0442. \u041a\u043e\u043c\u043f\u044c\u044e\u0442\u0435\u0440 \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u0442\u044c \u0432\u043a\u043b\u044e\u0447\u0435\u043d \u043a\u043e\u043d\u0435\u0447\u043d\u043e \u0436\u0435. \u0421\u0446\u0435\u043d\u0430\u0440\u0438\u0439 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u043f\u0440\u0438\u043c\u0435\u0440 \u0440\u0430\u0431\u043e\u0442\u044b \u0447\u0435\u0440\u0435\u0437 WMI. \u0417\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u0441 \u0434\u043e\u043c\u0435\u043d\u0430.  <\/p>\n<pre><code># \u0437\u0430\u043f\u0440\u0430\u0448\u0438\u0432\u0430\u0435\u043c \u043a\u0440\u0435\u0434\u0438\u0442\u0430\u043b\u044b \u0434\u043e\u043c\u0435\u043d\u043d\u043e\u0433\u043e \u0430\u0434\u043c\u0438\u043d\u0430 $cred = Get-Credential &lt;anchor&gt;habracut&lt;\/anchor&gt; $Clients = Get-ADComputer -Filter * | Sort-Object name | Select-Object name $CompData = @()  foreach ($cli in $Clients)    {     if (( Test-Connection $cli.Name -Count 2 -Quiet ) -eq 'True')       {         if ($cli.name -ne $env:COMPUTERNAME)        {             #\u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043f\u043e WMI             $os = Get-WmiObject -ComputerName $cli.name Win32_OperatingSystem -Credential $cred             $net = Get-WmiObject -Class Win32_NetWorkAdapterConfiguration -Filter IPEnabled=TRUE -ComputerName $cli.name  -Credential $cred             $nic = Get-WmiObject -Class Win32_NetWorkAdapter -ComputerName $cli.name  -Credential $cred | where {$_.adaptertype -eq 'Ethernet 802.3'} | where { $_.NetEnabled -eq 'True'}             $disk = Get-WmiObject -Class Win32_DiskDrive -ComputerName $cli.name -Credential $cred               $props = [ordered]@{ Name=$os.CSName                         OSName=$os.Caption                         OSSN=$os.SerialNumber                         OSVersion=$os.Version                         OSSystemDirectory=$os.SystemDirectory                         OSBuild=$os.BuildNumber                         OSMUI=$os.MUILanguages                         OSBootDevice=$os.BootDevice                         NICNetConnectionID=$nic.NetConnectionID                         NICName=$nic.Name                         NICDeviceID=$nic.DeviceID                         NICAdapterType=$nic.AdapterType                         NICIndex=$nic.Index                         NICInterfaceIndex=$nic.InterfaceIndex                         NICMAC=$nic.MACAddress                         NICManufacturer=$nic.Manufacturer                         NICNetEnabled=$nic.NetEnabled                         NICPhysical=$nic.PhysicalAdapter                         NICProductName=$nic.ProductName                         NICServiceName=$nic.ServiceName                         NICSpeed=$nic.Speed                         NetDHCPEnabled=$net.DHCPEnabled                         NetIPAddress=$net.IPAddress                         NetDefaultGateway=$net.DefaultIPGateway                         DiskName=$disk.Caption                          DiskStatus=$disk.Status                          DiskDeviceId=$disk.deviceid                          DiskSerialNumber=$disk.serialnumber                          DiskSize=$disk.size                          }              $obj = New-Object -TypeName PSObject -Property $props             $CompData += $obj         }     } }  $CompData <\/code><\/pre>\n<h3>2. \u041f\u043e\u043c\u0435\u043d\u044f\u0442\u044c \u0448\u043b\u044e\u0437 \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e<\/h3>\n<p>  \u041c\u043e\u0434\u0438\u0444\u0438\u0446\u0438\u0440\u0443\u0435\u043c \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u0439 \u0441\u043a\u0440\u0438\u043f\u0442 \u0442\u0430\u043a \u0447\u0442\u043e\u0431\u044b \u043e\u043d \u043c\u0435\u043d\u044f\u043b \u0448\u043b\u044e\u0437 \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e. (\u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u0432\u0441\u0435 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0439\u0442\u0435 \u0432 \u0441\u0432\u043e\u0435\u0439 \u0441\u0440\u0435\u0434\u0435 \u043f\u0435\u0440\u0435\u0434 \u0437\u0430\u043f\u0443\u0441\u043a\u043e\u043c \u043d\u0430 \u0436\u0438\u0432\u043e\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u0435!) \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u0432 \u0434\u043b\u044f \u0441\u043c\u0435\u043d\u044b \u0448\u043b\u044e\u0437\u0430 \u0432\u044b\u0437\u043e\u0432\u044b WMI \u0442.\u043a. \u0447\u0435\u0440\u0435\u0437 \u043f\u043e\u0432\u0435\u0440\u0448\u0435\u043b\u043b \u043d\u0443\u0436\u043d\u043e \u0443\u0434\u0430\u043b\u0438\u0442\u044c \u0438 \u0441\u043d\u043e\u0432\u0430 \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0430\u0434\u0430\u043f\u0442\u0435\u0440, \u0447\u0442\u043e \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u0442 \u043a \u043f\u043e\u0442\u0435\u0440\u0438 \u0441\u0432\u044f\u0437\u0438 \u0441 \u043a\u043e\u043c\u043f\u044c\u044e\u0442\u0435\u0440\u043e\u043c. \u041f\u0440\u043e\u0432\u0435\u0440\u044f\u043b\u0441\u044f \u043d\u0430 Powershell 4 \u0438 3, win 2012 \u0438 8  <\/p>\n<pre><code>$cred = Get-Credential  $OldGateway = '192.168.30.1' $NewGateway = '192.168.30.50'  $Clients = Get-ADComputer -Filter * | Sort-Object name | Select-Object name $CompData = @()  foreach ($cli in $Clients) {     if (( Test-Connection $cli.Name -Count 2 -Quiet ) -eq 'True')     {         if ($cli.name -ne $env:COMPUTERNAME)         {             $os = Get-WmiObject -ComputerName $cli.name Win32_OperatingSystem -Credential $cred             $net = Get-WmiObject -Class Win32_NetWorkAdapterConfiguration -Filter IPEnabled=TRUE -ComputerName $cli.name  -Credential $cred             $nic = Get-WmiObject -Class Win32_NetWorkAdapter -ComputerName $cli.name  -Credential $cred | where {$_.adaptertype -eq 'Ethernet 802.3'} | where { $_.NetEnabled -eq 'True'}             $disk = Get-WmiObject -Class Win32_DiskDrive -ComputerName $cli.name -Credential $cred               $props = [ordered]@{ Name=$os.CSName                         OSName=$os.Caption                         OSSN=$os.SerialNumber                         OSVersion=$os.Version                         OSSystemDirectory=$os.SystemDirectory                         OSBuild=$os.BuildNumber                         OSMUI=$os.MUILanguages                         OSBootDevice=$os.BootDevice                         NICNetConnectionID=$nic.NetConnectionID                         NICName=$nic.Name                         NICDeviceID=$nic.DeviceID                         NICAdapterType=$nic.AdapterType                         NICIndex=$nic.Index                         NICInterfaceIndex=$nic.InterfaceIndex                         NICMAC=$nic.MACAddress                         NICManufacturer=$nic.Manufacturer                         NICNetEnabled=$nic.NetEnabled                         NICPhysical=$nic.PhysicalAdapter                         NICProductName=$nic.ProductName                         NICServiceName=$nic.ServiceName                         NICSpeed=$nic.Speed                         NetDHCPEnabled=$net.DHCPEnabled                         NetIPAddress=$net.IPAddress                         NetDefaultGateway=$net.DefaultIPGateway                         DiskName=$disk.Caption                          DiskStatus=$disk.Status                          DiskDeviceId=$disk.deviceid                          DiskSerialNumber=$disk.serialnumber                          DiskSize=$disk.size                          }              $obj = New-Object -TypeName PSObject -Property $props              $CompData += $obj         }     } }  #$CompData ################################################################  # \u041c\u0435\u043d\u044f\u0435\u043c \u0448\u043b\u044e\u0437 foreach($Co in $CompData) {          if ($Co.NetDefaultGateway = $OldGateway)       {             $Co.Name             $Co.netdefaultgateway              $NWCards = Get-WmiObject Win32_NetworkAdapterConfiguration -ComputerName $co.Name -Credential $cred | where{ $_.ipenabled -eq $true }             foreach ($nwc in $NWCards)       {                 $gateway = $nwc.defaultipgateway                 if ($gateway -eq $OldGateway)       {                     $nwc.setgateways($NewGateway)                 }             }          } } <\/code><\/pre>\n<p>  <\/p>\n<h3>3. \u041f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0441\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u043a\u0443 \u043f\u043e \u043f\u043e\u0447\u0442\u043e\u0432\u044b\u043c \u044f\u0449\u0438\u043a\u0430\u043c<\/h3>\n<p>  \u0421\u043e\u0431\u0438\u0440\u0430\u0435\u0442 \u0441\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u043a\u0443 \u0442\u043e\u043f \u044f\u0449\u0438\u043a\u043e\u0432 \u043f\u043e \u0440\u0430\u0437\u043c\u0435\u0440\u0443, \u0442\u043e\u043f \u044f\u0449\u0438\u043a\u043e\u0432 \u043f\u043e \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0443 \u043f\u0438\u0441\u0435\u043c, \u0442\u043e\u043f \u044f\u0449\u0438\u043a\u043e\u0432 \u043f\u043e \u0443\u0434\u0430\u043b\u0435\u043d\u044b\u043c \u0430\u0439\u0442\u0435\u043c\u0430\u043c (purge \u043a\u043e\u0440\u0437\u0438\u043d\u044b 2 \u0435\u0449\u0435 \u043d\u0435 \u043f\u0440\u043e\u0438\u0437\u043e\u0448\u0435\u043b, \u0442\u043e\u043b\u044c\u043a\u043e \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u0435 \u043f\u0438\u0441\u0435\u043c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u043c), \u043f\u043e\u0441\u043b\u0435 \u0444\u043e\u0440\u043c\u0438\u0440\u0443\u0435\u0442 \u00ab\u043a\u0440\u0430\u0441\u0438\u0432\u044b\u0439\u00bb \u043e\u0442\u0447\u0435\u0442 \u0432 HTML \u0438 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442 \u043d\u0430 \u043f\u043e\u0447\u0442\u0443 \u0438 \u0441\u043a\u043b\u0430\u0434\u044b\u0432\u0430\u0435\u0442 \u0432 \u043f\u0430\u043f\u043e\u0447\u043a\u0443. \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0441\u044f \u043a\u0430\u043a \u0435\u0436\u0435\u043c\u0435\u0441\u044f\u0447\u043d\u044b\u0439 \u0440\u0435\u043f\u043e\u0440\u0442\u0435\u0440 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f \u0431\u0430\u0437\u044b, \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u043b\u0441\u044f \u0432 \u0442\u0430\u0441\u043a \u0448\u0435\u0434\u0430\u043b\u0435\u0440. \u0417\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u043d\u0430 \u0441\u0435\u0440\u0432\u0435\u0440\u0435 exchange. \u041f\u0440\u043e\u0432\u0435\u0440\u044f\u043b\u043e\u0441\u044c \u043d\u0430 Exchange 2010.  <\/p>\n<pre><code>&lt;#      \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u0432\u044b\u0431\u0438\u0440\u0430\u0435\u0442 \u043f\u043e 25 \u0442\u043e\u043f \u043c\u044d\u0439\u043b\u0431\u043e\u043a\u0441\u043e\u0432     \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u0435 \u043e\u0442\u0447\u0435\u0442\u0430 \u043d\u0430 \u0434\u0438\u0441\u043a \u043e\u0442\u043a\u043b\u044e\u0447\u0435\u043d\u043e #&gt;  Param (  [int]$TopCount = 25,         [boolean]$SaveReport = $false,         [string]$ReportPath = 'C:\\Reports\\MailboxReport.html',         [boolean]$SendReport = $true,         [string]$ReportMail1 = 'admin@mail.local'     )  # check snapin present $EX2010 = $false  $snaps = Get-PSSnapin foreach( $snap in $snaps )  {     if ($snap.Name -eq 'Microsoft.Exchange.Management.PowerShell.E2010')   {         $EX2010 = $true     } }  if ($EX2010 -eq $false) {     Add-PSSnapin Microsoft.Exchange.Management.PowerShell.E2010 }  $boxes = Get-Mailbox | Get-MailboxStatistics | sort TotalItemSize -Descending $TotalSize = $boxes | sort TotalItemSize -Descending | select -First $TopCount  # \u0441\u0430\u043c\u044b\u0435 \u0442\u043e\u043b\u0441\u0442\u044b\u0435 \u044f\u0449\u0438\u043a\u0438 $Size = @() foreach ($box in $TotalSize)  {     $propsTotalSize = [ordered]@{   DisplayName=$box.DisplayName                                     User=$box.LastLoggedOnUserAccount                                     Database=$box.Database                                     TotalSize=$box.TotalItemSize                                     ItemCount=$box.ItemCount                                     DeletedItemCount=$box.DeletedItemCount                                     TotalDeletedSize=$box.TotalDeletedItemSize                         }             $obj = New-Object -TypeName PSObject -Property $propsTotalSize             $Size += $obj }  # \u0442\u043e\u043f \u0443\u0434\u0430\u043b\u0435\u043d\u044b\u0445 \u0431\u0435\u0437 purge $Deleted = $boxes | sort TotalDeletedItemSize -Descending | select -First $TopCount $Del = @() foreach ($box in $Deleted)   {     $propsDeleted = [ordered]@{   DisplayName=$box.DisplayName                                   User=$box.LastLoggedOnUserAccount                                   Database=$box.Database                                   TotalSize=$box.TotalItemSize                                   ItemCount=$box.ItemCount                                   DeletedItemCount=$box.DeletedItemCount                                   TotalDeletedSize=$box.TotalDeletedItemSize                         }             $obj = New-Object -TypeName PSObject -Property $propsDeleted             $Del += $obj }  # \u0442\u043e\u043f \u043f\u043e \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0443 \u043f\u0438\u0441\u0435\u043c, \u0441\u043b\u0438\u0448\u043a\u043e\u043c \u043c\u043d\u043e\u0433\u043e \u0438\u043d\u0434\u0438\u043a\u0430\u0442\u043e\u0440 \u0447\u0442\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u0441\u0432\u0430\u043b\u0438\u0432\u0430\u0435\u0442 \u0432\u0441\u0435 \u0432 \u043a\u0443\u0447\u0443 \u0438 \u043d\u0443\u0436\u0434\u0430\u0435\u0442\u0441\u044f \u0432 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u043f\u0440\u0430\u0432\u0438\u043b\u0430\u0445 $Top = $boxes | sort ItemCount -Descending | select -First $TopCount $TopItems = @() foreach ($box in $Top)  {     $propsTopItems = [ordered]@{   DisplayName=$box.DisplayName                                    User=$box.LastLoggedOnUserAccount                                    Database=$box.Database                                    TotalSize=$box.TotalItemSize                                    ItemCount=$box.ItemCount                                    DeletedItemCount=$box.DeletedItemCount<\/code><\/pre>\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-285888","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/285888","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=285888"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/285888\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=285888"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=285888"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=285888"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}