PortValhalla/scripts/Common/Scripts/System.ps1

32 lines
718 B
PowerShell
Raw Normal View History

2024-08-05 18:07:39 +00:00
<#
.SYNOPSIS
Creates a new temporary directory.
#>
function New-TemporaryDirectory {
$path = Join-Path ([System.IO.Path]::GetTempPath()) ([System.IO.Path]::GetRandomFileName());
New-Item -ItemType Directory $path;
}
<#
.SYNOPSIS
Removes desktop icons which apply to the specified pattern.
.PARAMETER Pattern
The pattern to match the icons to delete.
#>
function Remove-DesktopIcon {
param(
[string] $Pattern
)
$path = "Desktop/$Pattern";
2024-08-06 10:21:00 +00:00
foreach ($userDir in @("~", $env:PUBLIC, "$env:SystemDrive/Users/Default")) {
$fullName = "$userDir/$path";
if (Test-Path -PathType Leaf $fullName) {
Remove-Item $fullName;
}
}
}