I’m hard stuck trying to figure if this is possible. I need to cd into a newly created .tmp folder. The problem is that there isn’t a constant folder name for the .tmp folder. The issue in the code is at cd C:\temp\KillMcAfee\XXXXXXX.tmp. This script will download McAfee Consumer Tool Removal and run it if someone can help fix this issue. Thank you.
#Runs Powershell as Administrator and Bypass ExecutionPolicy
if (-Not ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)) {
if ([int](Get-CimInstance -Class Win32_OperatingSystem | Select-Object -ExpandProperty BuildNumber) -ge 6000) {
Start-Process PowerShell -Verb RunAs -ArgumentList “-NoProfile -ExecutionPolicy Bypass -Command "cd '$pwd'; & '$PSCommandPath';”";
Exit;
}
}
#New temp folder
New-Item “C:\temp” -itemType Directory
#Download MCPR
$url = “https://download.mcafee.com/molbin/iss-loc/SupportTools/MCPR/MCPR.exe”
$dest = “C:\temp\MCPR.exe”
Invoke-WebRequest -Uri $url -OutFile $dest
#Run, Copy MCPR data, Stop Process
start-process C:\temp\MCPR.exe -verb runas
cd $Env:LocalAppData\Temp
copy-item -Path “$Env:LocalAppData\Temp*” -Destination “C:\temp\KillMcAfee” -Recurse -Force -ErrorAction SilentlyContinue
start-sleep -Seconds 3
stop-process -Name “McClnUI”
#Run Mccleanup
cd C:\temp\KillMcAfee\XXXXXXX.tmp
.\Mccleanup.exe -p StopServices,MFSY,PEF,MXD,CSP,Sustainability,MOCP,MFP,APPSTATS,Auth,EMproxy,FWdiver,HW,MAS,MAT,MBK,MCPR,McProxy,McSvcHost,VUL,MHN,MNA,MOBK,MPFP,MPFPCU,MPS,SHRED,MPSCU,MQC,MQCCU,MSAD,MSHR,MSK,MSKCU,MWL,NMC,RedirSvc,VS,REMEDIATION,MSC,YAP,TRUEKEY,LAM,PCB,Symlink,SafeConnect,MGS,WMIRemover,RESIDUE -v -s
#Delete temp folder
Get-ChildItem C:\temp -Recurse | Remove-Item -Force -Recurse
#Empty RecycleBin
Clear-RecycleBin -Force
#Press Enter To Exit
Read-Host -Prompt “PRESS ENTER TO EXIT”