Forums on Intune, SCCM, and Windows 11

Welcome to the forums. Register a free account today to become a member! Once signed in, you'll be able to participate on this site by adding your topics and posts, as well as connect with other members through your own private inbox!

SOLVED Exclude folders from USMT

Status
Not open for further replies.

Codi

Member
Messages
9
Reaction score
0
Points
1
Hello,

I'm trying to use SCCM to upgrade clients from Windows 7 to Windows 10 and use USMT. There are two folders on the public desktop of the Windows 7 image I need to exclude in the MigUser.XML but I'm not sure how to string together the argument to exclude them.

The two folders are named "Office Apps" and "Resources". I thought this would work:

Code:
<exclude>
     <objectSet>
        <pattern type="File">C:\Users\*\desktop\Office Apps [*]</pattern>
        <pattern type="File">C:\Users\*\desktop\Resources [*]</pattern>
     </objectSet>
</exclude>

But when used in MigUser.xml is excluded everything. Please let me know how I can fix this!
 
I figured I could also delete the Resources and Office Apps folder before doing the capture. I tried a command line task with
Code:
del "%PUBLIC%\Desktop\Office Apps"
and it worked when I tried it in CMD on the computer, but not when I used it through OSD.

I tried a script I found, the script being:
Code:
# If you have other paths you need to delete just add more $path variables 
# and copy the If statements
$path = "C:\Users\Public\Desktop\"
# Checks if $path exists, if so deletes it and all subfolders and files
if (Test-Path $path) {
    
    $path + " Exists"
    Remove-Item -path $path -recurse
    Write-host -foregroundcolor Red $path " Deleted"
    [System.Threading.Thread]::Sleep(1500)
    
    } else {
    
    Write-host -foregroundcolor Red  $path  " Does not exist"
    
    }
# Checks if $path exists, if so deletes it and all subfolders and files
if (Test-Path $path2) {
    
    $path2 + " Exists"
    Remove-Item -path $path2 -recurse
    Write-host -foregroundcolor Red $path2 " Deleted"
    [System.Threading.Thread]::Sleep(1500)
    
    } else {
    
    Write-host -foregroundcolor Red  $path2  " Does not exist"
    
    }

I put that into a command step in the OSD as
Code:
"powershell.exe -command \\server\folder\sources\delete_files.ps1"
and it worked when used locally on the machine, but once again failed in when running the OSD.
 
If the script worked locally, then probably it did not work correctly during OSD or it failed to run. The log file should reveal more info on this.
 
The script works locally immediately. I've had the OSD running for about 2 hours now and it's still on the deleting folder task - it has no completed or deleted the folder. Additionally, it's dumped absolutely no info into the smsts.log file. Attached is the picture of my current task sequence step. I know it works when executed on the machine manually. The OSD TS step is not working though. I deleted the contents of the SMSTS.log beforehand so I'd all be applicable to this OSD, it is currently empty after having run for 2 hours.
 

Attachments

  • deke.PNG
    deke.PNG
    29 KB · Views: 3
I tried this instead:

Code:
cmd.exe /c rmdir c:\yourdir /s /q

And it worked well. I suppose my initial del command, as well as the powershell just didn't pan out for me.
 
Status
Not open for further replies.
Back
Top