问题
I'd like a simple command to copy a shortcut for Devices and Printer.lnk
to All Users Profile Start Menu so that I can pin this shortcut to every users start menu that logs in to the Windows 10 PC at logon.
I've exported my start menu but having read up on it doesn't seem possible to pin the Devices and Printers shortcut in the normal fashion. This is why I've uploaded the shortcut to a network location that all users have access to, if I can copy this to a location on the PC that all users have access to then I can adjust my startmenu script so that it appears as a tile.
I can copy the shortcut to a basic location (the logged on user) but not to all users folder?
I thought that the following would work but doesn't:
Copy-Item -Path "\\Server\Share\*.lnk" -Destination "$env:allusersprofile\APPDATA\Microsoft\Windows\Start Menu\Programs"
Appreciate your help.
Edit: I have resolved the above issue however, it's lead me on to a follow on issue. I apply this script when a user logs in to Windows 10 but I then want to run a separate task (that is a part of the same ps1 file) which removes a whole host of Bloatware from the OS.
I've tried to add a ;
and additionally and but they both still require the user to login twice to complete both tasks. My full script at the moment is:
Copy-Item -Path "\\Server\Share\*.lnk" -Destination "$env:APPDATA\Microsoft\Windows\Start Menu\Programs"; $AppList = @( "*Microsoft.3dbuilder*" etc etc*" ) foreach ($App in $AppList) { Get-AppxPackage -Name $App | Remove-AppxPackage -ErrorAction SilentlyContinue }
I've added "etc etc" as there's a load of commands below that I won't include that remove the bloatware.
回答1:
You need to remove APPDATA
from Destination
and it should work. Use following code:
Copy-Item -Path "\\Server\Share\*.lnk" -Destination "$env:ALLUSERSPROFILE\Microsoft\Windows\Start Menu\Programs"
来源:https://stackoverflow.com/questions/54706625/powershell-command-to-copy-from-network-location-to-all-users-profile