【问题标题】:Copying folders and creating names from user accounts Powershell从用户帐户 Powershell 复制文件夹和创建名称
【发布时间】:2020-04-15 15:35:51
【问题描述】:
我正在尝试制作一个脚本,我可以将机器上所有用户的 Outlook sig 文件夹复制到基于帐户名的新文件夹中。所以文件夹会像
c\temp\Nathan\sig
c\temp\James\sig
这是我目前所拥有的
Copy-Item c:\Users\*\AppData\Roaming\Microsoft\Signatures -Recurse -destination c:\msp\$env:username
我假设星号会通过每个用户,但它不起作用。是否愿意分享如何使其正常工作?
【问题讨论】:
标签:
powershell
outlook
scripting
windows-10
【解决方案1】:
您需要将其分为两个步骤。
获取所有用户配置文件
如果那里有 Microsoft\Signatures 路径,请将其移至目的地。
这应该能让你继续前进。
$profiles = Get-ChildItem C:\Users -Directory
foreach ($profile in $profiles){
$signaturePath = "$($profile.FullName)\AppData\Roaming\Microsoft\Signatures"
"checking $signaturePath for user signatures..."
if (test-path $signaturePath){
$newPath = "c:\msp\$($profile.BaseName)"
"!!signature path found"
Copy-Item -Path $signaturePath -Recurse -Destination $newPath
}
else{
"--not found"
}
}