Skip to content

Commit 0d36ebb

Browse files
committedJul 22, 2020
Add latest prepackaged 'CreateDesktopIcon.ps1' files
1 parent b6b848e commit 0d36ebb

File tree

4 files changed

+47
-8
lines changed

4 files changed

+47
-8
lines changed
 
3.24 KB
Binary file not shown.

‎IntuneShortcut/Readme.md

+1-6
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,8 @@
1-
# Create Desktop shortcuts with Microsoft Intune
21

3-
![Demo](https://tech.nicolonsky.ch/content/images/2019/07/Intune-Create-Desktop-Shortcut.gif)
4-
5-
[Find a full post and desciption on my blog](https://tech.nicolonsky.ch/intune-create-desktop-shortcut/)
2+
Create Desktop shortcuts with Microsoft Intune. [Find a full post and desciption on my blog](https://tech.nicolonsky.ch/intune-create-desktop-shortcut/)
63

74
Create and remediate desktop and start menu shortcuts with Microsoft Intune using Win32 app deployment. Because with OneDrive Known Folder Move the Desktop is not stored in the default user profile location we need to resolve it with the ```[Environment]::GetFolderPath("Desktop")``` method.
85

9-
Usage: ```CreateDesktopIcon.exe -ShortcutTargetPath "%ProgramFiles(x86)%\Microsoft\Edge Dev\Application\msedge.exe" -ShortcutDisplayName "nicolonsky tech" -IconFile "https://tech.nicolonsky.ch/favicon.ico" -ShortcutArguments "https://tech.nicolonsky.ch"```
10-
116
## Quick Overview
127

138
* This solution works with OneDrive Known Folder Move

‎IntuneShortcut/Remove-CreateDesktopIcon.ps1

-2
This file was deleted.

‎IntuneShortcut/RemoveDesktopIcon.ps1

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
[CmdletBinding()]
2+
Param (
3+
[Parameter(Mandatory=$true)]
4+
[String]$ShortcutDisplayName
5+
)
6+
7+
#check if running as system
8+
function Test-RunningAsSystem {
9+
[CmdletBinding()]
10+
param()
11+
process{
12+
return ($(whoami -user) -match "S-1-5-18")
13+
}
14+
}
15+
16+
function Get-DesktopDir {
17+
[CmdletBinding()]
18+
param()
19+
process{
20+
if (Test-RunningAsSystem){
21+
$desktopDir = Join-Path -Path $env:PUBLIC -ChildPath "Desktop"
22+
}else{
23+
$desktopDir=$([Environment]::GetFolderPath("Desktop"))
24+
}
25+
return $desktopDir
26+
}
27+
}
28+
29+
function Get-StartDir {
30+
[CmdletBinding()]
31+
param()
32+
process{
33+
if (Test-RunningAsSystem){
34+
$startMenuDir= Join-Path $env:ALLUSERSPROFILE "Microsoft\Windows\Start Menu\Programs"
35+
}else{
36+
$startMenuDir="$([Environment]::GetFolderPath("StartMenu"))\Programs"
37+
}
38+
return $startMenuDir
39+
}
40+
}
41+
42+
# Remove icon from desktop
43+
Remove-Item -Path $(Join-Path $(Get-DesktopDir) "$ShortcutDisplayName.lnk") -EA SilentlyContinue;
44+
45+
# Remove icon from start
46+
Remove-Item -Path $(Join-Path $(Get-StartDir) $"$ShortcutDisplayName.lnk") -EA SilentlyContinue

0 commit comments

Comments
 (0)