I'm trying to create a symbolic link with mklink through a Powershell script to a Powershell script on a remote server. this link should come on the desktop of all users.
if(!(test-path -path \$hostname\c$\Users)) { Copy-Item -Path "\dsfpad\Nagios\Nagios_Downtime\Nagios - Schedule Downtime.lnk" -Destination "\$hostname\c$\Documents and Settings\All Users\Desktop\Nagios - Schedule Downtime.lnk" } else { $s=New-PSSession -ComputerName $hostname Enter-PSSession $s Invoke-Command -Session $s -ScriptBlock {& cmd /c mklink "C:\Users\Public\Desktop\Nagios - Schedule Downtime.lnk" "C:\WINDOWS\system32\WindowsPowerShell\v1.0\powershell.exe -file c:\Nagios\Nagios_Downtime_Window_NRDP.ps1"} exit-pssession
remove-pssession $s }
I get symbolic link created for C:\Users\Public\Desktop\Nagios - Schedule Downtime.lnk <<===>> C:\WINDOWS\system32\WindowsPowerShell\v1.0\po wershell.exe -file c:\Nagios\Nagios_Downtime_Window_NRDP.ps1
But when I try to execute the link on a server, it doesn't work. looking at the Target of the link, therer seems to be no target...
Any tips / ideas?