forked from gangstanthony/PowerShell
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGet-Shortcut.ps1
38 lines (33 loc) · 828 Bytes
/
Get-Shortcut.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# Get-Shortcut
#
# Arguments
# Description
# FullName
# Hotkey
# IconLocation = '%SystemRoot%\system32\SHELL32.dll,16' # printer
# RelativePath
# TargetPath
# WindowStyle
# WorkingDirectory
function Get-Shortcut {
param (
[parameter(mandatory=$true)]
[string]$Path
)
begin {
$WshShell = New-Object -ComObject WScript.Shell
}
process {
if (!$Path) {Throw 'No Source'}
$Shortcut = $WshShell.CreateShortcut($Path)
$Shortcut | select *
}
end {
function Release-Ref ($ref) {
([System.Runtime.InteropServices.Marshal]::ReleaseComObject([System.__ComObject]$ref) -gt 0)
[System.GC]::Collect()
[System.GC]::WaitForPendingFinalizers()
}
$Shortcut, $WshShell | % {$null = Release-Ref $_}
}
}