Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Create the function to test if a registry key exists
- function Test-RegKey {
- param (
- $ComputerName = $env:COMPUTERNAME,
- $Hive = 'LocalMachine',
- $Key
- )
- try {
- $regKey = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey($Hive, $ComputerName)
- $ref = $regKey.OpenSubKey($Key)
- if (!$ref) {
- $false
- } else {
- $true
- }
- } catch {
- $null
- }
- }
- # gotta get your computers from somewhere, right?
- #$computers = ipcsv c:\temp\listofcomputers.csv
- # or we'll just use this for test purposes
- $computers = [pscustomobject]@{
- Name = $env:COMPUTERNAME
- }
- $results = $computers | % {
- $ping = New-Object System.Net.NetworkInformation.Ping
- $total = $computers.Count
- $starttime = $lasttime = Get-Date
- $index = 0
- } {
- $index++
- $currtime = (Get-Date) - $starttime
- $avg = $currtime.TotalSeconds / $index
- $last = ((Get-Date) - $lasttime).TotalSeconds
- $left = $total - $index
- Write-Progress `
- -Activity ((
- "Check for OfficeScan $(Get-Date -f yyyy-MM-dd_HH:mm:ss)",
- "Total: $($currtime -replace '\..*')",
- "Avg: $('{0:N2}' -f $avg)",
- "Last: $('{0:N2}' -f $last)",
- "ETA: $('{0:N2}' -f (($avg * $left) / 60))",
- "min ($([string](Get-Date).AddSeconds($avg*$left) -replace '^.* '))"
- ) -join ' ') `
- -Status "$index of $total ($left left) [$('{0:N2}' -f (($index/$total)*100))%]" `
- -CurrentOperation "COMP: $($_.Name)" `
- -PercentComplete (($index/$total)*100)
- $lasttime = Get-Date
- $pingresult = try{ $ping.Send($_.Name, 750) }catch{}
- if ($pingresult.Status -eq 'Success') {
- $resultx86 = Test-RegKey -ComputerName $_.Name -Key 'SOFTWARE\TrendMicro\PC-cillinNTCorp\CurrentVersion\HotfixHistory\11.0\CP_4150'
- $resultx64 = Test-RegKey -ComputerName $_.Name -Key 'SOFTWARE\Wow6432Node\TrendMicro\PC-cillinNTCorp\CurrentVersion\HotfixHistory\11.0\CP_4150'
- } else {
- $resultx86 = $resultx64 = 'Offline'
- }
- [pscustomobject]@{
- ComputerName = $_.Name
- HasOfficeScanx86 = $resultx86
- HasOfficeScanx64 = $resultx64
- }
- }
- $results
- $results | epcsv c:\temp\results.csv -not
Advertisement
Add Comment
Please, Sign In to add comment