Tuesday, July 12, 2016






The highlighted lines are what I added to the script.
There is a lot of handy information under the public-opstate section of the registry for SEP.

SEPVersionCheckv2-test.ps1

$cred = Get-Credential -Message "User Info" -UserName "wf\$env:USERNAME-a"
#$cred2 = Get-Credential -Message "User Info" -UserName "wesdevdomain\a656673"
$today = Get-Date -UFormat "%Y%m%d_%H%M"
$serverlist = read-host "Location of Server Names"
$servers = Get-Content $serverlist
$HKLM = 2147483650
$SEP = @()
foreach($server in $servers){
$reg = Get-WmiObject -List -Namespace root\default -ComputerName $server -Credential $cred | Where-Object {$_.Name -eq "StdRegProv"}
$properties=@{
    'Server'          = $server ;
    'SEPVersion'      = $reg.GetStringValue($HKLM,"SOFTWARE\Symantec\Symantec Endpoint Protection\CurrentVersion","PRODUCTVERSION").sValue;
    'SEPDEFDate'      = $reg.GetStringValue($HKLM,"SOFTWARE\Symantec\Symantec Endpoint Protection\CurrentVersion\public-opstate","LatestVirusDefsDate").sValue;
    'SEPDEFVersion'   = $reg.GetStringValue($HKLM,"SOFTWARE\Symantec\Symantec Endpoint Protection\CurrentVersion\public-opstate","LatestVirusDefsRevision").sValue;
    }
$output = New-Object -TypeName PSObject -Property $properties
$SEP+=$output
   
}

$SEP | Export-Csv "c:\temp\SEPVersion_$($today).csv"


Friday, April 29, 2016

PS script to find a specific file.

#Read the list of computers
$Servers = Get-Content "$ServerList"

#init some objects
$LineItems = @()
$LineItem = $null

#for loop to call Get-CimFile
foreach($Server in $Servers){
    try{
       $Results = Get-CimFile -Name $FileName -ComputerName $Server -Credential $Credential 
       Foreach($Result in $Results){
               $Properties = @{ 'ComputerName'=$Server;
                                'FileInstance'=$Result.Name;
                                'FileVersion'=$Result.Version;
                               }
               $LineItem = new-object -TypeName PSObject -Property $Properties
               $LineItems+=$LineItem
       }  
    }
    Catch{
       Write-host "  FindAllFileInstances Error: Could not connect to $Server. Check your credentials and Remote Computer availability." -f Red
    }
}


#Write Output to CSV
Foreach($LineItem in $LineItems){
        Foreach($item in $LineItem){
            $Item | Export-Csv $OutputFile -NoTypeInformation -Append
        }
}
Write-Host "$OutputFile created."
________________________________________

Friday, March 11, 2016

TOTT

Windows Commands

Get a list of patches on the machine:
wmic qfe get /format:csv > hotfixes.csv


Friday, March 4, 2016

Powershell


Powershell snippets 
I first used the following to get the list:
Get-Content Computers.txt | ./Get-ScheduledTask.ps1
This gave me the output, using the servers in the Computers.txt file, but not in a CSV format. The following is what I came up with next:
Get-Content Computers.txt | ./Get-ScheduledTask.ps1 | Export-Csv schtask.csv
This gave me the output, using the servers in the Computers.txt file, and it was in a CSV format

