locked
Acceso denegado RRS feed

  • Question

  • Hi, I am trying to run a script from one computer to another within the same network and it gives me denied access

    the script what it does is the installation of some applications

    This is a Error

    Acceso denegado
        + CategoryInfo          : NotSpecified: (Acceso denegado:String) [], RemoteException
        + FullyQualifiedErrorId : NativeCommandError
        + PSComputerName        : rwood-old
     
    En l¡nea: 1 Car cter: 1
    + \\spuga1\InstaladoresTravel\TurboSabre2014Setup.exe /silent /install
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : OperationStopped: (:) [], UnauthorizedAccessException
        + FullyQualifiedErrorId : System.UnauthorizedAccessException
    NotSpecified: (:) [], RemoteException

    $servers = Get-Content C:\Temp\servers.txt $source = "\\spuga1\InstaladoresTravel\" $dest = "C$" $testPath1 = "\\spuga1\InstaladoresTravel\TurboSabre2014Setup.exe" $testPath2 = "\\spuga1\InstaladoresTravel\Firefox_install.exe" $testPath3 = "\\spuga1\InstaladoresTravel\AcrobatRider_install.exe" $testPath4 = "\\spuga1\InstaladoresTravel\Office_2016_x64\setup.exe" $testPath5 = "\\spuga1\InstaladoresTravel\Chrome_install.exe" foreach ($servers in $servers){ if (Test-Connection -Cn $servers -Quiet){ Copy-Item $source -Destination \\$servers\$dest -Recurse -Force if(Test-Path -Path $testPath1){ Invoke-Command -ComputerName $servers -ScriptBlock {powershell.exe \\spuga1\InstaladoresTravel\TurboSabre2014Setup.exe /silent /install} Write-Host -ForegroundColor Green "Instalacion de Turbo Sabre Realizada en el equipo $servers" } } else { Write-Host -ForegroundColor Red "$servers no se encuentra en linea, instalacion fall" } } foreach ($servers in $servers){ if (Test-Connection -Cn $servers -Quiet){ Copy-Item $source -Destination \\$servers\$dest -Recurse -Force if(Test-Path -Path $testPath2){ Invoke-Command -ComputerName $servers -ScriptBlock {powershell.exe \\spuga1\InstaladoresTravel\Firefox_install.exe /s} Write-Host -ForegroundColor Green "Instalacion de Mozilla FireFox Realizada en el equipo $servers" } } else { Write-Host -ForegroundColor Red "$servers no se encuentra en linea, instalacion fall" } } foreach ($servers in $servers){ if (Test-Connection -Cn $servers -Quiet){ Copy-Item $source -Destination \\$servers\$dest -Recurse -Force if(Test-Path -Path $testPath3){ Invoke-Command -ComputerName $servers -ScriptBlock {powershell.exe \\spuga1\InstaladoresTravel\AcrobatRider_install.exe /sAll /norestart ALLUSERS=1 EULA_ACCEPT=YES} Write-Host -ForegroundColor Green "Instalacion de Acrobat Rider Realizada en el equipo $servers" } } else { Write-Host -ForegroundColor Red "$servers no se encuentra en linea, instalacion fall" } } foreach ($servers in $servers){ if (Test-Connection -Cn $servers -Quiet){ Copy-Item $source -Destination \\$servers\$dest -Recurse -Force if(Test-Path -Path $testPath4){ Invoke-Command -ComputerName $servers -ScriptBlock {powershell.exe \\spuga1\InstaladoresTravel\Office_2016_x64\setup.exe /adminfile config.msp } Write-Host -ForegroundColor Green "Instalacion de Microsoft Office 365 Realizada en el equipo $servers" } } else { Write-Host -ForegroundColor Red "$servers no se encuentra en linea, instalacion fall" } } foreach ($servers in $servers){ if (Test-Connection -Cn $servers -Quiet){ Copy-Item $source -Destination \\$servers\$dest -Recurse -Force if(Test-Path -Path $testPath5){ Invoke-Command -ComputerName $servers -ScriptBlock {powershell.exe \\spuga1\InstaladoresTravel\Chrome_install.exe /silent /install} Write-Host -ForegroundColor Green "Instalacion de Google Chrome Realizada en el equipo $servers" } } else { Write-Host -ForegroundColor Red "$servers no se encuentra en linea, instalacion fall" } }

    Tuesday, May 7, 2019 6:20 PM

