2016-09-29 3 views
0

Я пытаюсь скопировать файл с сервера на компьютер для автоматической установки Microsoft Office 2010. При попытке использовать часть CopyItem появляется следующая ошибка.Скрипт Powershell для установки Microsoft 2010

Start-Service : Service 'Remote Registry (remoteregistry)' cannot be started due to the following error: Cannot open remoteregistry service on computer 'IT-PCName'. 
At line:21 char:54 
+ Get-Service remoteregistry -ComputerName $computer | Start-Service 
+              ~~~~~~~~~~~~~ 
    + CategoryInfo   : OpenError: (System.ServiceProcess.ServiceController:ServiceController) [Start-Service], ServiceCommandException 
    + FullyQualifiedErrorId : CouldNotStartService,Microsoft.PowerShell.Commands.StartServiceCommand 

(Ну, я просто понял, выше ошибка происходит потому, что имя компьютера и имя пользователя отличаются, так что позаботилась этой ошибки, но сценарий все еще не работает, потому что я не знаю, как эта линия должна читать $InstallString = '"C:\windows\temp\Office 2010\setup.exe" /adminfile Updates/OfficeSetup.MSP /config ProPlus.WW/config.xml"')

Это мой код, который до сих пор копирует Office 2010 на компьютер для автоматического запуска установки.

ForEach ($computer in (GC (Get-FileName -InitialDirectory $env:USERPROFILE\Desktop -Filter "Text files (*.txt)|*.txt|All files (*.*)|*.*"))) { 

    $filepath = Test-Path -Path "\\$computer\C:\Program Files (x86)\Microsoft Office" 
     If ($filepath -eq $false) 
     { 
    Get-Service remoteregistry -ComputerName $computer | Start-Service 
     Copy-Item -Path "\\server\Orig\Install\Office2010" -Destination "\\$computer\c$\windows\temp\" -Container -Recurse -Force 
} 
} 

После того, как файл будет передан на компьютер я думаю что я мог сделать что-то вроде этого

ForEach ($computer in (GC (Get-FileName -InitialDirectory $env:USERPROFILE\Desktop -Filter "Text files (*.txt)|*.txt|All files (*.*)|*.*"))) { 

$filepath = Test-Path -Path "\\$computer\C:\Program Files (x86)\Microsoft Office" 
    If ($filepath -eq $false) 
    { 
Get-Service remoteregistry -ComputerName $computer | Start-Service 
    Copy-Item -Path "\\server\Orig\Install\Office2010" -Destination "\\$computer\c$\windows\temp\" -Container -Recurse -Force 
    $InstallString = '"C:\windows\temp\Office 2010\setup.exe" /adminfile Updates/OfficeSetup.MSP /config ProPlus.WW/config.xml"' 
    ([WMICLASS]"\\$computer\ROOT\CIMV2:Win32_Process").Create($InstallString) 

    "$computer" + "-" + "(Get-Date)" | Out-File -FilePath "\\server\Orig\Install\RemoteInstallfile.txt" -Append 
    } 
    Else 
    { 
    "$computer" + "_Already_Had_Software_" + "(Get-Date)" | Out-File -FilePath "\\server\Orig\Install\RemoteInstallfile.txt" -Append 
    } 
} 

ответ

0

Похоже, вы только что дополнительный "после config.xml

$InstallString = '"C:\windows\temp\Office 2010\setup.exe" /adminfile Updates/OfficeSetup.MSP /config ProPlus.WW/config.xml' 
Смежные вопросы