Asked by:
Pushing a script using SCCM does not work with folder shortcut.

Question
-
I have a script that creates a shortcut to a network drive folder that I am deploying through SCCM. The short cut gets created and works if I run it with PowerShell on my computer but when deployed using SCCM the target type is set as "File" instead of "File Folder" and does not work. Here is the script:
$SourceFileLocation = "S:\OR_Resources\"
$ShortcutLocation = "c:\users\public\desktop\OR Resources.lnk"
$WScriptShell = New-Object -ComObject WScript.Shell
$Shortcut = $WScriptShell.CreateShortcut($ShortcutLocation)
$Shortcut.TargetPath = $SourceFileLocation
$Shortcut.IconLocation = "C:\Windows\OR Resources.ico"
$Shortcut.Save()Any suggestions would be very helpful. Thank you
Friday, June 19, 2020 8:20 PM
All replies
-
Hi,
When you run the script in SCCM it runs under System Context, have you tested it that way as well on your computer? You can use Psexec.exe -i -s cmd.exe and then run your script.
Regards,
Jörgen
-- My Enterprise Mobility blog ccmexec.com -- Twitter @ccmexec
Monday, June 22, 2020 11:53 AM -
I do not find the Psexec.exe file on my system
Thursday, July 2, 2020 2:34 PM -
I do not find the Psexec.exe file on my system
Garth Jones
Blog: https://www.enhansoft.com/blog Old Blog: https://sccmug.ca/
Twitter: @GarthMJ Book: System Center Configuration Manager Reporting Unleashed
Thursday, July 2, 2020 4:24 PM -
Ok now. This is not exactly what I need. I am in a large healthcare network and this will not be allowed to run in our environment. I need a way to use PowerShell scripting to create a shortcut on client computers to a shared folder on a network mapped drive. When I run the script I have above locally on my computer it works fine.
Then when I push through SCCM I get this and it does not work.
I would send an image but the forum has not verified my account yet.
Thursday, July 2, 2020 6:41 PM -
Ok now. This is not exactly what I need. I am in a large healthcare network and this will not be allowed to run in our environment. I need a way to use PowerShell scripting to create a shortcut on client computers to a shared folder on a network mapped drive. When I run the script I have above locally on my computer it works fine.
Then when I push through SCCM I get this and it does not work.
I would send an image but the forum has not verified my account yet.
Garth Jones
Blog: https://www.enhansoft.com/blog Old Blog: https://sccmug.ca/
Twitter: @GarthMJ Book: System Center Configuration Manager Reporting Unleashed
Friday, July 3, 2020 1:24 PM -
Ok now. This is not exactly what I need. I am in a large healthcare network and this will not be allowed to run in our environment. I need a way to use PowerShell scripting to create a shortcut on client computers to a shared folder on a network mapped drive. When I run the script I have above locally on my computer it works fine.
Then when I push through SCCM I get this and it does not work.
I would send an image but the forum has not verified my account yet.
Garth Jones
Blog: https://www.enhansoft.com/blog Old Blog: https://sccmug.ca/
Twitter: @GarthMJ Book: System Center Configuration Manager Reporting Unleashed
Friday, July 3, 2020 1:25 PM -
I am creating a Package and deploying it to a collection of computers and running it as Administrator on the client machines. I have other shortcuts that work this way but the target on those are either files or URLs. This one is a network folder.
Monday, July 6, 2020 2:11 PM -
This one is a network folder.
Garth Jones
Blog: https://www.enhansoft.com/blog Old Blog: https://sccmug.ca/
Twitter: @GarthMJ Book: System Center Configuration Manager Reporting Unleashed
Monday, July 6, 2020 3:07 PM -
The shortcut gets created but does not work as Target Type under properties gets set to file and not file folder. This is happening on my test computer on which I am logged in with IT GPO and my network account login as admin. I do have access to the folder. Is there a way to force the target type?Monday, July 6, 2020 3:14 PM