Forum Discussion
Rob_Lam
Sep 06, 2024Brass Contributor
How to combine 4 scripts into 1?
Hi I'm trying to use Intune to deploy microsoft apps icons onto the desktop At the moment I have 4 scripts for Outlook,Word,PowerPoint and OneNote $TargetFile = "C:\Program Files\Microsoft O...
- Sep 06, 2024
Rob_Lam Saving everything in one .ps1 file will work, but you can also use this :
$shortcuts = @{ Outlook = "C:\Program Files\Microsoft Office\root\Office16\OUTLOOK.exe" OneNote = "C:\Program Files\Microsoft Office\root\Office16\ONENOTE.exe" PowerPoint = "C:\Program Files\Microsoft Office\root\Office16\POWERPNT.exe" Word = "C:\Program Files\Microsoft Office\root\Office16\WINWORD.exe" } foreach ($shortcut in $shortcuts.GetEnumerator()) { $TargetFile = $shortcut.Value $DesktopPath = [Environment]::GetFolderPath("Desktop") $ShortcutFile = "$DesktopPath\$($shortcut.name).lnk" $WScriptShell = New-Object -ComObject WScript.Shell $Shortcut = $WScriptShell.CreateShortcut($ShortcutFile) $Shortcut.TargetPath = $TargetFile $Shortcut.Save() }
Sep 06, 2024
Rob_Lam Saving everything in one .ps1 file will work, but you can also use this :
$shortcuts = @{
Outlook = "C:\Program Files\Microsoft Office\root\Office16\OUTLOOK.exe"
OneNote = "C:\Program Files\Microsoft Office\root\Office16\ONENOTE.exe"
PowerPoint = "C:\Program Files\Microsoft Office\root\Office16\POWERPNT.exe"
Word = "C:\Program Files\Microsoft Office\root\Office16\WINWORD.exe"
}
foreach ($shortcut in $shortcuts.GetEnumerator()) {
$TargetFile = $shortcut.Value
$DesktopPath = [Environment]::GetFolderPath("Desktop")
$ShortcutFile = "$DesktopPath\$($shortcut.name).lnk"
$WScriptShell = New-Object -ComObject WScript.Shell
$Shortcut = $WScriptShell.CreateShortcut($ShortcutFile)
$Shortcut.TargetPath = $TargetFile
$Shortcut.Save()
}