Wednesday, September 3, 2008

Powershell Script To update links

Single line to deploy new shortcut to all workstations:
cat workstations.txt | ForEach-Object -process {copy-item 'shortcut.lnk' -destination "\\$_\c$\documents and settings\all users\start menu"}

If I was to work on this again I would want to add a line that would tell me what workstation was being worked on like the untested code below.  If the computer is turned off or not able to be connected then the error just shows up as "Copy-Item : The network path was not found" or "Copy-Item : Could not find a part of the path" without any indication of what workstation was failing.
cat workstations.txt | ForEach-Object -process {

write-host "Trying to connect to $_"; copy-item 'shortcut.lnk' -destination "\\$_\c$\documents and settings\all users\start menu"}

No comments:

Post a Comment