Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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?

share|improve this question
    
it seems when i dont't use C:\WINDOWS\system32\WindowsPowerShell\v1.0\powershell.exe -file in the target, I do get a target in the lnk file, but it does not execute the script... –  user2961029 Dec 10 '13 at 11:43
    
Creating a symlink requires admin level on windows, and the link target must exist. There are multiple types of them, one is similar to hardlink, one is to bind-mounts, and the third is the normal symlink. You know: hope it helps :-) –  Peter Horvath Dec 10 '13 at 13:50

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.