# Аудит локальной системы (сбор информации) # Опрос системы на установленное ПО, аппаратную конфигурацию, наличие обновлений, сетевую конфигурацию и пр. #version: 0.3beta $hm=hostname $spath=split-path -parent $MyInvocation.MyCommand.Definition $mpath="$spath\report" $dt=Get-Date -f yyyy.MM.dd $dtf=Get-Date -f yyyy-MM-dd-HH-mm $mfile=$hm+"_"+$dtf+".txt" write-host "Checking service path..." if (test-path $mpath) {write-host "Service path exists."} else {md $mpath;write-host "Service path created."} write-host "Write headers." Write-Output "Inv date: $dt" | Out-File $mpath\$mfile Write-Output "---------------------------------" | Out-File $mpath\$mfile -Append Write-Output "" | Out-File $mpath\$mfile -Append Write-Output "Step: IPCONFIG /ALL" | Out-File $mpath\$mfile -Append Write-Host "Step: IPCONFIG /ALL" ipconfig /all | Out-File $mpath\$mfile -Append Write-Output "---------------------------------" | Out-File $mpath\$mfile -Append Write-Output "" | Out-File $mpath\$mfile -Append Write-Output "Step: ROUTE PRINT" | Out-File $mpath\$mfile -Append Write-Host "Step: ROUTE PRINT" route print | Out-File $mpath\$mfile -Append Write-Output "---------------------------------" | Out-File $mpath\$mfile -Append Write-Output "" | Out-File $mpath\$mfile -Append Write-Output "Step: SYSTEMINFO" | Out-File $mpath\$mfile -Append Write-Host "Step: SYSTEMINFO" systeminfo | Out-File $mpath\$mfile -Append Write-Output "---------------------------------" | Out-File $mpath\$mfile -Append Write-Output "" | Out-File $mpath\$mfile -Append Write-Output "Step: NETSTAT -A" | Out-File $mpath\$mfile -Append Write-Host "Step: NETSTAT -A" netstat -a | Out-File $mpath\$mfile -Append Write-Output "---------------------------------" | Out-File $mpath\$mfile -Append Write-Output "" | Out-File $mpath\$mfile -Append Write-Output "Step: ARP -A" | Out-File $mpath\$mfile -Append Write-Host "Step: ARP -A" arp -a | Out-File $mpath\$mfile -Append Write-Output "---------------------------------" | Out-File $mpath\$mfile -Append Write-Output "" | Out-File $mpath\$mfile -Append Write-Output "Step: NET USE" | Out-File $mpath\$mfile -Append Write-Host "Step: NET USE" net use | Out-File $mpath\$mfile -Append Write-Output "---------------------------------" | Out-File $mpath\$mfile -Append Write-Output "" | Out-File $mpath\$mfile -Append Write-Output "Step: NETSH ADVFIREWALL FIREWALL SHOW RULE ALL" | Out-File $mpath\$mfile -Append Write-Host "Step: NETSH ADVFIREWALL FIREWALL SHOW RULE ALL" netsh advfirewall firewall show rule all | Out-File $mpath\$mfile -Append Write-Output "---------------------------------" | Out-File $mpath\$mfile -Append Write-Output "" | Out-File $mpath\$mfile -Append Write-Output "Step: NET LOCALGROUP" | Out-File $mpath\$mfile -Append Write-Host "Step: NET LOCALGROUP" net localgroup | Out-File $mpath\$mfile -Append Write-Output "---------------------------------" | Out-File $mpath\$mfile -Append Write-Output "" | Out-File $mpath\$mfile -Append Write-Output "Step: NET USER" | Out-File $mpath\$mfile -Append Write-Host "Step: NET USER" net user | Out-File $mpath\$mfile -Append Write-Output "---------------------------------" | Out-File $mpath\$mfile -Append Write-Output "" | Out-File $mpath\$mfile -Append Write-Output "Step: Test-Connection ipatron.ru -Count 10 -BufferSize 1024" | Out-File $mpath\$mfile -Append Write-Host "Step: Test-Connection ipatron.ru -Count 10 -BufferSize 1024" Test-Connection ipatron.ru -Count 10 -BufferSize 1024 | Out-File $mpath\$mfile -Append Write-Output "---------------------------------" | Out-File $mpath\$mfile -Append Write-Output "" | Out-File $mpath\$mfile -Append Write-Host "Copy cygwin1.dll to Windows dir." Copy-Item $spath\cygwin1.dll $env:windir Write-Host "Register library cygwin1.dll." regsvr32 cygwin1.dll -silentcontinue Write-Output "Step: IPERF3 -p 65001 -c l2tp.mcprombez.ru -i 10 -t 60" | Out-File $mpath\$mfile -Append Write-Host "Step: IPERF3 -p 65001 -c l2tp.mcprombez.ru -i 10 -t 60" & "$spath\iperf3.exe" -p 65001 -c l2tp.mcprombez.ru -i 10 -t 60 | Out-File $mpath\$mfile -Append Write-Output "---------------------------------" | Out-File $mpath\$mfile -Append Write-Output "" | Out-File $mpath\$mfile -Append Write-Output "Step: DISKS DATA" | Out-File $mpath\$mfile -Append Write-Host "Get local disks." $ld=Get-WMIObject -Class Win32_logicaldisk -Filter "DriveType=3" | Select-Object DeviceID $ld=$ld.DeviceID Write-Host "Get disks data." Foreach ($dl in $ld) { $colItems = (Get-ChildItem $dl\ -force -ErrorAction SilentlyContinue | Where-Object {$_.PSIsContainer -eq $True} | Sort-Object) foreach ($i in $colItems) { $subFolderItems = (Get-ChildItem $i.FullName -force -recurse -ErrorAction SilentlyContinue | Measure-Object -property length -sum -ErrorAction SilentlyContinue) $i.FullName + " -- " + "{0:N2}" -f ($subFolderItems.sum / 1MB) + " MB" | Out-File $mpath\$mfile -Append if ($i.Name -match "Users") { $colIUtems = (Get-ChildItem $i -force -ErrorAction SilentlyContinue | Where-Object {$_.PSIsContainer -eq $True} | Sort-Object) foreach ($iu in $colIUtems) { $subFolderIUtems = (Get-ChildItem $iu.FullName -force -recurse -ErrorAction SilentlyContinue | Measure-Object -property length -sum -ErrorAction SilentlyContinue) $iu.FullName + " -- " + "{0:N2}" -f ($subFolderIUtems.sum / 1MB) + " MB" | Out-File $mpath\$mfile -Append } } } } Write-Output "---------------------------------" | Out-File $mpath\$mfile -Append Write-Output "" | Out-File $mpath\$mfile -Append Write-Output "Step: Get-Disk | Get-StorageReliabilityCounter (DISK HEALTH)" | Out-File $mpath\$mfile -Append Write-Host "Step: Get-Disk | Get-StorageReliabilityCounter (DISK HEALTH)" Get-Disk | Get-StorageReliabilityCounter | Out-File $mpath\$mfile -Append