简体   繁体   English

为什么这个 Foreach 循环迭代两次?

[英]Why Does This Foreach Loop Iterate Twice?

This code will cause 2 iterations before continuing to my next code.在继续我的下一个代码之前,此代码将导致 2 次迭代。 Running this off a USB drive.在 USB 驱动器上运行它。

write-Host "McAfee Consumer Product Removal" -ForegroundColor Cyan
$drives = Get-PSDrive
foreach ($root in $drives.root)  {
if (test-path "$root`mccleanup\mccleanup.exe") {
cd "$root`mccleanup" 
.\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 
write-Host "McAfee Consumer Product Removal completed" -ForegroundColor Magenta
    }
}
$drives = Get-PSDrive -PSProvider filesystem

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM