当我在下面运行下面的脚本时,我得到的是:
PsExec v2.11 - 远程执行进程 版权所有(C)2001-2014 Mark Russinovich Sysinternals - www.sysinternals.com
\■B: 无法访问■B: 找不到网络路径。 确保在■B。
上启用了默认的admin $共享我检查了computers.txt列表是否有效(故意将其设置为仅运行一个以进行测试)
以下是代码:
# refresh gp for logged in user
param(
$ouInfo
)
#make computer list
cls
Write-Host "Group Policy Update for User(s) on Remote Computer(s)`nBy xxxx`r" -ForegroundColor Yellow
$manOrAuto = Read-Host = "Enter computer name(s) Manually or Import from location? (m or i)"
if ($manOrAuto -eq "m")
{
New-Item c:\computers.txt -type file -Force
cls
Write-Host "Group Policy Update for User(s) on Remote Computer(s)`nBy Tom Gipson - txxxxx@xxxx`r" -ForegroundColor Yellow
do {
$computarList = Read-Host "Enter the name of the computer or IP address:"
[string]$addSitesToList = "`r" + $computarList + "`r`n"
Add-Content -Path c:\computers.txt -Value $addSitesToList
Read-Host [string]$runAgain = "Add another? (y or n)"
} while ($runAgain -eq "y")
#update gp for logged in user
Psexec.exe @c:\computers.txt Gpupdate.exe /Target:User /force
}
else {if ($manOrAuto -eq "i"){
#get list of computers from AD
New-Item c:\computers.txt -type file -Force
cls
Write-Host "Group Policy Update for User(s) on Remote Computer(s)`nBy xxxxxx - txxxx@vxxxxxx`r" -ForegroundColor Yellow
#get location
Write-Host "Locations:`r" -ForegroundColor Yellow
Write-Host "xxxx`mxxxx`nxxxx`netc`n`r" -ForegroundColor Cyan
$branchLocation = Read-Host "Enter the location from the list above and hit enter:"
$ouInfoPrefix = "'OU=xxxxxxx,OU="
$ouInfoSuffix = ",OU=xxxxx,OU=xxxxxx,dc=xxxxxxx,dc=local'"
[string]$ouInfo = $ouInfoPrefix + $branchLocation + $ouInfoSuffix
Get-ADComputer -SearchBase 'OU=Computers,OU=xxxxxx,OU=xxxxxx,OU=vxxxxx,dc=xxxxxx,dc=local' -Filter '*' | Select -Expand Name | Out-File c:\computers.txt
Start-Sleep -Seconds 1
Psexec.exe @c:\computers.txt cmd /c Gpupdate.exe /force
}}
答案 0 :(得分:0)
我能够通过强制将文件外编码转换为ASCII(默认为Unicode)
来解决此问题out-file -encoding ASCII