Mivel nem vagyok egy informatikus zseni inkább beilleszetem a program szöveges fájljait:
##Setting alias for Write-Host to Equal "wh"
Set-Alias wh Write-Host
Set-Alias rh Read-Host
wh n, "############################", n, "# APPRAISER SCRIPT v0.92 #", n, "############################", n
Start-Sleep 1
## Definition
$pantherDir = 'C:$WINDOWS.~BT\Sources\Panther'
$appraiserFile = "APPRAISER_HumanReadable.xml"
$AppVendorPattern = "<Property.*?SdbAppVendor.*?Value=""(.*?)"".*?/`>"
$AppNamePattern = "<Property.*?SdbAppName.*?Value=""(.*?)"".*?/`>"
$AppPathPattern = "<Property.*?LowerCaseLongPath.*?Value=""(.*?)"".*?/`>"
$logFilePath = "$(Split-Path -Parent -Path $MyInvocation.MyCommand.Definition)\log.txt"
$blockingAppVndrs = @()
$blockingAppDirs = @()
$blockingAppFiles = @()
$blockingAppNames = @()
Function EndScript($msg) {
if ($msg -ne "") { wh $msg, `n -ForeGroundColor Red }
rh "Press ENTER to Close"
BREAK
}
Function LogAndDisplayItem($itemname, $itemvalue) {
wh $itemname -NoNewLine; wh $itemvalue -ForeGroundColor Magenta
Add-Content -Path $logFilePath -Value "$($itemname.Trim()) $($itemvalue)"
}
Function TryOpenFolder($folderpath) {
if ((Test-Path $folderpath) -And ((Get-Item $folderpath) -is [System.IO.DirectoryInfo])) { Invoke-Item $folderpath }
Else { wh n, "Folder not found.", n -ForeGroundColor Red }
}
Function IsNewBlocker($filepath) {
if ($blockingAppDirs.Count -le 0) { return $true }
for ($i=0; $i -lt $blockingAppDirs.Count; $i++) {
$blkFilePath = "$($blockingAppDirs[$i])$($blockingAppFiles[$i])"
if ($blkFilePath -ieq $filepath) { return $false }
}
return $true
}
##CHECK FOR $Windows.~BT
if(Test-Path $pantherDir) { wh $pantherDir -NoNewLine; wh " - OK!" -ForeGroundColor Green }
Else{ EndScript "There is no $($pantherDir)\ Folder!" }
##CHECK FOR *APPRAISER_HumanReadable.xml & Store as VAR $appFile
$appFile = Get-Item "$pantherDir\*$appraiserFile"
if($appFile.Count -gt 0) { wh "Found *$($appraiserFile)",n, "@ $appFile" -NoNewLine; wh " - OK!" -ForeGroundColor Green }
Else{ EndScript "Did not find an *$($appraiserFile) File!" }
##Search String to locate what we need here...
$blockingAppEntries = $appFile | Select-String -Pattern "DT_ANY_FMC_BlockingApplication.*?Value="True""
## Catch and BREAK if No Values Found
if($($blockingAppEntries.Count) -eq 0) { EndScript "No Values Found for DT_ANY_FMC_BlockingApplication.*Value="True"!" }
##List Out Blocking Apps
wh n, "Located $($blockingAppEntries.Count) Apps Listed to be Blocking ...", n
##Clear log file
Set-Content -Path $logFilePath -Value ""
##Spit Out Blocking Apps
foreach ($blockingApp in $blockingAppEntries)
{
wh n, "Found Blocking App at: ""$($blockingApp.FileName)"" (line $($blockingApp.LineNumber))", n;
## Get last 50 lines
$blockingXML = "$(Get-Content "$pantherDir$($blockingApp.FileName)" -TotalCount $blockingApp.LineNumber -Encoding UTF8 | Select-Object -Last 50)"
## Find Strings in XML
$blockingAppVndr = ($blockingXML | Select-String -Pattern $AppVendorPattern).Matches
$blockingAppName = ($blockingXML | Select-String -Pattern $AppNamePattern).Matches
$blockingAppPath = ($blockingXML | Select-String -Pattern $AppPathPattern).Matches
$vndrName = ""; $appName = ""; $filename = ""; $dirpath = "";
if ($blockingAppVndr.Success) { $vndrName = $blockingAppVndr.Groups[1]; LogAndDisplayItem " App Vendor: " $vndrName }
if ($blockingAppName.Success) { $appName = $blockingAppName.Groups[1]; LogAndDisplayItem " App Name: " $appName }
if ($blockingAppPath.Success) { $blockingAppPath = $blockingAppPath.Groups[1]; LogAndDisplayItem " App Path: " $blockingAppPath }
$dirpath = Split-Path -Parent -Path $blockingAppPath; LogAndDisplayItem " Dir Path: " $dirpath
$filename = Split-Path -Leaf -Path $blockingAppPath
$dirpath = [System.Environment]::ExpandEnvironmentVariables($dirpath)
if (IsNewBlocker $blockingAppPath) {
$blockingAppFiles += $filename;
$blockingAppDirs += $dirpath;
$blockingAppNames += $appName;
$blockingAppVndrs += $vndrName;
}
LogAndDisplayItem "" ""
}
## End Script if no dirs found.
if($blockingAppDirs.Count -le 0) { EndScript "" }
## Folder open check
while($true)
{
wh n, n; wh "############ Would you like to open the folder of the Blocking App/File? ############", `n -BackgroundColor Black
for ($i=0; $i -lt $blockingAppDirs.Count; $i++) {
wh " $($i+1)" -ForeGroundColor Red -NoNewLine; wh ": $($blockingAppNames[$i]) ($($blockingAppVndrs[$i]))", n, n
wh " $($blockingAppFiles[$i])" -ForeGroundColor Yellow -NoNewLine; wh " in ""$($blockingAppDirs[$i])""" n, n
}
wh "Enter the " -NoNewLine; wh "number" -ForeGroundColor Red -NoNewLine
$numString = rh " of the App folder above you would like to open and press Enter.('q' to quit)"
## Check q and Cast the input to int
if($numString -eq 'q') { BREAK }
$num = $numString -as [int]
## Open the dir on explorer
if ($num -gt 0 -And $num -le $blockingAppDirs.Count) { TryOpenFolder $blockingAppDirs[$num-1] } else { wh `n, """$numString"" is not valid" -ForeGroundColor Red }
}
###EOF
Van egy másik szöveges fájl is:
App Vendor: Oracle
App Name: VirtualBox
Dir Path:
App Vendor: Oracle
App Name: VirtualBox
Dir Path:
App Vendor: Oracle
App Name: VirtualBox
Dir Path:
App Vendor: Oracle
App Name: VirtualBox
Dir Path:
App Vendor: Oracle
App Name: VirtualBox
Dir Path:
App Vendor: Oracle
App Name: VirtualBox
Dir Path:
App Vendor: Oracle
App Name: VirtualBox
Dir Path:
App Vendor: Oracle
App Name: VirtualBox
Dir Path:
App Vendor: Oracle
App Name: VirtualBox
Dir Path:
App Vendor: Oracle
App Name: VirtualBox
Dir Path:
App Vendor: Oracle
App Name: VirtualBox
Dir Path:
App Vendor: Oracle
App Name: VirtualBox
Dir Path:
App Vendor: Oracle
App Name: VirtualBox
Dir Path:
App Vendor: Oracle
App Name: VirtualBox
Dir Path:
App Vendor: Oracle
App Name: VirtualBox
Dir Path:
App Vendor: Oracle
App Name: VirtualBox
Dir Path:
App Vendor: Oracle
App Name: VirtualBox
Dir Path:
App Vendor: Oracle
App Name: VirtualBox
Dir Path:
App Vendor: Oracle
App Name: VirtualBox
Dir Path:
App Vendor: Oracle
App Name: VirtualBox
Dir Path:
App Vendor: Oracle
App Name: VirtualBox
Dir Path:
App Vendor: Oracle
App Name: VirtualBox
Dir Path: