31 lines
718 B
PowerShell
31 lines
718 B
PowerShell
<#
|
|
.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";
|
|
|
|
foreach ($userDir in @("~", $env:PUBLIC, "$env:SystemDrive/Users/Default")) {
|
|
$fullName = "$userDir/$path";
|
|
|
|
if (Test-Path -PathType Leaf $fullName) {
|
|
Remove-Item $fullName;
|
|
}
|
|
}
|
|
}
|