【发布时间】:2014-08-01 18:12:00
【问题描述】:
当我运行下面的脚本时,我得到了:
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
}}
【问题讨论】:
-
您想启动该行以由简单的命令解析器解析(我认为这是正确的术语,Keith Hill 会知道的)。执行
PSExec.exe --% @c:\computers.txt gpupdate.exe /target:user /force看看是否能解决问题。 -
@TheMadTechnician 谢谢——虽然它仍然给我相同的输出,但它不起作用。就像它认为列表中的第一台计算机是共享位置一样。列表中的第一个是:BR-TELL-01 如果有帮助的话
标签: powershell active-directory