Quantcast
Channel: The Official Scripting Guys Forum! forum
Viewing all articles
Browse latest Browse all 15028

powershell script to delete files works with 64bit dosent delete folders with 32bit

$
0
0
Invoke-Command -ComputerName      -Credential  -ScriptBlock {


$fileToCheck = "$env:LOCALAPPDATA\Microsoft\Windows Live Mail"

$fileToCheck2 = "$env:APPDATA\Thunderbird\profiles.ini"

$fileToCheck3 = "C:\program files (x86)\windows live\installer\wlarp.exe"

$fileToCheck4 = "C:\program files\windows live\installer\wlarp.exe"

if((get-process "wlmail" -ea SilentlyContinue) -eq $Null)
{ 

    if ((Get-WmiObject win32_operatingsystem | select osarchitecture).osarchitecture -like "64*")
{
#64bit code here
Write-Output 64bit

if (test-path -LiteralPath "$fileToCheck3") 
{
cmd.exe /C "$fileToCheck3" /cleanup:all /q /w
}

    if (Test-Path -LiteralPath "$fileToCheck") 
    {
     Write-Output Del user files 64bit 
     cmd.exe /c rmdir /Q /S "$fileToCheck"
    }
}
else
{
#32bit code here
Write-Output 32bit

if (test-path -LiteralPath $fileToCheck4) 
{   
 cmd.exe /C $fileToCheck4 /cleanup:all /q /w
} 

    if (Test-Path "$fileToCheck") 
    {
     Write-Output Del user files 32bit 
     cmd.exe /c rmdir /Q /S "c:\Users\Kauplus\AppData\Local\Microsoft\Windows Live Mail"
    }
}
}
else
{ 
    Stop-Process -Name wlmail 
if ((Get-WmiObject win32_operatingsystem | select osarchitecture).osarchitecture -like "64*")
{
#64bit code here
Write-Output 64bit wlmain 

  if (test-path -LiteralPath "$fileToCheck3") 
  {
  cmd.exe /C "$fileToCheck3" /cleanup:all /q /w
  }

    if (Test-Path -LiteralPath "$fileToCheck") 
    {
     Write-Output Del user files 64bit 
     cmd.exe /c rmdir /Q /S "$fileToCheck"
    }
}
else
{
#32bit code here
Write-Output 32bit  wlmain 

if (test-path -LiteralPath "$fileToCheck4") 
    {
     cmd.exe /C "$fileToCheck4" /cleanup:all /q /w
    } 

    if (Test-Path -LiteralPath "$fileToCheck") 
    {
     Write-Output Del user files 32bit 
     cmd.exe /c rmdir /Q /S "$fileToCheck"
    }
}
 }
 }




Viewing all articles
Browse latest Browse all 15028

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>