1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677 |
- $curPSScriptRoot = split-path -parent $MyInvocation.MyCommand.Definition
- $caRoot = Split-Path -Path $curPSScriptRoot
- $caPIDFile = "$caRoot\logs\capids.log"
- $wlpBootPIDFile = "$caRoot\logs\wlp_cogbootstrap_service.pid"
- $allPIDFile = "$caRoot\logs\allpids.log"
- Function GetChildPID {
- Param($aPID)
- $allProc | Where { $_.ParentProcessID -eq $aPID} | ForEach-Object {
- $aPName = '{0}' -f $_.Name
- if ( $aPName -ne "conhost.exe") {
- $pidName = '{0} {1}' -f $_.ProcessID, $_.Name | Out-File -append $caPIDFile
- }
-
- GetChildPID -aPID $_.ProcessID
- }
- }
- if ( Test-Path -Path $caPIDFile) {
- del $caPIDFile
- }
- if ( Test-Path -Path $wlpBootPIDFile) {
- $bootPID = Get-Content $wlpBootPIDFile
- if ( !$bootPID ) {
- exit 0
- }
- }
- else {
- exit 0
- }
- if ( Test-Path -Path $allPIDFile) {
- del $allPIDFile
- }
- $bootProc = Get-Process -id $bootPID
- if ( $bootProc -ne $null ) {
- $pidName = '{0} {1}' -f $bootProc.Id, $bootProc.ProcessName | Out-File -append $caPIDFile
- }
- $allProc = Get-WmiObject -Class Win32_process
- $CAPath = [regex]::escape($caRoot)
- $allProc | ForEach-Object {
- $procInfo = '{0} {1} {2} {3}' -f $_.ProcessID, $_.ParentProcessID, $_.Name, $_.Path
- $procPath = $_.Path
- if ( $procPath -cmatch $CAPath ) {
- "-- $procInfo" | Out-File -append $allPIDFile
- }
- else {
- "$procInfo" | Out-File -append $allPIDFile
- }
- }
- GetChildPID -aPID $bootPID
|