Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ## USER VARIABLES
- $vhdSharePath = "\\DOMAIN.LOCAL\dfsroot$\ostvhd" ## Path To OST Files
- ## GLOBAL VARIABLES Start ##
- $userName = $env:USERNAME
- $userDomain = $env:USERDOMAIN
- $secUser = New-Object System.Security.Principal.NTAccount($userName)
- $userSID = $secUser.Translate([System.Security.Principal.SecurityIdentifier])
- $vhdFileName = $userName + "_EMCache.vhd"
- $vhdUserDirectoryName = $userName + "_" + $userSID
- $vhdDirectoryPath = $vhdSharePath + "\" + $vhdUserDirectoryName
- $vhdPath = $vhdDirectoryPath + "\" + $vhdFileName
- $workingDir = $env:USERPROFILE + "\AppData\Local\Temp\VHDCache"
- $filesystemlabel = $userName + "_EMcache"
- $outlookDir = $env:USERPROFILE + "\AppData\Local\Microsoft\Outlook"
- ## GLOBAL VARIABLES End ##
- ## UNMOUNT Start ##
- $mountPath = Join-Path -Path $workingDir -ChildPath VHD
- mountvol.exe $mountPath /d
- Remove-Item -Path "$workingDir" -Force -Recurse
- $cmd = @"
- Select vdisk file=$vhdPath
- detach vdisk
- exit
- "@
- $cmd | diskpart | Out-Null
- cmd.exe /C rd $outlookDir
- ## UNMOUNT End ##
Advertisement
Add Comment
Please, Sign In to add comment