"GFI Script - Add Website shortcut link to All users Desktop"

I need to add a shortcut to a website to all users desktop.

created 1 month ago
bksnow2
 1 1
You must be signed in before you can post a fix
Scripting Language: PowerShell

Here is a Powershell script that I use for deployment of a new remote PC. All of our client servers and workstations have a folder on the c: drive to store misc scripts and tools and there for our use only. While it creates the folder, it also creates a URL shortcut on the desktop to our help page. This script also downloads our favicon and stores it in the new folder to reference for the shortcut. The process renames the favicon to whatever you want to save it as or you can keep the name.


$source = "http://somesite.com/favicon.ico"
$targetroot = "c:\mcgadmin"
$icon = "c:\mcgadmin\ico\mcgtech.ico"
$URL = "http://www.somesite.com"
if( -Not (Test-Path -Path $targetroot ) )
{
    New-Item -ItemType directory -Path $targetroot
}

if( -Not (Test-Path -Path $targetroot\ico ) )
{
    New-Item -ItemType directory -Path $targetroot\ico
}
Invoke-WebRequest $source -OutFile $icon

$shortcut_name = "MCGtech"
$shortcut_target = $URL 
$sh = new-object -com "WScript.Shell"
$p = $sh.SpecialFolders.item("AllUsersDesktop")
$lnk = $sh.CreateShortcut( (join-path $p $shortcut_name) + ".lnk" )
$lnk.TargetPath = $shortcut_target
$lnk.Description  = "Shortcut to MCGtech Site"
$lnk.IconLocation = $icon
$lnk.Save()
created 5 hours ago
MyOwnBoss
 1 1
modified 5 hours ago
Scripting Language: PowerShell

Hello,

This should do that you're looking for. This has been tested on a Windows 10 machine as well.

This will copy a file from a UNC path as the source and place it on every users Desktop.

Edit: You may also want to be wary of any permissions on the source file as I believe the copy will bring over and specified permissions as well so I would make sure to copy them from a public share.


$Users = Get-ChildItem C:\Users\ -Exclude "Administrator","Public","Default*" # Exclude any other defaults that you don't want.

    foreach($User in $Users.name){
    $Path = "C:\Users\$User\Desktop";
    Copy-Item -Path "\\Path\To\Source\File.url" -Destination $Path\File.url
    }
created 1 month ago
m.Polselli
 70 1 9

► Have questions?

► Something not working?

► Suggestions?

Post your questions on the meta site, where we discuss everything related to FixIT Scripts

visit meta now»