我试图递归地将配置文件添加到以下路径中:C:\Users*\AppData\Roaming\
目前我的代码如下:
#Sets config file as source.
$Source = "$dirFiles\NewAgentAP\AgentAP.cfg"
#Recursive copying of a file to specific folder destination.
$Destination = 'C:\Users\*\AppData\Roaming\Trio\Trio Enterprise'
Get-ChildItem $Destination | ForEach-Object {Copy-Item -Path $Source -Destination $_ -Force}
如果用户还没有路径,我希望powershell脚本能够为每个用户添加路径,并随后添加.cfg文件。我已经尝试搜索此问题,但没有找到解决方法。
'C:\Users\*\'
作为路径,似乎可以正常工作。问题似乎是一些用户有一个 AppData 文件夹,而其他用户没有,因此脚本无法继续。如果我提供一个已经存在的路径,它就像魔术般地工作。谢谢。 - Rainoa