Powershell 删除符号链接窗口 [英] Powershell Remove Symbolic Link Windows

查看:71
本文介绍了Powershell 删除符号链接窗口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在删除使用 New-Item 创建的 SymbolicLink 时遇到问题:

I am having issues when removing SymbolicLinks which I have created with New-Item:

New-Item -ItemType SymbolicLink -Path C:\SPI -Target "C:\Users\Chino\Dropbox (Reserve Membership)\"

我需要修改链接,因为它有错误的-Target,应该是:

I need to modify the link because it has the wrong -Target, which should be:

New-Item -ItemType SymbolicLink -Path C:\SPI -Target "C:\Users\Chino\Dropbox (Reserve Membership)\SPI"

如何删除该链接并分配一个新链接?或者,如何更新现有链接的目标路径?

How to remove that link and assign a new one? Alternatively, how to update the target path of the existing link?

推荐答案

在相应的 DirectoryInfo 对象上调用 Delete() 应该可以解决问题:

Calling Delete() on the corresponding DirectoryInfo object should do the trick:

(Get-Item C:\SPI).Delete()
New-Item -ItemType SymbolicLink -Path C:\SPI -Target "C:\Users\Chino\Dropbox (Reserve Membership)\SPI"

这篇关于Powershell 删除符号链接窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