├── EventLogReport
├── reportsample.png
├── Readme.md
└── GetEventLogReport.ps1
├── WinCollect7
└── WinCollectAgentReInstall
│ ├── setpolicy.png
│ ├── unblockfile.png
│ ├── readme.md
│ └── ReInstallWinCollect.ps1
├── WinCollect10
├── Agent Install Templates
│ ├── mTLS
│ │ ├── update_mTLSPrivateKeyPassphrase.xml
│ │ └── update_mTLSClientCertificate.xml
│ ├── QuickInstall
│ │ └── update_QuickInstall.xml
│ ├── Microsoft_Windows_Event_Log
│ │ ├── update_StandardEventLogs_SecurityInclusionFilter.xml
│ │ ├── update_StandardEventLogs_ForwardedEvents.xml
│ │ ├── update_StandardEventLogs_Event5156WinCollect.xml
│ │ ├── update_StandardEventLogs_SecurityExclusionFilter.xml
│ │ ├── update_StandardEventLogs_DirectoryService_DNS_Server.xml
│ │ ├── update_StandardEventLogs_Sysmon.xml
│ │ └── update_StandardEventLogs_SecurityNSAFilter.xml
│ ├── Microsoft_IIS
│ │ └── update_MicrosoftIIS_StandardEventLogs.xml
│ ├── Microsoft_DHCP
│ │ └── update_MicrosoftDHCP_StandardEventLogs.xml
│ ├── Microsoft_Forefront_TMG
│ │ └── update_MicrosoftForefrontTMG_StandardEventLogs.xml
│ ├── Microsoft_NPS
│ │ └── update_MicrosoftNPS_StandardEventLogs.xml
│ ├── Microsoft_SQL_Server
│ │ └── update_MicrosoftSQLServer_StandardEventLogs.xml
│ ├── Microsoft_DNS_Debug
│ │ └── update_MicrosoftDNSDebug_StandardEventLogs.xml
│ ├── IBM_File_Forwarder
│ │ ├── update_FileForwarderContinuous_StandardEventLogs.xml
│ │ └── update_FileForwarderFileDrop_StandardEventLogs.xml
│ ├── TLS
│ │ └── update_AgentwithTLSSyslog.xml
│ ├── Microsoft_Exchange_Server
│ │ └── update_MicrosoftExchangeServer_StandardEventLogs.xml
│ └── readme.md
└── Powershell Scripts
│ ├── AgentInstallation
│ ├── InstallWC10Agent.ps1
│ └── readme.md
│ ├── AgentManagement
│ ├── SetClientCertThumbprint.ps1
│ ├── MassAgentUpdate.ps1
│ └── readme.md
│ └── ViewRestrictedGroups
│ ├── readme.md
│ └── CheckRestrictedGroups.ps1
├── readme.md
└── LICENSE
/EventLogReport/reportsample.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/IBM/wincollect/HEAD/EventLogReport/reportsample.png
--------------------------------------------------------------------------------
/WinCollect7/WinCollectAgentReInstall/setpolicy.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/IBM/wincollect/HEAD/WinCollect7/WinCollectAgentReInstall/setpolicy.png
--------------------------------------------------------------------------------
/WinCollect7/WinCollectAgentReInstall/unblockfile.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/IBM/wincollect/HEAD/WinCollect7/WinCollectAgentReInstall/unblockfile.png
--------------------------------------------------------------------------------
/WinCollect10/Agent Install Templates/mTLS/update_mTLSPrivateKeyPassphrase.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/WinCollect10/Powershell Scripts/AgentInstallation/InstallWC10Agent.ps1:
--------------------------------------------------------------------------------
1 |
2 | $file = '\\yournetworkshare\wincollect\10\wincollect-10.0.1-276.x64.msi'
3 | $computerName = 'yourtargetendpoint'
4 |
5 |
6 | $session = New-PSSession -ComputerName $computerName
7 | Copy-Item -Path $file -ToSession $session -Destination c:\windows\temp\wincollect-10.0.1-276.x64.msi
8 |
9 | Invoke-Command -Session $session -ScriptBlock {
10 | Start-Process msiexec.exe -Wait -ArgumentList '/i C:\Windows\Temp\wincollect-10.0.1-276.x64.msi QUICK_INSTALL="yes" WC_DEST="172.18.233.102" ADMIN_GROUP="true"'
11 | }
12 | Remove-PSSession $session
13 |
--------------------------------------------------------------------------------
/WinCollect10/Agent Install Templates/mTLS/update_mTLSClientCertificate.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/WinCollect10/Powershell Scripts/AgentManagement/SetClientCertThumbprint.ps1:
--------------------------------------------------------------------------------
1 | #Checks the "My" (or "Personal") certificate store of the local machine for a certificate issued to this machine
2 | param
3 | (
4 | [string]$hostname = $env:computername
5 | )
6 |
7 | Write-Output "Searching for certificate issued to '$hostname' in LocalMachine certificate store 'Personal'"
8 | [Environment]::SetEnvironmentVariable(
9 | 'WC_CLIENT_CERT_THUMBPRINT',
10 | (Get-ChildItem -Path cert:\LocalMachine\My |
11 | Where-Object Subject -Like "*CN=$hostname*" |
12 | Select-Object -First 1).Thumbprint,
13 | 'Machine')
14 |
--------------------------------------------------------------------------------
/WinCollect10/Powershell Scripts/AgentManagement/MassAgentUpdate.ps1:
--------------------------------------------------------------------------------
1 | # This file contains the list of servers you want to copy files/folders to
2 | $computers = gc "C:\WCAgents\Agents.txt"
3 |
4 | # This is the file/folder(s) you want to copy to the servers in the $computer variable
5 | $source = "C:\WCAgents\update_AddSecondaryDestination.xml"
6 |
7 | # The destination location you want the file/folder(s) to be copied to
8 | $destination = "c$\Program Files\IBM\WinCollect\patch\"
9 |
10 | foreach ($computer in $computers) {
11 | if ((Test-Path -Path \\$computer\$destination)) {
12 | Copy-Item $source -Destination \\$computer\$destination -Recurse
13 | } else {
14 | "\\$computer\$destination is not reachable or does not exist"
15 | }
16 | }
--------------------------------------------------------------------------------
/WinCollect10/Powershell Scripts/ViewRestrictedGroups/readme.md:
--------------------------------------------------------------------------------
1 | # Installation Scripts
2 |
3 | The installation scripts are intended for WinCollect 10 only.
4 |
5 | ## Purpose of CheckRestrictedGroups.ps1
6 |
7 | This powershell script can be used to check if Administrators and Event Log Readers groups are part of Restricted Accounts/Groups on domain controller.
8 |
9 | ## Author Team WinCollect
10 |
11 | ## Copyright (c) 2021 IBM
12 | Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
13 |
--------------------------------------------------------------------------------
/WinCollect10/Agent Install Templates/QuickInstall/update_QuickInstall.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/WinCollect10/Agent Install Templates/Microsoft_Windows_Event_Log/update_StandardEventLogs_SecurityInclusionFilter.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/WinCollect7/WinCollectAgentReInstall/readme.md:
--------------------------------------------------------------------------------
1 | # ReinstallWinCollect.ps1
2 |
3 | **NOTE:**
4 | The ReinstallWinCollect.ps1 PowerShell utility is no longer needed with the release of 7.3.0 Patch 1 (7.3.0-41).
5 | Uninstalling the Agent and then installing a fresh copy is not longer necessary. The new installer will upgrade your Agent in place. You can perform an upgrade one of two ways
6 |
7 | **GUI Installation**
8 | When you run the executable the UI will prompt if you would like to "Perform and upgrade of WinCollect", when you click "Yes", the agent will be upgraded in place.
9 |
10 | **Cmd Line Installation**
11 | Run the following cmd, which will upgrade the Agent.
12 | **wincollect-7.3.0-41.x64.exe /S /v/qn**
13 |
14 |
15 |
16 |
17 | ## Author
18 | Jamie Wheaton
19 |
20 |
21 | ## Copyright (c) 2020 IBM
22 |
23 | Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
--------------------------------------------------------------------------------
/WinCollect10/Agent Install Templates/Microsoft_Windows_Event_Log/update_StandardEventLogs_ForwardedEvents.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/WinCollect10/Agent Install Templates/Microsoft_Windows_Event_Log/update_StandardEventLogs_Event5156WinCollect.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/WinCollect10/Agent Install Templates/Microsoft_Windows_Event_Log/update_StandardEventLogs_SecurityExclusionFilter.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/WinCollect10/Agent Install Templates/Microsoft_Windows_Event_Log/update_StandardEventLogs_DirectoryService_DNS_Server.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/WinCollect10/Agent Install Templates/Microsoft_IIS/update_MicrosoftIIS_StandardEventLogs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/WinCollect10/Agent Install Templates/Microsoft_DHCP/update_MicrosoftDHCP_StandardEventLogs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/WinCollect10/Agent Install Templates/Microsoft_Forefront_TMG/update_MicrosoftForefrontTMG_StandardEventLogs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/WinCollect10/Agent Install Templates/Microsoft_NPS/update_MicrosoftNPS_StandardEventLogs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/WinCollect10/Powershell Scripts/ViewRestrictedGroups/CheckRestrictedGroups.ps1:
--------------------------------------------------------------------------------
1 | try
2 | {
3 | Write-Host "Getting restricted groups"
4 | $tempFile = "C:\GroupPolicyResult.txt"
5 | Gpresult /V /scope Computer > $tempFile
6 | if (Test-Path -Path $tempFile)
7 | {
8 | $Start = Select-String $tempFile -pattern "Restricted" | Select-Object LineNumber
9 | $End = Select-String $tempFile -pattern "System Services" | Select-Object LineNumber
10 | for($i = $Start.LineNumber; $i -lt $End.LineNumber; $i += 1)
11 | {
12 | $temp += Get-Content -Path $tempFile | Select-Object -Index $i
13 | }
14 | Remove-Item -Path $tempFile -Force
15 | if (($temp -clike "*Groupname: Administrators*") -and ($temp -clike "*Groupname: Event Log Readers*"))
16 | {
17 | Write-Host "Administrators and Event Log Readers groups are part of restricted groups. So the agent may not have been installed correctly"
18 | }
19 | else {
20 | Write-Host "Administrators and Event Log Readers groups are not part of restricted groups"
21 | }
22 | }
23 | }
24 | catch {
25 | Write-Error "Error finding restricted groups"
26 | }
27 |
28 | Write-Host "GroupPolicy.ps1 is finished"
--------------------------------------------------------------------------------
/WinCollect10/Agent Install Templates/Microsoft_SQL_Server/update_MicrosoftSQLServer_StandardEventLogs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/WinCollect10/Agent Install Templates/Microsoft_DNS_Debug/update_MicrosoftDNSDebug_StandardEventLogs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/WinCollect10/Agent Install Templates/IBM_File_Forwarder/update_FileForwarderContinuous_StandardEventLogs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/WinCollect10/Agent Install Templates/TLS/update_AgentwithTLSSyslog.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 | "Insert your Certificate blob here"
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/WinCollect10/Agent Install Templates/IBM_File_Forwarder/update_FileForwarderFileDrop_StandardEventLogs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/WinCollect10/Agent Install Templates/Microsoft_Windows_Event_Log/update_StandardEventLogs_Sysmon.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
--------------------------------------------------------------------------------
/WinCollect10/Agent Install Templates/Microsoft_Exchange_Server/update_MicrosoftExchangeServer_StandardEventLogs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
--------------------------------------------------------------------------------
/WinCollect10/Agent Install Templates/Microsoft_Windows_Event_Log/update_StandardEventLogs_SecurityNSAFilter.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 | 1100,1102,4624,4625,4634,4648,4657,4672,4688,4689,4704,4706,4713,4714,4716,4719,4720,4722,4725,4726,4728,4731,4732,4733,4735,4740,4756,4765,4766,4767,4769,4776,4778,4779,4781,4782,4793,4870,4873,4874,4880,4881,4882,4885,4886,4887,4888,4890,4891,4892,4896,4897,4898,4899,4900,5038,5136,5137,5138,5139,5140,5141,5142,5144,5145,5376,5377,5632,6272,6273,6274,6275,6276,6277,6278,6279,6280,6281
23 |
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/readme.md:
--------------------------------------------------------------------------------
1 | This repository contains samples of scripts and tools that administrators can use to assist with Windows event collection. All Powershell samples and scripts are for reference or educational use. These samples are provided on an "as is" basis and are without warranties of any kind.
2 |
3 | We encourage administrators to examine these scripts before running them or test these tools in a lab environment before making use of them in the production network.
4 |
5 | Any issues discovered using the samples should not be directed to QRadar support, but be reported on the Github issue tracker.
6 |
7 | # WinCollect 10
8 | ### Agent Install Templates
9 | These installation templates can be used as part of the WinCollect 10 command line install to configure any of the sources during installation. This will allow you to configure say Windows Event logs as well as IIS as part of the Agent installation.
10 |
11 | ### Install Powershell Scripts
12 | Agent Installation and Update Powershell scripts
13 |
14 | # WinCollect 7
15 | ### WinCollect Agent Reinstall
16 | The ReInstallWinCollect.ps1 PowerShell utility is intended to assist administrators with upgrades to Wincollect V7.3.0 on Windows hosts. The attached utility automates the install process to copy existing installation values and reinstall agents using the WinCollect V7.3.0 EXE for administrators who have large deployments of WinCollect agents.
17 |
18 | # Get Event Log Reports
19 | This Powershell script allows administrators to create EPS reports for local or remote Windows systems by polling the data from the Windows Event Viewer. The script advises the administrator on the best method of event collection, based on the returned EPS rate.
20 |
--------------------------------------------------------------------------------
/WinCollect10/Powershell Scripts/AgentManagement/readme.md:
--------------------------------------------------------------------------------
1 | # Installation Scripts
2 |
3 | The installation scripts are intended for WinCollect 10 only.
4 |
5 | ## Purpose of MassAgentUpdate.ps1
6 |
7 | This powershell script can be used to change the agent configuration on multiple agents at a time.
8 |
9 | ## Parameters
10 |
11 | The $computers parameter is used to specify a file that has a list of machines in a .txt file.
12 |
13 | The $source parameter is used to specify the "update_" script you want to use to change on your agents.
14 |
15 | The $destination parameter is used to specify where to drop the "update_" script to change the configuration for your agents. The default location is used here, but if you installed your agent in a different location make sure this is changed accordingly.
16 |
17 | ## Purpose of SetClientCertThumbprint.ps1
18 |
19 | This powershell script can be used to search the local machine's Windows certificate stores for a client certificate and store that certificate's thumbprint as an environment variable. This environment variable can be used in update scripts (WinCollect10/Agent Install Templates/mTLS/update_mTLSClientCertificate.xml) to update destinations to use the certificate.
20 |
21 | ## Parameters
22 |
23 | The $hostname parameter is used to specify the hostname that the certificate was issued to. The default value for this is the name of the computer the script is running from.
24 |
25 | ## Author Team WinCollect
26 |
27 | ## Copyright (c) 2021 IBM
28 | Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
29 |
--------------------------------------------------------------------------------
/WinCollect10/Powershell Scripts/AgentInstallation/readme.md:
--------------------------------------------------------------------------------
1 | # Installation Scripts
2 |
3 | The installation scripts are intended for WinCollect 10 only.
4 |
5 | # Purpose of InstallWC10Agent.ps1
6 |
7 | This powershell script can be used to install WinCollect 10 on a target endpoint from a remote share. The script will start a PSSession and then copy over the installation file to the temp directory of the target machine and then run the installer. The installer will run the "Quick" install method that just captures the Security, Application and System event channels from the target machine and will then send them to the desire destination configured using the "WC_DEST" parameter
8 |
9 | # Parameters
10 |
11 | The $file parameter is used to specify the path to where the WinCollect 10 agent MSI file is located.
12 | The $computerName parameter is used to specify the target endpoint where you want to install the agent.
13 |
14 | The WC_DEST parameter is use to specify the QRadar appliance you want to send the events to.
15 |
16 | The ADMIN_GROUP command line parameter is required on systems that are not a domain controller. This command line parameter must be specified with either a true or false value. A value of true adds the WinCollect virtual account to the Administrators group, whereas a value of false does not. This parameter can be omitted when WinCollect 10 is being installed on a domain controller.
17 |
18 | If upgrading to version 10.1.7 or above, instead of using the virual account and ADMIN_GROUP parameter, you can alternatively specify an account for the service to run as using the ACCOUNT_NAME parameter. The value will be the name of the existing account to use.
19 |
20 | ## Author Team WinCollect
21 |
22 | ## Copyright (c) 2023 IBM
23 | Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
24 |
--------------------------------------------------------------------------------
/WinCollect10/Agent Install Templates/readme.md:
--------------------------------------------------------------------------------
1 | # Installation Templates
2 |
3 | The installation templates are intended for WinCollect 10 only.
4 |
5 | We have included serveral template examples to show how to use an XML formatted document (template) as part of a command-line install. The templates cover all the different "sources" supported by WinCollect. This replaces the paragraph install command of WinCollect 7 which only supported Windows Events.
6 |
7 | ## Installation cmd
8 |
9 | The installation command will need the WC_SCRIPT parameter which includes the path to the installation template.
10 |
11 |
12 |
13 | msiexec.exe /q /i wincollect-10.x.x-xxx.x64.msi WC_SCRIPT="c:\wincollectinstall\update_.xml"
14 |
15 | - All templates used as part of the WinCollect install must start with "update_" and be in XML format. Examples to follow.
16 | - Replace in your scripts with the actual Hostname or IP of your QRadar server
17 |
18 | # Setting Parameters in Templates
19 |
20 | You will see the following three different formats for setting parameters in the update XML.
21 |
22 | The easiest way to see how different settings are used is to make changes in the console UI and then review the update AgentConfig.xml
23 |
24 |
25 |
26 | ## Inline parameter
27 |
28 |
29 |
30 |
31 |
32 | ### Child parameter
33 |
34 |
35 |
36 |
37 |
38 | ### Expanded child parameter
39 |
40 | This is a good way to represent text that might be quite large or odd formatting such as an Xpath
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 | ## Author Team WinCollect
58 |
59 | ## Copyright (c) 2021 IBM
60 | Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
61 |
--------------------------------------------------------------------------------
/EventLogReport/Readme.md:
--------------------------------------------------------------------------------
1 |
2 | 
3 | Example Report
4 |
5 | ABOUT
6 | =====
7 |
8 | The Get Event Log Report script allows administrators to chart the EPS rate of a local or remote Windows host based by polling the Event Log. The PowerShell script must be run as an administrator and is capable of creating EPS rate reports for local, remote, or all Windows hosts within the domain where the script is run.
9 |
10 |
11 | REQUIREMENTS
12 | ===========
13 | - PowerShell v3.0 or v4.0 is required. For more information on PowerShell or downloads, see the following website:
14 | - PowerShell must be run as local admin & users must run **Set-ExecutionPolicy RemoteSigned** to use this script.
15 | - To use option 3 for domain scans, Powershell domain cmdlets must be installed.
16 | - This script can be run on any Windows host at Windows XP or above.
17 | - For Windows 2003 Server and Windows XP, remote EPS data collection uses WMI to remotely read the Windows Event Log. If there are network firewalls between Windows hosts, then standard WMI ports might need to be opened to prevent connection error messages.
18 |
19 |
20 | DETAILED DESCRIPTION
21 | ===========
22 |
23 | This Powershell script includes three options for data collection:
24 | - **Local Host**: Scan the event log(s) of the local host to create a report of the Events Per Second (EPS) rate.
25 | - **IP List**: Scan a list of IP addresses provided by the user. The remote systems are scanned and a report is created for each IP address.
26 | - **Domain**: Scan the local domain where the script is run to create an EPS rate report for all of the Windows hosts within the domain. Powershell domain cmdlets must be installed to use this option.
27 |
28 | Instructions
29 | ===========
30 | 1. Download the Powershell script.
31 | 2. Copy the script to a Windows host.
32 | 3. Launch Microsoft Powershell as an administrator.
33 | 4. Type **Set-ExecutionPolicy RemoteSigned**.
34 | 5. If prompted to update the policy, select **Yes**.
35 | - For more information on Set-ExecutionPolicy, see
36 | 4. Open GetEventLogReports.ps1 in Powershell.
37 | 5. Run the GetEventLogReports.ps1 script.
38 | 6. Select one of the following options:
39 | - **Local Host**
40 | -- Creates a CSV file of EPS rate data for the local host.
41 | - **IP List**
42 | -- Creates a CSV report for the list of IP addresses specified.
43 | - **Domain**
44 | -- The script must be run within the Domain specified.
45 | 7. Follow the on-screen prompts to create the EPS report.
46 | 8. Select a location to save the report data.
47 | 9. A summary details an success or error messages and the location of the report.
48 |
49 |
50 |
51 | Author information
52 | ===========
53 | Authors: Jamie Wheaton & William Delong
54 |
55 |
56 | LICENSE
57 | ===========
58 | Copyright (c) 2015 IBM
59 |
60 | Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
61 | See the License for the specific language governing permissions and limitations under the License.
62 |
63 |
64 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Apache License
2 | Version 2.0, January 2004
3 | http://www.apache.org/licenses/
4 |
5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6 |
7 | 1. Definitions.
8 |
9 | "License" shall mean the terms and conditions for use, reproduction,
10 | and distribution as defined by Sections 1 through 9 of this document.
11 |
12 | "Licensor" shall mean the copyright owner or entity authorized by
13 | the copyright owner that is granting the License.
14 |
15 | "Legal Entity" shall mean the union of the acting entity and all
16 | other entities that control, are controlled by, or are under common
17 | control with that entity. For the purposes of this definition,
18 | "control" means (i) the power, direct or indirect, to cause the
19 | direction or management of such entity, whether by contract or
20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the
21 | outstanding shares, or (iii) beneficial ownership of such entity.
22 |
23 | "You" (or "Your") shall mean an individual or Legal Entity
24 | exercising permissions granted by this License.
25 |
26 | "Source" form shall mean the preferred form for making modifications,
27 | including but not limited to software source code, documentation
28 | source, and configuration files.
29 |
30 | "Object" form shall mean any form resulting from mechanical
31 | transformation or translation of a Source form, including but
32 | not limited to compiled object code, generated documentation,
33 | and conversions to other media types.
34 |
35 | "Work" shall mean the work of authorship, whether in Source or
36 | Object form, made available under the License, as indicated by a
37 | copyright notice that is included in or attached to the work
38 | (an example is provided in the Appendix below).
39 |
40 | "Derivative Works" shall mean any work, whether in Source or Object
41 | form, that is based on (or derived from) the Work and for which the
42 | editorial revisions, annotations, elaborations, or other modifications
43 | represent, as a whole, an original work of authorship. For the purposes
44 | of this License, Derivative Works shall not include works that remain
45 | separable from, or merely link (or bind by name) to the interfaces of,
46 | the Work and Derivative Works thereof.
47 |
48 | "Contribution" shall mean any work of authorship, including
49 | the original version of the Work and any modifications or additions
50 | to that Work or Derivative Works thereof, that is intentionally
51 | submitted to Licensor for inclusion in the Work by the copyright owner
52 | or by an individual or Legal Entity authorized to submit on behalf of
53 | the copyright owner. For the purposes of this definition, "submitted"
54 | means any form of electronic, verbal, or written communication sent
55 | to the Licensor or its representatives, including but not limited to
56 | communication on electronic mailing lists, source code control systems,
57 | and issue tracking systems that are managed by, or on behalf of, the
58 | Licensor for the purpose of discussing and improving the Work, but
59 | excluding communication that is conspicuously marked or otherwise
60 | designated in writing by the copyright owner as "Not a Contribution."
61 |
62 | "Contributor" shall mean Licensor and any individual or Legal Entity
63 | on behalf of whom a Contribution has been received by Licensor and
64 | subsequently incorporated within the Work.
65 |
66 | 2. Grant of Copyright License. Subject to the terms and conditions of
67 | this License, each Contributor hereby grants to You a perpetual,
68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69 | copyright license to reproduce, prepare Derivative Works of,
70 | publicly display, publicly perform, sublicense, and distribute the
71 | Work and such Derivative Works in Source or Object form.
72 |
73 | 3. Grant of Patent License. Subject to the terms and conditions of
74 | this License, each Contributor hereby grants to You a perpetual,
75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76 | (except as stated in this section) patent license to make, have made,
77 | use, offer to sell, sell, import, and otherwise transfer the Work,
78 | where such license applies only to those patent claims licensable
79 | by such Contributor that are necessarily infringed by their
80 | Contribution(s) alone or by combination of their Contribution(s)
81 | with the Work to which such Contribution(s) was submitted. If You
82 | institute patent litigation against any entity (including a
83 | cross-claim or counterclaim in a lawsuit) alleging that the Work
84 | or a Contribution incorporated within the Work constitutes direct
85 | or contributory patent infringement, then any patent licenses
86 | granted to You under this License for that Work shall terminate
87 | as of the date such litigation is filed.
88 |
89 | 4. Redistribution. You may reproduce and distribute copies of the
90 | Work or Derivative Works thereof in any medium, with or without
91 | modifications, and in Source or Object form, provided that You
92 | meet the following conditions:
93 |
94 | (a) You must give any other recipients of the Work or
95 | Derivative Works a copy of this License; and
96 |
97 | (b) You must cause any modified files to carry prominent notices
98 | stating that You changed the files; and
99 |
100 | (c) You must retain, in the Source form of any Derivative Works
101 | that You distribute, all copyright, patent, trademark, and
102 | attribution notices from the Source form of the Work,
103 | excluding those notices that do not pertain to any part of
104 | the Derivative Works; and
105 |
106 | (d) If the Work includes a "NOTICE" text file as part of its
107 | distribution, then any Derivative Works that You distribute must
108 | include a readable copy of the attribution notices contained
109 | within such NOTICE file, excluding those notices that do not
110 | pertain to any part of the Derivative Works, in at least one
111 | of the following places: within a NOTICE text file distributed
112 | as part of the Derivative Works; within the Source form or
113 | documentation, if provided along with the Derivative Works; or,
114 | within a display generated by the Derivative Works, if and
115 | wherever such third-party notices normally appear. The contents
116 | of the NOTICE file are for informational purposes only and
117 | do not modify the License. You may add Your own attribution
118 | notices within Derivative Works that You distribute, alongside
119 | or as an addendum to the NOTICE text from the Work, provided
120 | that such additional attribution notices cannot be construed
121 | as modifying the License.
122 |
123 | You may add Your own copyright statement to Your modifications and
124 | may provide additional or different license terms and conditions
125 | for use, reproduction, or distribution of Your modifications, or
126 | for any such Derivative Works as a whole, provided Your use,
127 | reproduction, and distribution of the Work otherwise complies with
128 | the conditions stated in this License.
129 |
130 | 5. Submission of Contributions. Unless You explicitly state otherwise,
131 | any Contribution intentionally submitted for inclusion in the Work
132 | by You to the Licensor shall be under the terms and conditions of
133 | this License, without any additional terms or conditions.
134 | Notwithstanding the above, nothing herein shall supersede or modify
135 | the terms of any separate license agreement you may have executed
136 | with Licensor regarding such Contributions.
137 |
138 | 6. Trademarks. This License does not grant permission to use the trade
139 | names, trademarks, service marks, or product names of the Licensor,
140 | except as required for reasonable and customary use in describing the
141 | origin of the Work and reproducing the content of the NOTICE file.
142 |
143 | 7. Disclaimer of Warranty. Unless required by applicable law or
144 | agreed to in writing, Licensor provides the Work (and each
145 | Contributor provides its Contributions) on an "AS IS" BASIS,
146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147 | implied, including, without limitation, any warranties or conditions
148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149 | PARTICULAR PURPOSE. You are solely responsible for determining the
150 | appropriateness of using or redistributing the Work and assume any
151 | risks associated with Your exercise of permissions under this License.
152 |
153 | 8. Limitation of Liability. In no event and under no legal theory,
154 | whether in tort (including negligence), contract, or otherwise,
155 | unless required by applicable law (such as deliberate and grossly
156 | negligent acts) or agreed to in writing, shall any Contributor be
157 | liable to You for damages, including any direct, indirect, special,
158 | incidental, or consequential damages of any character arising as a
159 | result of this License or out of the use or inability to use the
160 | Work (including but not limited to damages for loss of goodwill,
161 | work stoppage, computer failure or malfunction, or any and all
162 | other commercial damages or losses), even if such Contributor
163 | has been advised of the possibility of such damages.
164 |
165 | 9. Accepting Warranty or Additional Liability. While redistributing
166 | the Work or Derivative Works thereof, You may choose to offer,
167 | and charge a fee for, acceptance of support, warranty, indemnity,
168 | or other liability obligations and/or rights consistent with this
169 | License. However, in accepting such obligations, You may act only
170 | on Your own behalf and on Your sole responsibility, not on behalf
171 | of any other Contributor, and only if You agree to indemnify,
172 | defend, and hold each Contributor harmless for any liability
173 | incurred by, or claims asserted against, such Contributor by reason
174 | of your accepting any such warranty or additional liability.
175 |
176 | END OF TERMS AND CONDITIONS
177 |
178 | APPENDIX: How to apply the Apache License to your work.
179 |
180 | To apply the Apache License to your work, attach the following
181 | boilerplate notice, with the fields enclosed by brackets "{}"
182 | replaced with your own identifying information. (Don't include
183 | the brackets!) The text should be enclosed in the appropriate
184 | comment syntax for the file format. We also recommend that a
185 | file or class name and description of purpose be included on the
186 | same "printed page" as the copyright notice for easier
187 | identification within third-party archives.
188 |
189 | Copyright {yyyy} {name of copyright owner}
190 |
191 | Licensed under the Apache License, Version 2.0 (the "License");
192 | you may not use this file except in compliance with the License.
193 | You may obtain a copy of the License at
194 |
195 | http://www.apache.org/licenses/LICENSE-2.0
196 |
197 | Unless required by applicable law or agreed to in writing, software
198 | distributed under the License is distributed on an "AS IS" BASIS,
199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200 | See the License for the specific language governing permissions and
201 | limitations under the License.
202 |
--------------------------------------------------------------------------------
/WinCollect7/WinCollectAgentReInstall/ReInstallWinCollect.ps1:
--------------------------------------------------------------------------------
1 | #####################################################################
2 | ## For Reference only
3 | ##
4 | ## Pre-Requisites - Assumes WinCollect installer is located on system drive already (ie. c:\wincollect-7.3.0-24.x64.exe)
5 | ## Set Auth Token parameter if in Managed Mode
6 | #####################################################################
7 |
8 | Param
9 | (
10 | # Param1 help description
11 | [Parameter(Mandatory=$false,ValueFromPipelineByPropertyName=$false,Position=0)][string]$Authtoken
12 |
13 | )
14 |
15 |
16 |
17 | ### Function
18 |
19 | function Stop-WinCollect{
20 |
21 | Write-Host "Stopping WinCollect Service"
22 |
23 | Start-Job -Name "StopService" -ScriptBlock {Stop-Service -Name “WinCollect” -Force }
24 |
25 | #give it 5 seconds to stop
26 | Start-Sleep -Seconds 5
27 |
28 | $SERVICESTATE = (Get-Service -Name WinCollect).Status
29 |
30 | if( $SERVICESTATE -eq "Stopping" -or $SERVICESTATE -eq "StopPending")
31 | {
32 | # still stopping so force process stop
33 | Stop-Process -Name "WinCollectSvc" -Force -ErrorAction SilentlyContinue
34 | Stop-Process -Name "WinCollect" -Force -ErrorAction SilentlyContinue
35 | write-host "Stopped WinCollect processes"
36 |
37 | }
38 |
39 | Start-Sleep -Seconds 5
40 |
41 | $SERVICESTATE = (Get-Service -Name WinCollect).Status
42 |
43 | if( $SERVICESTATE -eq "Stopped" )
44 | {
45 | Write-Host "Service Stopped `n"
46 | }
47 |
48 | else {Write-Host "Service not stopped, something is wrong, check status of WinCollect Service" Exit }
49 |
50 | Remove-Job -Name "StopService"
51 | }
52 |
53 | function Check-WinCollect {
54 |
55 | # Checking to see if we have a successful install - or as close as we can get
56 |
57 |
58 | ## Check to see if service is running
59 |
60 | Write-Host "`nFinal Checks.....`n"
61 |
62 |
63 | try {(Get-Service WinCollect).WaitForStatus('Running','00:00:30')
64 |
65 | Write-Host "WinCollect Service is running" -ForegroundColor Green
66 |
67 | }
68 |
69 | catch {Write-Host "WinCollect Service is not running please check the WinCollect service status" -BackgroundColor Red
70 |
71 | }
72 |
73 |
74 | #If (-Not((Get-Service WinCollect).Status -eq 'Running')) {Write-Host "WinCollect Service is not running please check the WinCollect service status" -BackgroundColor Red} else {Write-Host "WinCollect Service running" -BackgroundColor Green}
75 |
76 | ## Check for both wincollect.exe and wincollectsvc.exe processes
77 |
78 |
79 | Check-Process WinCollect
80 |
81 | Check-Process WinCollectSvc
82 |
83 |
84 | #if (-Not(Get-Process WinCollect)) {Write-Host "WinCollect.exe is not running please check the WinCollect service status" -BackgroundColor Red} else {Write-Host "WinCollect process is running" -ForegroundColor Green}
85 | #if (-Not(Get-Process WinCollectSvc)) {Write-Host "WinCollectSvc.exe is not running please check the WinCollect service status" -BackgroundColor Red} else {Write-Host "WinCollectSvc process is running" -ForegroundColor Green}
86 |
87 | ## Pull out the build number from the install config
88 |
89 | $install_config = (ConvertFrom-StringData([Regex]::Escape([IO.File]::ReadAllText("$InstallPath\config\install_config.txt")) -replace "(\\r)?\\n", [Environment]::NewLine))
90 |
91 | if (-Not($install_config.BuildNumber -eq "24")) {Write-Host "WinCollect is not running at the correct build number please uninstall and try re-installing" -BackgroundColor Red} else {Write-Host "WinCollect running at 7.3.0 build 24" -ForegroundColor Green}
92 |
93 |
94 | }
95 |
96 | Function Check-Process($processname){
97 |
98 | $timeout = new-timespan -Seconds 10
99 | $sw = [diagnostics.stopwatch]::StartNew()
100 |
101 | while ($sw.elapsed -lt $timeout){
102 |
103 | if (Get-Process $processname -ErrorAction SilentlyContinue){
104 | Write-Host "$processname process is running" -ForegroundColor Green
105 | return
106 | }
107 |
108 | start-sleep -seconds 1
109 | }
110 |
111 | write-host "$processname is not running please check the WinCollect service status" -BackgroundColor Red
112 |
113 | }
114 |
115 | #############################
116 |
117 |
118 |
119 | #Parameters
120 | $ProgramName = "WinCollect"
121 | $AgentConfigBackup = "$env:SystemDrive\AgentConfig_Backup.xml"
122 | $InstallConfigBackup = "$env:SystemDrive\install_config_backup.txt"
123 | $ConfigurationServerPort = "8413"
124 |
125 | ## Pre-Checks - Don't proceed unless these conditions are met
126 |
127 | ## Is the installer on the system drive
128 |
129 | # Set the bit version from AMD64 to X64
130 |
131 | if ($env:PROCESSOR_ARCHITECTURE -eq "X86") {$bit = "x86"} else {$bit = "x64"}
132 |
133 |
134 | if (-Not(Test-Path -Path $env:SystemDrive\wincollect-7.3.0-24.$bit.exe -PathType Any))
135 |
136 | {
137 |
138 | Write-Host "Can't find WinCollect installer, make sure you copy wincollect-7.3.0-24.$bit.exe to $env:SystemDrive Exiting" -BackgroundColor Red
139 |
140 | Exit
141 |
142 | }
143 |
144 | ## Make sure WinCollect is installed
145 |
146 | Write-Host "`nWinCollect installation information..."
147 |
148 | $InstallPath = Get-ChildItem "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Installer\UserData\*\Products\*\InstallProperties" | Where-Object { $_.getValue('DisplayName') -like $ProgramName } | ForEach-Object { $_.getValue('InstallLocation')}
149 |
150 | Write-Host "Agent install path: $InstallPath"
151 |
152 | if ([string]::IsNullOrEmpty($InstallPath))
153 |
154 | {
155 |
156 | Write-host "Can't find WinCollect installation location. Exiting" -BackgroundColor Red
157 |
158 | Exit
159 |
160 | }
161 |
162 |
163 | # Determine if this is a Managed or Stand Alone install
164 |
165 | #$install_config = (ConvertFrom-StringData([Regex]::Escape((Get-Content "$InstallPath\config\install_config.txt" | Out-String)) -replace "(\\r)?\\n", [Environment]::NewLine))
166 |
167 | $install_config = (ConvertFrom-StringData([Regex]::Escape([IO.File]::ReadAllText("$InstallPath\config\install_config.txt")) -replace "(\\r)?\\n", [Environment]::NewLine))
168 |
169 |
170 |
171 |
172 | # Get App Identifier and Config Server
173 |
174 | $appid = $install_config.ApplicationIdentifier
175 |
176 | if ([string]::IsNullOrEmpty($appid))
177 |
178 | {
179 |
180 | Write-host "Can't load Install Config Parameters. Exiting" -BackgroundColor Red
181 |
182 | Exit
183 |
184 | }
185 |
186 | $statusserver = $install_config.StatusServer
187 | $configserver = $install_config.ConfigurationServer
188 | $ConfigurationServerPort = $install_config.ConfigurationServerPort
189 |
190 | Write-Host "Agent Identifier: $appid`n"
191 |
192 | if ($configserver -eq "") {
193 |
194 | Write-Host "Install Type: Stand-Alone`n"
195 |
196 | $installtype = "Stand-Alone"
197 |
198 | }
199 |
200 | else {
201 | $installtype = "Managed"
202 |
203 | Write-Host "Install Type: $installtype"
204 | Write-Host "QRadar Configuration Server: $configserver"
205 | Write-Host "QRadar Configuration Port: $ConfigurationServerPort`n"
206 |
207 | #Check to make sure the token has been updated
208 |
209 | if ($Authtoken -eq "")
210 |
211 | {
212 |
213 | Write-Host 'Please run the script using the Authtoken parameter (i.e. .\ReInstallWinCollect.ps1 -Authtoken 9e32bca0-97f1-47c7-84da-4567605c814b, we need the authorization token created in QRadar.'
214 |
215 | Exit
216 |
217 | }
218 |
219 | if ($Authtoken.Length -ne 36){
220 |
221 | Write-Host 'The Authtoken provied is not 36 characters long, please re-check the auth token and try again'
222 |
223 | Exit
224 |
225 | }
226 |
227 | }
228 |
229 |
230 | # Stop WinCollect Service
231 |
232 | Stop-WinCollect
233 |
234 |
235 | # Make a backup of the Agent-Config.xml and Install_config.txt
236 |
237 | Copy-Item -Path $InstallPath\config\AgentConfig.xml -Destination $AgentConfigBackup -Force
238 |
239 | Copy-Item -Path $InstallPath\config\install_config.txt -Destination $InstallConfigBackup -Force
240 |
241 | # Make sure the file is there, before we uninstall
242 |
243 | if (-Not (Test-Path -Path $AgentConfigBackup -PathType Leaf)) {Write-Host "Unable to backup AgentConfig.xml Exiting" Exit}
244 |
245 | if (-Not (Test-Path -Path $InstallConfigBackup -PathType Leaf)) {Write-Host "Unable to backup install_config.txt Exiting" Exit}
246 |
247 |
248 | #Uninstall and then Install Agent
249 |
250 | if ($configserver -eq "" -and $statusserver -eq "") { $argument = '/s /v"/qn HOSTNAME=' + $appid + ' INSTALLDIR=\"' + $InstallPath +'""'}
251 | elseif ($configserver -eq "" -and $statusserver -ne "") { $argument = '/s /v"/qn HOSTNAME=' + $appid + ' INSTALLDIR=\"' + $InstallPath +'" STATUSSERVER=' + $statusserver + '"'}
252 | elseif ($configserver -ne "" -and $statusserver -eq "") { $argument = '/s /v"/qn HOSTNAME=' + $appid + ' FULLCONSOLEADDRESS=' + $configserver + ':' + $ConfigurationServerPort + ' AUTHTOKEN=' + $Authtoken + ' INSTALLDIR=\"' + $InstallPath +'""'}
253 | elseif ($configserver -ne "" -and $statusserver -ne "") { $argument = '/s /v"/qn HOSTNAME=' + $appid + ' FULLCONSOLEADDRESS=' + $configserver + ':' + $ConfigurationServerPort + ' AUTHTOKEN=' + $Authtoken + ' INSTALLDIR=\"' + $InstallPath +'" STATUSSERVER=' + $statusserver + '"'}
254 | else{write-host "Something is wrong trying to generate the Installation command, Exiting" Exit }
255 |
256 | Write-Host "Uninstalling WinCollect `n"
257 |
258 | Start-Process msiexec.exe -Wait -ArgumentList '/x {1E933549-2407-4A06-8EC5-83313513AE4B} REMOVE_ALL_FILES=True /qn'
259 |
260 | #Clean-up folders just in case
261 |
262 | if ( Test-Path -Path $InstallPath -PathType Container ) { "Remove-Item $InstallPath -Force -Recurse -ErrorAction SilentlyContinue" }
263 |
264 | Write-Host "Installing WinCollect...`n"
265 |
266 | Write-Host "Installation Command: `n $env:SystemDrive\wincollect-7.3.0-24.$bit.exe $argument`n"
267 |
268 | Start-Process "$env:SystemDrive\wincollect-7.3.0-24.$bit.exe" -Wait -ArgumentList $argument
269 |
270 |
271 |
272 | #If we are in stand alone copy in the new Agent-Config
273 |
274 | if ($installtype -eq "Stand-Alone") {
275 |
276 | Write-Host "Waiting 30 seconds for Agent to finish installing"
277 |
278 | Start-Sleep -Seconds 10
279 |
280 | Write-Host "Copying back the AgentConfig and Restarting WinCollect"
281 |
282 | if (-Not (Test-Path -Path $AgentConfigBackup -PathType Leaf)) {Write-Host "Unable to find AgentConfig.xml something is wrong with the installation Exiting" Exit}
283 |
284 | Copy-Item -Path $AgentConfigBackup -Destination $InstallPath\config\AgentConfig.xml -Force
285 |
286 | write-host "Stopping WinCollect Service to apply backup configuration"
287 |
288 | Stop-WinCollect
289 |
290 | Start-Service -Name WinCollect
291 |
292 | Check-WinCollect
293 |
294 |
295 | }
296 |
297 | if ($installtype -eq "Managed") {
298 |
299 | Write-Host "Waiting 30 seconds for Agent to finish installing"
300 |
301 | Start-Sleep -Seconds 30
302 |
303 | Check-WinCollect
304 |
305 | Write-Host "`nNOTE: It could take 5-10 minutes, or more to get code and configuration updates from QRadar"
306 |
307 | }
308 |
309 |
310 |
311 |
312 |
313 |
--------------------------------------------------------------------------------
/EventLogReport/GetEventLogReport.ps1:
--------------------------------------------------------------------------------
1 | #################################################################################################
2 | # This Powershell script includes three options for EPS data collection:
3 | #
4 | # Option 1) Scan the event log(s) of the local Windows host to determine the Events Per Second
5 | # (EPS) rate.
6 | # Option 2) Scan a list of IP addresses provided by the user. The remote systems Event Log(s) are
7 | # scanned to determine the Events Per Second (EPS) rate of each host in the list.
8 | # Option 3) Scan the local domain where the script is run to determine the Events Per Second (EPS)
9 | # rate of all Windows hosts within the domain.
10 | #
11 | # Note: PowerShell must be run as local admin & users must run Set-ExecutionPolicy RemoteSigned
12 | # To use Option 3 for domain scans, Powershell domain cmdlets need to be installed.
13 | #
14 | # Pre-requisites: This script requires Powershell 3.0 or 4.0. Powershell is the property of
15 | # Microsoft. For more information on Powershell or downloads, see the following
16 | # website: https://technet.microsoft.com/en-us/scriptcenter/dd742419.aspx
17 | #
18 | #
19 | # Authors: Jamie Wheaton // William Delong
20 | #
21 | #
22 | #################################################################################################
23 | #
24 | #
25 | #################################################################################################
26 | #Function will scan the Event Log(s) & determine the Events Per Second (EPS).
27 | #
28 | #@param $Agent -> The Computer / IP
29 | #@param $LogName -> The Event Log that will be evaluated (Security, Application, System)
30 | #@param $RemoteComputer -> The value to tell if the computer is remote or local
31 | #
32 | #################################################################################################
33 |
34 | function Get-EventLogInfo { param($Agent, $LogName, $RemoteComputer, $OS)
35 |
36 | $LogInfo = @{}
37 |
38 | try {
39 |
40 | # Just localhost
41 | If (!$RemoteComputer) {
42 |
43 | $TotalLogEvents = (Get-WinEvent -ListLog $LogName).RecordCount
44 |
45 | $LogSize = (Get-WinEvent -ListLog $LogName).FileSize / 1000000 # Set to MB
46 |
47 | $LogSize = [math]::Round(($LogSize), 1)
48 |
49 | $OldestEventTime = (Get-WinEvent $LogName -Oldest -maxevents 1).TimeCreated
50 |
51 | $NewestEventTime = (Get-WinEvent $LogName -maxevents 1).TimeCreated
52 |
53 | $TotalTime = (Get-Date).Subtract($OldestEventTime).TotalSeconds
54 |
55 | $AvgEventsPerSecond = $TotalLogEvents / $TotalTime
56 |
57 | $AvgEventsPerSecond = [math]::Round($AvgEventsPerSecond, 5)
58 |
59 | }
60 |
61 | # Remote box
62 | Else {
63 |
64 | if ($OS -like "*Server 2003*" -or $OS -like "*Windows XP*"){
65 |
66 | Write-Host "$OS is an old Operating System, Collecting $LogName Event Log Information via WMI, this may take some time"
67 |
68 | $wmi_eventlogsummary = Get-WmiObject -Class Win32_NTEventLogFile -computername $Agent -Credential $Global:Cred -filter "LogFileName = '$LogName'"
69 |
70 | $TotalLogEvents = $wmi_eventlogsummary.NumberOfRecords
71 |
72 | $LogSize = ($wmi_eventlogsummary.FileSize / 1MB)
73 |
74 | $wmi_eventlogdata = Get-WMIobject -ComputerName $computer -Credential $cred -query "Select * from Win32_NTLogEvent Where Logfile = 'application'"
75 |
76 | $getwmioldevent = $wmi_eventlogdata| select -last 1
77 |
78 | $getwminewest = $wmi_eventlogdata | select -first 1
79 |
80 | $OldestEventTime = [management.managementDateTimeConverter]::ToDateTime($getwmioldevent.TimeGenerated)
81 |
82 | $NewestEventTime = [management.managementDateTimeConverter]::ToDateTime($getwminewest.TimeGenerated)
83 |
84 |
85 | }
86 |
87 | else {
88 |
89 | $TotalLogEvents = (Get-WinEvent -ListLog $LogName -ComputerName $Agent -Credential $Global:Cred).RecordCount
90 |
91 | $LogSize = ((Get-WinEvent -ListLog $LogName -ComputerName $Agent -Credential $Global:Cred).FileSize / 1MB) # Set to MB
92 |
93 | #$LogSize = [math]::Round(($LogSize), 1)
94 |
95 | if ($TotalLogEvents -eq 0) {
96 |
97 | Write-Log $ERROR_LOG "There are 0 $LogName Events"
98 |
99 | $OldestEventTime = 0
100 | $NewestEventTime = 0
101 | $TotalTime = 0
102 | $AvgEventsPerSecond = 0
103 | $AvgEventsPerSecond = 0
104 |
105 | }
106 |
107 | else {
108 |
109 | $OldestEventTime = (Get-WinEvent $LogName -ComputerName $Agent -Credential $Global:Cred -Oldest -Maxevents 1).TimeCreated
110 |
111 | $NewestEventTime = (Get-WinEvent $LogName -ComputerName $Agent -Credential $Global:Cred -Maxevents 1).TimeCreated
112 |
113 | $TotalTime = (Get-Date).Subtract($OldestEventTime).TotalSeconds
114 |
115 | $AvgEventsPerSecond = $TotalLogEvents / $TotalTime
116 |
117 | $AvgEventsPerSecond = [math]::Round($AvgEventsPerSecond, 5)
118 |
119 |
120 | }
121 |
122 | }
123 |
124 |
125 | }
126 |
127 |
128 |
129 | $LogInfo.Add("StartTime", $OldestEventTime)
130 | $LogInfo.Add("EndTime", $NewestEventTime)
131 |
132 | $LogInfo.Add("LogSize", $LogSize)
133 | #$LogInfo.Add("OSVersion", $OSVersion)
134 |
135 | $LogInfo.Add("TotalEvents", $TotalLogEvents)
136 |
137 | $LogInfo.Add("AverageEvents", $AvgEventsPerSecond)
138 |
139 | Return $LogInfo
140 |
141 | }
142 |
143 | catch {
144 |
145 | Write-Log $ERROR_LOG "Unable to scan $Agent event logs"
146 |
147 | Write-Log $ERROR_LOG $Error[0]
148 |
149 | $ErrorLineNumber = $Error[0].InvocationInfo.scriptlinenumber
150 |
151 | Write-Log $ERROR_LOG "Caught on line number: $ErrorLineNumber"
152 |
153 | continue
154 | }
155 | }
156 |
157 |
158 | #################################################################################################
159 | #Function will generate output info for the given log events per second
160 |
161 | #@param $TotalLogEvents -> The total # of events for the given log
162 |
163 | #################################################################################################
164 |
165 | function Get-ProfileSuggestion { param($AvgEventsPerSecond)
166 |
167 | try {
168 |
169 | #Profile sugestion
170 | $LogStatsAndInfo = ""
171 |
172 |
173 | If ($AvgEventsPerSecond -GE 0 -and $AvgEventsPerSecond -LE 100) {
174 |
175 | $LogStatsAndInfo += "MSRPC (0-100) EPS or WinCollect Default (Endpoint) (0-50) EPS`n"
176 | }
177 |
178 | # Above High Hate
179 | If ($AvgEventsPerSecond -GT 625) {
180 |
181 | $LogStatsAndInfo += "Suggested Profile: High Event Rate Server (251-625) EPS"
182 | #$LogStatsAndInfo += "NOTE: Log Event Rate Higher Then Profile Range`n"
183 |
184 | }
185 |
186 | #- High Event Rate Server 1250-1875 (416-625)
187 | ElseIf ($AvgEventsPerSecond -GE 250) {
188 |
189 | $LogStatsAndInfo += "High Event Rate Server (251-625) EPS"
190 | }
191 |
192 | #- Typical Server 500-750 (166-250)
193 | ElseIf ($AvgEventsPerSecond -GE 50) {
194 |
195 | $LogStatsAndInfo += "Typical Server (51-250) EPS"
196 | }
197 |
198 | #- Default (Endpoint) 100-150 (33-50)
199 | ElseIf ($AvgEventsPerSecond -GE 0) {
200 |
201 | $LogStatsAndInfo += "WinCollect Default (Endpoint) (0-50) EPS"
202 | }
203 |
204 | # Negitive or unreadble and cant be determined
205 | Else {
206 |
207 | Write-Log $ERROR_LOG "Unable to Suggest Profile"
208 |
209 | exit
210 | }
211 |
212 |
213 | $LogStatsAndInfo
214 |
215 |
216 | }
217 |
218 | catch {
219 |
220 | Write-Log $ERROR_LOG "Unable to get profile suggestion"
221 |
222 | Write-Log $ERROR_LOG $Error[0]
223 |
224 | $ErrorLineNumber = $Error[0].InvocationInfo.scriptlinenumber
225 |
226 | Write-Log $ERROR_LOG "Caught on line number: $ErrorLineNumber"
227 |
228 | exit
229 | }
230 | }
231 |
232 | #################################################################################################
233 | #Function will test connection
234 |
235 | #@param $Cred -> The Event Log
236 | #@param $Computer -> The avg events per second for the given log
237 |
238 | #################################################################################################
239 |
240 | function Test-HostConnection { param($Computer)
241 |
242 | try {
243 |
244 | if ((Test-Connection -ComputerName $Computer -count 1 -quiet)) {
245 |
246 | return $true
247 | }
248 |
249 | else {
250 |
251 |
252 | Write-Log $ERROR_LOG "Unable to contact $Computer. Please verify its network connectivity and try again"
253 |
254 | $Global:ConnectionIssues = $Global:ConnectionIssues + 1
255 |
256 | return $false
257 | }
258 | }
259 |
260 | catch {
261 |
262 | Write-Log $ERROR_LOG "Unable conect to Host"
263 |
264 | Write-Log $ERROR_LOG $Error[0]
265 |
266 | $ErrorLineNumber = $Error[0].InvocationInfo.scriptlinenumber
267 |
268 | Write-Log $ERROR_LOG "Caught on line number: $ErrorLineNumber"
269 |
270 | exit
271 |
272 | }
273 | }
274 |
275 |
276 | #################################################################################################
277 | #Function Create a log report for the each computer in the computer list
278 |
279 | #@param $LogName -> The Event Log
280 | #@param $AvgEventsPerSecond -> The avg events per second for the given log
281 | #@param $TotalLogEvents -> The total # of events for the given log
282 |
283 | #################################################################################################
284 |
285 | function Create-LogReport { param($Computerlist, $ComputerCount, $ComputerListType, $OS)
286 |
287 | try {
288 |
289 | $Report = @{}
290 | $ProgressCount = 0;
291 |
292 | if ($ComputerListType -NE $LOCALHOST_OPT) {
293 |
294 | $Global:Cred = Get-Credential -Message "Enter an account which has access to the Windows Event Logs"
295 | }
296 |
297 |
298 | ForEach ($Computer in $Computerlist) {
299 |
300 | $ProgressCount = $ProgressCount + 1
301 |
302 | $RemoteComputer = $false
303 |
304 | if($ProgressCount -EQ 1) {
305 |
306 | Write-Log $INFO_LOG "Calculating & Processing Log EPS For Computer List"
307 | }
308 |
309 | if ($ComputerListType -NE $LOCALHOST_OPT) {
310 |
311 | $RemoteComputer = $true
312 |
313 | $Login = Test-HostConnection $Computer
314 |
315 | if (!$Login) {
316 | continue
317 | }
318 | }
319 |
320 | # Get Server OS if not already gathered
321 | if ($ComputerListType -eq $FILE_OPT) {
322 | Write-Log $INFO_LOG "Getting OS Information for $Computer"
323 | $OS = (Get-WmiObject Win32_OperatingSystem -computername $Computer -Credential $Global:Cred).Caption
324 | Write-Log $INFO_LOG "$OS"
325 | }
326 |
327 | if ($ComputerListType -eq $LOCALHOST_OPT) {
328 | Write-Log $INFO_LOG "Getting OS Information for $Computer"
329 | $OS = (Get-WmiObject Win32_OperatingSystem).Caption
330 | Write-Log $INFO_LOG "$OS"
331 | }
332 |
333 | if ($ComputerListType -eq $DOMAIN_OPT) {
334 | Write-Log $INFO_LOG "Getting OS Information for $Computer"
335 | #$OS = (Get-WmiObject Win32_OperatingSystem -computername $Computer -Credential $Global:Cred).Caption
336 |
337 | $GetADComputerList = Get-ADComputer -Credential $Global:Cred -Filter {enabled -eq "true"} -Properties OperatingSystem | Select DNSHostname, OperatingSystem
338 |
339 | #$GetADOS = Get-ADComputer -Credential $Global:Cred -Filter {enabled -eq "true"} -Properties OperatingSystem | Select
340 |
341 | #$ComputerList = $GetADComputerList.DNSHostName
342 |
343 |
344 | $OS = ($GetADComputerList -match $Computer).OperatingSystem
345 | Write-Log $INFO_LOG "$OS"
346 | }
347 |
348 |
349 | # Retrieve the Application Event log info
350 | $ApplicationInfo = Get-EventLogInfo $Computer Application $RemoteComputer $OS
351 | $ApplicationEPS = $ApplicationInfo.AverageEvents
352 | $ApplicationFirstEventTime = $ApplicationInfo.StartTime
353 | $ApplicationLastEventTime = $ApplicationInfo.EndTime
354 | $ApplicationTotalEvents = $ApplicationInfo.TotalEvents
355 | $ApplicationEventLogSize = $ApplicationInfo.LogSize
356 |
357 |
358 | # Retrieve the Security Event log info
359 | $SecurityInfo = Get-EventLogInfo $Computer Security $RemoteComputer $OS
360 | $SecurityEPS = $SecurityInfo.AverageEvents
361 | $SecurityFirstEventTime = $SecurityInfo.StartTime
362 | $SecurityLastEventTime = $SecurityInfo.EndTime
363 | $SecurityTotalEvents = $SecurityInfo.TotalEvents
364 | $SecurityEventLogSize = $SecurityInfo.LogSize
365 |
366 |
367 | # Retrieve the System Event log info
368 | $SystemInfo = Get-EventLogInfo $Computer System $RemoteComputer $OS
369 | $SystemEPS = $SystemInfo.AverageEvents
370 | $SystemFirstEventTime = $SystemInfo.StartTime
371 | $SystemLastEventTime = $SystemInfo.EndTime
372 | $SystemTotalEvents = $SystemInfo.TotalEvents
373 | $SystemEventLogSize = $SystemInfo.LogSize
374 |
375 |
376 | $TotalEPS = [math]::Round(($ApplicationEPS + $SecurityEPS + $SystemEPS), 5)
377 | $ProfileSuggestion = Get-ProfileSuggestion $TotalEPS
378 | #$ComputerOS = (Get-ADComputer -Filter *).OperatingSystem
379 | $ComputerOS = "$OS"
380 |
381 |
382 | $Box = @{"ProfileSuggestion" = $ProfileSuggestion; "TotalEPS" = $TotalEPS; "OSVersion" = $ComputerOS;
383 | "ApplicationEPS" = $ApplicationEPS; "ApplicationFirstEventTime" = $ApplicationFirstEventTime; "ApplicationLastEventTime" = $ApplicationLastEventTime; "ApplicationTotalEvents" = $ApplicationTotalEvents; "ApplicationEventLogSize" = $ApplicationEventLogSize;
384 | "SecurityEPS" = $SecurityEPS; "SecurityFirstEventTime" = $SecurityFirstEventTime; "SecurityLastEventTime" = $SecurityLastEventTime; "SecurityTotalEvents" = $SecurityTotalEvents; "SecurityEventLogSize" = $SecurityEventLogSize;
385 | "SystemEPS" = $SystemEPS; "SystemFirstEventTime" = $SystemFirstEventTime; "SystemLastEventTime" = $SystemLastEventTime; "SystemTotalEvents" = $SystemTotalEvents; "SystemEventLogSize" = $SystemEventLogSize;}
386 |
387 | $Report.Add($Computer, $Box)
388 |
389 | $PercentComplete = $ProgressCount / $ComputerCount * 100
390 | $PercentComplete = [math]::Round($PercentComplete, 0)
391 |
392 | Write-Progress -Activity "Processing Computer List - $PercentComplete% Complete" -status "Calculating EPS for Computer: $Computer" -percentComplete $PercentComplete
393 | }
394 |
395 | Write-Log $INFO_LOG "Event Log ESP Report Calculations Complete"
396 |
397 | Return $Report
398 |
399 | }
400 |
401 | catch {
402 |
403 | Write-Log $ERROR_LOG "Unable to Create Log Report"
404 |
405 | Write-Log $ERROR_LOG $Error[0]
406 |
407 | $ErrorLineNumber = $Error[0].InvocationInfo.scriptlinenumber
408 |
409 | Write-Log $ERROR_LOG "Caught on line number: $ErrorLineNumber"
410 |
411 | exit
412 | }
413 | }
414 |
415 |
416 | #################################################################################################
417 | #Function will generate output info for the given log. Avg, Suggested Profile, etc...
418 |
419 | #@param $LogName -> The Event Log
420 | #@param $AvgEventsPerSecond -> The avg events per second for the given log
421 | #@param $TotalLogEvents -> The total # of events for the given log
422 |
423 | #################################################################################################
424 |
425 | function Export-LogReport { param($Computerlist, $ComputerCount, $ComputerListType)
426 |
427 | try {
428 |
429 | $Report = Create-LogReport $Computerlist $ComputerCount $ComputerListType
430 |
431 | $OutputTable = foreach ($box in $Report.GetEnumerator()) {
432 |
433 | New-Object PSObject -Property ([ordered]@{
434 | "Server" = $box.Name; "OS Version" = $box.Value.OSVersion;
435 | "Application (EPS)" = $box.Value.ApplicationEPS; "Application 1st Event" = $box.Value.ApplicationFirstEventTime; "Application last Event" = $box.Value.ApplicationLastEventTime; "Application total events" = $box.Value.ApplicationTotalEvents; "Application Log Size (MB)" = $box.Value.ApplicationEventLogSize;
436 | "Security (EPS)" = $box.Value.SecurityEPS; "Security 1st Event" = $box.Value.SecurityFirstEventTime; "Security last Event" = $box.Value.SecurityLastEventTime; "Security total events" = $box.Value.SecurityTotalEvents; "Security Log Size (MB)" = $box.Value.SecurityEventLogSize;
437 | "System (EPS)" = $box.Value.SystemEPS; "System 1st Event" = $box.Value.SystemFirstEventTime; "System last Event" = $box.Value.SystemLastEventTime; "System total events" = $box.Value.SystemTotalEvents; "System Log Size (MB)" = $box.Value.SystemEventLogSize;
438 | "Total (EPS)" = $box.Value.TotalEPS; "Profile Suggestion (3 Sec Polling Interval)" = $box.Value.ProfileSuggestion;})
439 |
440 | }
441 |
442 |
443 | Write-Log $INPUT_LOG "Select Event Log Export Location..."
444 |
445 | $ExportFolder = Select-ExportLocation "Event Log Summary Report Export Location" "Desktop"
446 |
447 | $ExportLocation = $ExportFolder + "\Event-Log-Summary-Report-" + $(get-date -f yyyyMMddhhmmss) + ".csv"
448 |
449 | Write-Log $INFO_LOG "Exporting Log Events to: $ExportLocation"
450 |
451 | $OutputTable | Export-CSV $ExportLocation -NoTypeInformation -Force
452 |
453 | }
454 |
455 | catch {
456 |
457 | Write-Log $ERROR_LOG "Unable to Export Log Report"
458 |
459 | Write-Log $ERROR_LOG $Error[0]
460 |
461 | $ErrorLineNumber = $Error[0].InvocationInfo.scriptlinenumber
462 |
463 | Write-Log $ERROR_LOG "Caught on line number: $ErrorLineNumber"
464 |
465 | exit
466 | }
467 | }
468 |
469 |
470 | #################################################################################################
471 | #Function will generate a Folder Select Dialog
472 |
473 | #@param $Description -> The Description of the Dialog
474 | #@param $RootFolder -> The location that the folder selection begins
475 |
476 | #################################################################################################
477 |
478 | function Get-FileName { param($RootFolder)
479 |
480 | try {
481 |
482 | $OpenFileDialog = New-Object System.Windows.Forms.OpenFileDialog
483 | $OpenFileDialog.initialDirectory = $RootFolder
484 | $OpenFileDialog.Title = "Select Computer List"
485 | $OpenFileDialog.filter = "All files (*.*)| *.*"
486 | $OpenFileDialog.ShowDialog() | Out-Null
487 | $OpenFileDialog.filename
488 |
489 | }
490 |
491 | catch {
492 |
493 | Write-Log $ERROR_LOG "Unable to Select File"
494 |
495 | Write-Log $ERROR_LOG $Error[0]
496 |
497 | $ErrorLineNumber = $Error[0].InvocationInfo.scriptlinenumber
498 |
499 | Write-Log $ERROR_LOG "Caught on line number: $ErrorLineNumber"
500 |
501 | exit
502 |
503 | }
504 | }
505 |
506 |
507 | #################################################################################################
508 | #Function will generate a Folder Select Dialog
509 |
510 | #@param $Description -> The Description of the Dialog
511 | #@param $RootFolder -> The location that the folder selection begins
512 |
513 | #################################################################################################
514 |
515 | function Select-ExportLocation { param($Description, $RootFolder)
516 |
517 | try {
518 |
519 | $objForm = New-Object System.Windows.Forms.FolderBrowserDialog
520 | $objForm.Rootfolder = $RootFolder
521 | $objForm.Description = $Description
522 | $Show = $objForm.ShowDialog()
523 |
524 | if ($Show -EQ "OK") {
525 |
526 | return $objForm.SelectedPath
527 | }
528 |
529 | else {
530 |
531 | Write-Log $ERROR_LOG "Operation cancelled by user"
532 |
533 | Write-Log $ERROR_LOG $Error[0]
534 |
535 | $ErrorLineNumber = $Error[0].InvocationInfo.scriptlinenumber
536 |
537 | Write-Log $ERROR_LOG "Caught on line number: $ErrorLineNumber"
538 |
539 | exit
540 |
541 | }
542 |
543 |
544 | }
545 |
546 | catch {
547 |
548 | Write-Log $ERROR_LOG "Unable to Select Folder"
549 |
550 | Write-Log $ERROR_LOG $Error[0]
551 |
552 | $ErrorLineNumber = $Error[0].InvocationInfo.scriptlinenumber
553 |
554 | Write-Log $ERROR_LOG "Caught on line number: $ErrorLineNumber"
555 |
556 | exit
557 |
558 | }
559 | }
560 |
561 |
562 | #################################################################################################
563 | #Function will generate a Drop Down Menu based on the given Drop Down Options
564 |
565 | #@param $DropDownOptions -> The Event Log that will be evaluated (Security, Application, System)
566 | #@param $Title -> The Title of the Drop Down Menu
567 |
568 | #################################################################################################
569 |
570 | function Get-InputFromDropDown { param($DropDownOptions, $Title)
571 |
572 | try {
573 |
574 | function Return-DropDown {
575 | $script:Choice = $DropDown.SelectedItem.ToString()
576 | $Form.Close()
577 | }
578 |
579 | $Form = New-Object System.Windows.Forms.Form
580 |
581 | $Form.width = 300
582 | $Form.height = 150
583 | $Form.Text = "Select $Title"
584 |
585 | $DropDown = new-object System.Windows.Forms.ComboBox
586 | $DropDown.Location = new-object System.Drawing.Size(100,10)
587 | $DropDown.Size = new-object System.Drawing.Size(130,30)
588 |
589 | ForEach ($Item in $DropDownOptions) {
590 | [void] $DropDown.Items.Add($Item)
591 | }
592 |
593 | $Form.Controls.Add($DropDown)
594 |
595 | $DropDownLabel = new-object System.Windows.Forms.Label
596 | $DropDownLabel.Location = new-object System.Drawing.Size(10,10)
597 | $DropDownLabel.size = new-object System.Drawing.Size(100,20)
598 | $DropDownLabel.Text = "Options:"
599 | $Form.Controls.Add($DropDownLabel)
600 |
601 | $Button = new-object System.Windows.Forms.Button
602 | $Button.Location = new-object System.Drawing.Size(100,50)
603 | $Button.Size = new-object System.Drawing.Size(100,20)
604 | $Button.Text = "Submit"
605 | $Button.Add_Click({Return-DropDown})
606 | $form.Controls.Add($Button)
607 |
608 | $DropDown.SelectedIndex = 0
609 |
610 | $Form.Add_Shown({$Form.Activate()})
611 | [void] $Form.ShowDialog()
612 |
613 | $Choice
614 | }
615 |
616 | catch {
617 |
618 | Write-Log $ERROR_LOG "Unable to generate input drop down"
619 |
620 | Write-Log $ERROR_LOG $Error[0]
621 |
622 | $ErrorLineNumber = $Error[0].InvocationInfo.scriptlinenumber
623 |
624 | Write-Log $ERROR_LOG "Caught on line number: $ErrorLineNumber"
625 |
626 | exit
627 |
628 | }
629 | }
630 |
631 |
632 | #########################################################################################
633 | #Function will get the list of computers based on the users selected list type
634 |
635 | #@param $ComputerListType -> The type of computer list
636 |
637 | #########################################################################################
638 |
639 | function Get-ComputerList { param($ComputerListType)
640 |
641 |
642 | try {
643 |
644 | $ComputerList = @{};
645 |
646 | switch($ComputerListType) {
647 |
648 | $DOMAIN_OPT {
649 |
650 | $GetADComputerList = Get-ADComputer -Credential $Global:Cred -Filter {enabled -eq "true"} -Properties OperatingSystem | Select DNSHostname, OperatingSystem
651 |
652 | $ComputerList = $GetADComputerList.DNSHostName
653 |
654 | break
655 |
656 | }
657 |
658 | $FILE_OPT {
659 |
660 | $ComputerList = Get-FileName "Desktop"
661 | $ComputerList = Get-Content $ComputerList
662 |
663 | break
664 | }
665 |
666 | $LOCALHOST_OPT {
667 |
668 | $ComputerList = "localhost"
669 |
670 | break
671 | }
672 | }
673 |
674 | Return $ComputerList
675 |
676 | }
677 |
678 | catch {
679 |
680 | Write-Log $ERROR_LOG "Unable to determine computer list"
681 |
682 | Write-Log $ERROR_LOG $Error[0]
683 |
684 | $ErrorLineNumber = $Error[0].InvocationInfo.scriptlinenumber
685 |
686 | Write-Log $ERROR_LOG "Caught on line number: $ErrorLineNumber"
687 |
688 | exit
689 |
690 | }
691 | }
692 |
693 |
694 |
695 | #########################################################################################
696 | #Function will log messages throughout the script execution
697 |
698 | #@param $severity -> How severe of the input message to log
699 | #@param $logMessage -> The message that will be logged cast to a string
700 |
701 | #########################################################################################
702 |
703 | function Write-Log { param($severity, [string]$logMessage)
704 |
705 | try {
706 |
707 | if ($logMessage.length -GT 200) {
708 | $logMessage = $logMessage.Substring(0,200) + "..."
709 |
710 | }
711 |
712 | $output = $logMessage + "`n"
713 |
714 | switch($Severity) {
715 |
716 | $INFO_LOG {Write-Host $output -Fore Green; break}
717 |
718 | $INPUT_LOG {Write-Host $output -Fore Cyan; break}
719 |
720 | $WARN_LOG {Write-Host $output -Fore Cyan; break}
721 |
722 | $ERROR_LOG {Write-Host $output -Fore Red; break}
723 |
724 | Default {Write-Host "Unable to log based on severity: $Severity" -Fore Cyan; break}
725 | }
726 |
727 | }
728 |
729 | catch {
730 |
731 | Write-Host "Unable to log`n" -Fore Red
732 |
733 | Write-Host $Error[0] -Fore Red
734 |
735 | $ErrorLineNumber = $Error[0].InvocationInfo.scriptlinenumber
736 |
737 | Write-Host "Caught on line number: $ErrorLineNumber" -Fore Red
738 |
739 | exit
740 |
741 | }
742 | }
743 |
744 |
745 | # Imports the forms
746 | [System.Reflection.Assembly]::LoadWithPartialName("System.windows.forms") | Out-Null
747 |
748 | #Set severities
749 | $INFO_LOG = "Info"
750 | $INPUT_LOG = "Input"
751 | $WARN_LOG = "Warn"
752 | $ERROR_LOG = "Error"
753 |
754 | #Set Computer List Options
755 | #$hostdomain = (Get-ADDomain).DNSRoot
756 | $FILE_OPT = "IP List"
757 | $DOMAIN_OPT = "Domain"
758 | $LOCALHOST_OPT = "Local Host"
759 |
760 |
761 | Write-Log $INFO_LOG "Starting Script"
762 |
763 | # Drop Down Options
764 | [array]$ComputerListTypeOptions = $FILE_OPT, $LOCALHOST_OPT, $DOMAIN_OPT
765 |
766 |
767 | #Set the function variables
768 | $ComputerListType = Get-InputFromDropDown $ComputerListTypeOptions "IP List Type"
769 |
770 |
771 | #Set the function variables
772 | Write-Log $INPUT_LOG "Select Computer List..."
773 |
774 | $ComputerList = Get-ComputerList $ComputerListType
775 | $ComputerCount = $ComputerList.Count
776 | $Global:Cred = $Null
777 | $Global:ConnectionIssues = 0
778 |
779 | #Set all errors to terminating
780 | $ErrorActionPreference = "Stop"
781 |
782 | Write-Log $INFO_LOG "Selected: $ComputerListType ($ComputerCount Computer(s) Found)"
783 |
784 | #Call function
785 | $Time = Measure-Command -Expression {
786 | $LogReport = Export-LogReport $Computerlist $ComputerCount $ComputerListType
787 | }
788 |
789 | $Time = [math]::Round($Time.TotalMinutes, 1)
790 |
791 | Write-Log $INFO_LOG "Event Log Report Successfully Calculated & Exported - $ComputerCount Computers - $Time Minutes - $Global:ConnectionIssues Connection Issue(s)"
792 |
--------------------------------------------------------------------------------