[英]Powershell logon script remove item
I have a logon script that does the following: 我有一个执行以下操作的登录脚本:
$user = $env:username
remove-item -path c:\users\$user\appdata\local\FOLDER -recurse
It gets the username and removes a specific folder in the appdata of the user. 它获取用户名并删除用户的appdata中的特定文件夹。
If I run this in the session of the user ( without elevated rights ) using powershell
, it works. 如果我使用powershell
在用户会话中( 没有提升的权限 )运行此命令,它将起作用。 However, if I run it via login script, it doesn't work. 但是,如果我通过登录脚本运行它,则无法使用。 The script itself runs since other code ran correctly. 该脚本本身运行,因为其他代码正确运行。
What am i doing wrong? 我究竟做错了什么?
Try -Force switch if it helps. 如果有帮助,请尝试-Force开关。
$user = $env:username
remove-item -path c:\users\$user\appdata\local\FOLDER -recurse -Force
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.