Create a HTML file on Desktop with top 10 process running on your system, if that file already exists on Desktop it will give prompt to user to recreate that file.


#Name: Richa Sharma
#Create a HTML file on Desktop with top 10 process running on your system, if that file already #exists on Desktop it will give prompt to user to recreate that file.
#Action required: Change the path <Desktop path name> according to your requirement.

 

 

$path="C:\Users\azuser84\Desktop\process.html"

$isFilesExists = Test-path $path

 

if($isFilesExists -eq $true)

{

   

    $ans= Read-Host "Do you want to recreate (Y/N)"

        if($ans -eq "Y")

        { 

           

            Remove-Item -Path $path

            
Get-Process | select -First 10 | ConvertTo-Html | Out-File -FilePath <Desktop path name>

 

        }

 

        Else 

        

        {


        Write-Warning "No action will be taken care"

 

        }

}

 

Else{

 
    Get-Process | select -First 10 | ConvertTo-Html | Out-File - <Desktop file name>

 

}

Comments

Popular posts from this blog