Getting the status of all services on this computer:
get-service
Getting a list of running services on this computer:
Get-Service | Where-Object {$_.status -eq "running"}
Getting the status of a specific service:
Get-Service | Where-Object {$_.name -eq "WINS"}
getting the status of a specific service on a remote computer
Get-Service -computername SDRIPS01 | Where-Object {$_.name -eq "WINS"}
Now for a list of servers. this one provides lots of info
get-content servers.txt | % { if ($s=get-service -computer $_ -name WINS -ErrorAction SilentlyContinue) { $s | select * } else {"Service WINS is not avaible on $_"} }
list of servers. this one provides less info
get-content servers.txt | % { if ($s=get-service -computer $_ -name WINS -ErrorAction SilentlyContinue) { $s | select MachineName, ServiceName, Status } else {"Service WINS is not avaible on $_"} }
I wanted to expand my search, but this was too wide
Get-ADComputer -Filter * | Select -Expand Name
I tried this
Get-ADComputer -Filter { OperatingSystem -Like '*Windows Server*' } -Properties OperatingSystem | Select Name, OperatingSystem | Format-Table -AutoSize
But I went with this:
Get-ADComputer -Filter { OperatingSystem -Like '*Windows Server*' } -Properties OperatingSystem | Select -Expand Name
this will get the network info from a number of servers, based on a list.
get-wmiobject -query "Select * FROM Win32_NetworkAdapterConfiguration WHERE IpEnabled='TRUE'" -computer (get-content IPS-Servers.txt) | ft __SERVER,IPAddress,DNSServerSearchOrder,WINSPrimaryServer,WINSSecondaryServer -auto
Hold onto this one, output to csv
get-wmiobject -query "Select * FROM Win32_NetworkAdapterConfiguration WHERE IpEnabled='TRUE'" -computer (get-content TX-Servers-hq.txt) -ErrorAction SilentlyContinue | select-object -Property __SERVER,{$_.IPAddress},{$_.DNSServerSearchOrder},WINSPrimaryServer,WINSSecondaryServer | export-csv tx-hq-dns-wins.txt
this worked pretty well too
####################################################################### # Author : Matthew C. Huntley # Original Source: Chethan Gatty # This PS script provides Network Interface Information from a list of computers. ####################################################################### $names = Get-Content "C:\Users\N900338\powershell\machinelist.txt" @( foreach ($name in $names) { if ( Test-Connection -ComputerName $name -Count 1 -ErrorAction SilentlyContinue ) { $wmi = gwmi -query "Select * FROM Win32_NetworkAdapterConfiguration WHERE IpEnabled='TRUE'" -computer $name | select-object -Property __SERVER,@{n='IPAddress';e={ "$($_.IPAddress)" }}, @{n='DNSServers';e={ "$($_.DnsServerSearchOrder)" }},WINSPrimaryServer,WINSSecondaryServer Write-output "$name, $wmi " } else { Write-output "$name is not pinging" } } ) | Out-file -FilePath "C:\Users\N900338\powershell\GetNetworkInfo-results.txt"
this was derived from:
####################################################################### # Author : Chethan Gatty # This PS script provides Uptime and Pingstatus for list of computers. ####################################################################### $names = Get-Content "C:\Users\N900338\powershell\machinelist.txt" @( foreach ($name in $names) { if ( Test-Connection -ComputerName $name -Count 1 -ErrorAction SilentlyContinue ) { $wmi = gwmi -class Win32_OperatingSystem -computer $name $LBTime = $wmi.ConvertToDateTime($wmi.Lastbootuptime) [TimeSpan]$uptime = New-TimeSpan $LBTime $(get-date) Write-output "$name Uptime is $($uptime.days) Days $($uptime.hours) Hours $($uptime.minutes) Minutes $($uptime.seconds) Seconds" } else { Write-output "$name is not pinging" } } ) | Out-file -FilePath "C:\Users\N900338\powershell\results.txt"



Tracking AV Versions:
Interesting articles
Ok, trying another tack at this:
Get a list of all the servers:
Get-ADComputer -Filter {OperatingSystem -Like "Windows Server*"} -Property * | Format-Table Name,OperatingSystem,OperatingSystemServicePack -Wrap -Auto

Get the list of network profiles on the system.
Get-NetConnectionProfile Change the network interface to private, use the network interface index number from the previous command.
Set-NetConnectionProfile -InterfaceIndex 10 -NetworkCategory Private

Tuesday, March 1, 2016

Windows Commands

NET STATISTICS SERVER
shows servers last reboot!

Tuesday, February 16, 2016

TOTT

TOTT
Tools of the Trade

I will be maintaining some notes up here, which are my tools of the trade. Stuff I want to keep, and do not mind sharing.