Jump to content

Recommended Posts

Posted

Simple as it says really.

 

Is this safe to do?

 

Someone built a deployment on a site we look after and some muppett left half a gig of files in the default users download folder.

 

Que filled hard drives with 6gb of service accounts.

 

Can I just delete the files from the .wim, as all they are is a handful of unused .exe files?

Posted
Yes, as long as the files are not required by the OS

 

Mount, delete, commit and unmount.

 

Given what these are, exe's for paint.net etcm could i be as lazy as to open the archive with 7zip and delete them?

Posted
Is this safe to do?

Never tried 7-Zip, but it's easy enough to do using a PowerShell script and at least you would know your image would still work afterwards. :)

 

#Requires -Version 5.0
#Requires -RunAsAdministrator
#Requires -Modules Dism

# Get script directory
if ($myInvocation.MyCommand.CommandType -ne [system.Management.Automation.CommandTypes]::Script) {
$ScriptDir = [system.IO.Path]::GetDirectoryName($myInvocation.MyCommand.Definition)
} else {
$ScriptDir = [system.IO.Path]::GetDirectoryName($psISE.CurrentFile.FullPath)
}
Set-Location "$ScriptDir"

$Image = "$ScriptDir\install.wim"
$MountFolder = "$ScriptDir\Mount"

if (!(Test-Path -path $MountFolder)) {
New-Item -Path $MountFolder -ItemType Directory -Force | Out-Null
}

Mount-WindowsImage -ImagePath $Image -Index 1 -Path $MountFolder

Remove-Item "$ScriptDir\Mount\Users\Default\Downloads\*" -Recurse -Force

Dismount-WindowsImage -Path $MountFolder -Save

 

Note. Place .ps1 script into the same folder as the install.wim and then run. Make a copy of the image just in case though.

  • Thanks 1

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now



×
×
  • Create New...