-
Notifications
You must be signed in to change notification settings - Fork 7.6k
New-Item symlinks cannot be created if destination (target) is non-existent or not accessible #9067
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I think this issue might have to do with symbolic links need to know if it is a directory or a file based symlink. MKLINK requires specifying the purpose of the symbolic link. PowerShell is probably trying to find the target so that it can determine the type of link from the target. That doesn't work when the target cannot be accessed at that time. I also tested creating a symbolic link to a non-existent server via a UNC path and got the same results, except that it could not find 'the network path', so I don't think it has to do with drives as I originally though. This might require new enumerations for -itemtype (type) to bypass the target lookup. I imagine this is not required for unix, and so this is probably a Windows only issue. |
#2915 seems to have a good read on this … but I am not sure what happened along the way. |
This is what happened (quoting @joeyaiello):
The status quo:
As you state, a proper fix requires some way to explicitly indicate the type of a nonexistent target (and, indeed, it wouldn't be required on Unix-like platforms). Building on your idea to introduce new
|
Some thoughts:
|
Good points, @msftrncs.
|
Hi. Thank you for your answer. Best regards Jean-Marc |
When you create a symbolic link to a unicorn, you cannot make a note of when said unicorn recently pooped. |
@jmg69, that's not how the filesystem works; symlinks have their own last-write timestamps (which never change, unless you recreate the symlink). Therefore, you must manually determine the target file (assuming it exists) and then query its properties: $symlinkPath = './foo'
Get-Item (Get-Item $symlinkPath).Target # use (...).LastWriteTime to get just the last-write time If a given path may or may not be a symlink: $potentialSymlinkPath = './foo'
($item = Get-Item $potentialSymlinkPath).Target ? (Get-Item $item) : $item But please note that this issue is about symlinks with non-existent targets.
|
This issue has not had any activity in 6 months, if this is a bug please try to reproduce on the latest version of PowerShell and reopen a new issue and reference this issue if this is still a blocker for you. |
2 similar comments
This issue has not had any activity in 6 months, if this is a bug please try to reproduce on the latest version of PowerShell and reopen a new issue and reference this issue if this is still a blocker for you. |
This issue has not had any activity in 6 months, if this is a bug please try to reproduce on the latest version of PowerShell and reopen a new issue and reference this issue if this is still a blocker for you. |
This issue has been marked as "No Activity" as there has been no activity for 6 months. It has been closed for housekeeping purposes. |
Steps to reproduce
Because I have to execute this as an administrator, my Z: drive is not attached, and so PowerShell responds with an error.
It appears this was thought to be fixed in #801, but evidently it didn't include non-existent drives.
Instead I have to resort to CMD MKLINK.
Environment data
Edit 1: fixed spellings, changed parameter to '-target'.
The text was updated successfully, but these errors were encountered: