Powershell的新手 - 创建目录和复制文件 [英] Newbie to Powershell - Create Directory and copy files
本文介绍了Powershell的新手 - 创建目录和复制文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我目前正在尝试执行以下操作
I am currently trying to do the following
- 在c:\ProgramData \ Mysoftoft \ Windows中创建一个新目录
- 将图标文件复制到该文件夹
- 将.lnk文件复制到所有用户桌面
如果我运行创建目录步骤在运行中成功分开
If I run the create directory step separate in runs successfully
如果我单独运行复制步骤,则运行
If I run the copy steps separately they run
组合时脚本不运行?
# Create TBIcons Folder
$path= "C:\ProgramData\Microsoft\Windows\TBIcons"
If(!(test-path $path))
{
New-Item -ItemType Directory -Force -Path $path
}
$UserFolders= Get-ChildItem C:\Users
Foreach($UserFolder in $UserFolders)
{
Copy-Item ".\TBLearn.ico" -Destination "C:\ProgramData\Microsoft\Windows\TBIcons"-Force
# Copy new shortcut
Copy-Item ".\TrueBlue Learning Library.lnk" -Destination "C:\Users\$UserFolder\Desktop" -Force
}
DHeinz
推荐答案
为什么在使用GPO时使用脚本?
Why use a script when you can use a GPO?
这篇关于Powershell的新手 - 创建目录和复制文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文