All replies

  • This is not allowed in a remote session.  Look up "second hop restriction".  All files must exist on the remote server.  You are not allowed to access a third server.


    \_(ツ)_/

    • Proposed as answer by jrv Wednesday, May 8, 2019 1:31 AM
    Tuesday, May 7, 2019 6:25 PM
  • amigo, tengo todas las aplicaciones en el servidor A y desde el mismo servidor estoy ejecutando el script para ir a la máquina B a instalar las aplicaciones

    Lo que propone es que tenga las aplicaciones en el servidor A, ejecute el script desde el Servidor C, de modo que las aplicaciones estén instaladas en la máquina B? ¿es esto?

    Wednesday, May 8, 2019 1:18 AM
  • Esto no está permitido en una sesión remota. Busque la "restricción del segundo salto". Todos los archivos deben existir en el servidor remoto. No se le permite acceder a un tercer servidor.


    \ _ (ツ) _ /

    amigo, tengo todas las aplicaciones en el servidor A y desde el mismo servidor estoy ejecutando el script para ir a la máquina B a instalar las aplicaciones

    Lo que se propone es que tenga las aplicaciones en el servidor A, ejecute el script desde el Servidor C, de la manera que las aplicaciones instaladas en la máquina B? ¿Es esto?


    Wednesday, May 8, 2019 1:20 AM
  • Esto no está permitido en una sesión remota. Busque la "restricción del segundo salto". Todos los archivos deben existir en el servidor remoto. No se le permite acceder a un tercer servidor.


    \ _ (ツ) _ /

    amigo, tengo todas las aplicaciones en el servidor A y desde el mismo servidor estoy ejecutando el script para ir a la máquina B a instalar las aplicaciones

    Lo que se propone es que tenga las aplicaciones en el servidor A, ejecute el script desde el Servidor C, de la manera que las aplicaciones instaladas en la máquina B? ¿Es esto?


    Si.  No es possible ejecutandolos.


    \_(ツ)_/

    Wednesday, May 8, 2019 1:33 AM
  • Hi,

    Thanks for your question.

    You have copy the installer file to your remote computers. Why not use the local installer? Because of the double hoop problem, you need to install the software from the remote computer's local path.

    foreach ($servers in $servers){
         if (Test-Connection -Cn $servers -Quiet){
            Copy-Item $source -Destination \\$servers\$dest -Recurse -Force
    
            if(Test-Path -Path "\\$servers\$dest\TurboSabre2014Setup.exe"){
                 Invoke-Command -ComputerName $servers -ScriptBlock { c:\TurboSabre2014Setup.exe  /silent /install}
                 
                 Write-Host -ForegroundColor Green "Instalacion de Turbo Sabre Realizada en el equipo $servers"
                 }
         } else {
            Write-Host -ForegroundColor Red "$servers no se encuentra en linea, instalacion fall"
         }
    }

    For more information, please refer the link below:

    https://powershellexplained.com/2017-04-22-Powershell-installing-remote-software/

    Best regards,

    Lee


    Just do it.

    Wednesday, May 8, 2019 2:53 AM
  • thank you very much friend solve the issue by copying the installers to the local team and from there I could do the installation ... now I have another problem and it is especially with the office ...

    the command copies the entire office folder to the TEMP folder of the remote machine, but when it is going to execute the setup ... it does not progress, the process remains in the background and the installation does not advance

    $servers = Get-Content \\CUWS2016\Instaladores\Equipos\servers.txt
    
    $source = "\\CUWS2016\Instaladores\"
    
    $file1 = "\\CUWS2016\Instaladores\Office_2016_x64\*"
    $file3 = '\\CUWS2016\Instaladores\TurboSabre2014Setup.exe'
    $file4 = "\\CUWS2016\Instaladores\Firefox_install.exe"
    $file5 = "\\CUWS2016\Instaladores\AcrobatRider_install.exe"
    $file6 = "\\CUWS2016\Instaladores\Chrome_install.exe"
    
    $computerName = $servers
    
    foreach ($servers in $servers){
         if (Test-Connection -Cn $servers -Quiet){
            
            Copy-Item -Path $file1 -Recurse -Force "\\$computername\c$\windows\temp\"
            Invoke-Command -ComputerName $computerName -ScriptBlock {
    
           Start-Process c:\windows\temp\setup.exe /silent -Wait
           }
                 
                 Write-Host -ForegroundColor Green "Instalacion de Microsoft Office 365 Realizada en el equipo $servers"
                 
         }else {
            Write-Host -ForegroundColor Red "$servers no se encuentra en linea, instalacion fall"
         }
    } 

    when I run it with the .bat and deploy it by GPO I add a configuration file something like this

    \\ CUWS2016 \ Installers \ setup.exe / adminfile config.msp

    but in powershell it tells me that no position parameter is found that accepts the argument 'Config.msp'.

    this complicates the installation of the office


    • Edited by Pvegas Wednesday, May 8, 2019 5:54 PM
    Wednesday, May 8, 2019 5:50 PM
  • Most installers you cannot wait on.  You will have to contact the vendor of the setup file to learn if this is possible.

    You can also create a persistent session and poll the session to find if the install is complete.

    $s = New-PsSession $computername
    Invoke
    -Command -Session $s  -ScriptBlock { Start-Processc:\windows\temp\setup.exe /silent}
    # periodically poll session to see if install is complete.



    \_(ツ)_/

    Wednesday, May 8, 2019 6:06 PM
  • Hi,

    Was your issue resolved?

    If you resolved it using our solution, please "mark it as answer" to help other community members find the helpful reply quickly.

    If you resolve it using your own solution, please share your experience and solution here. It will be very beneficial for other community members who have similar questions.

    If no, please reply and tell us the current situation in order to provide further help.

    Best Regards,

    Lee


    Just do it.

    Tuesday, May 14, 2019 3:16 AM