Link to home
Start Free TrialLog in
Avatar of cwstad2
cwstad2Flag for United Kingdom of Great Britain and Northern Ireland

asked on

Powershell copy shortcut and point to other server

Hi guys i have the following code below which works great for copying FF to the servers in the txt file. However id like to go one step further and copy the shortcut for the FF.exe to another server. What would be the best way to achieve this.

Thanks in advance.

$servers =Get-Content "C:\Users\Downloads\exchange.txt"

foreach ( $servers1 in $servers ) {

 $copy = Copy-Item -Path C:\FirefoxPortable -Filter *.* -Destination "\\$servers1\c$\it" -Recurse

 }
Avatar of Dan Craciun
Dan Craciun
Flag of Romania image

$WshShell = New-Object -comObject WScript.Shell
 $Shortcut = $WshShell.CreateShortcut("\path\to\shortcut)
 $Shortcut.TargetPath = "\path\to\target"
 $Shortcut.Save()


HTH,
Dan
Avatar of cwstad2

ASKER

Hi Dan its a little bit complicated so i will give more details. im copying from server1 for example to london1 which is where the full app will be and the shortcut will be copied to london2 and london3 for example. But there are many other sites for example so would i need 1 txt file with all of the 2 and 3 servers but how will they point to server1 of that site. Each 2 and 3 server has to point to the shortcut on server1 for that site. Hope this makes sense
OK, please post a sample of your exchange.txt so I can get an idea of the hierarchical data.
Avatar of cwstad2

ASKER

for example this is whats in the exchange.txt file. but on each site there is a 2 and 3 server. so the shortcuts would need to be to london2 and london3 for example but ref back to the .exe on london1

london1
newyork1
paris1
Avatar of cwstad2

ASKER

is this even possible?
ASKER CERTIFIED SOLUTION
Avatar of Qlemo
Qlemo
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of cwstad2

ASKER

excellent thanks