Private/Remove-HPSTmpFile.ps1
Function Remove-HPSTmpFile { <# .SYNOPSIS n/a .DESCRIPTION n/a .PARAMETER Extension n/a .EXAMPLE Remove-HPSTmpFile -Path "C:\Windows\Temp\cc20c224-85bb-4008-b3dd-25d732fa7d98.inf" .INPUTS System.String .LINK https://hardening.thomas-illiet.fr/Private/Remove-HPSTmpFile/ .LINK https://github.com/thomas-illiet/Hardening/blob/stable/Hardening/Private/Remove-HPSTmpFile.ps1 .NOTES - File Name : Remove-HPSTmpFile.ps1 - Author : Thomas ILLIET #> [CmdletBinding( HelpUri = "https://hardening.thomas-illiet.fr/Private/Remove-HPSTmpFile/" )] [OutputType( [System.Void] )] Param( [Parameter(Mandatory = $true)] [System.String] $Path ) begin { Write-Verbose "[$($MyInvocation.MyCommand.Name)] Function started" } process { $TempPath = [System.IO.Path]::GetTempPath() if ( (Test-Path -Path $Path) -and ( $Path -like "${TempPath}*" ) ) { Remove-Item -Path $Path -Force } } end { Write-Verbose "[$($MyInvocation.MyCommand.Name)] Complete" } } |