Executing a script remotely on non-domain Target from server on Domain

0

I am stuck with a very specific problem:

My infrastructure:

  1. Driver script on a Server in organization domain – uses delegated credentials based on user login
  2. Target VM – not on organization domain – different local credentials that need to be passed
  3. Shared network drive with data that should be accessible to '2' – same credentials as '1'

What I need to do:

  1. Trigger Driver script from Server that is on domain
  2. Revert the Target VM to some existing snapshot (using PowerCLI)
  3. Map a drive on Target VM – using the domain related credentials
  4. Execute some powershell scripts placed on shared network drive (this internally accesses some .dat and .bin files on the same location)

My problem is I am unable to connect to the Target VM with Invoke-Command to execute the drive map script. The error I get is:

WinRM cannot process the request. The following error with errorcode 0x8009030e occurred while using
Negotiate authentication: A specified logon session does not exist. It may already have been terminated.
Possibly because:
-Kerberos accepts domain user names, but not local user names.
But I do not have any domain user names, as the VM is not on domain

What I have tried:

  1. Invoke-Command with script path in ScriptBlock
  2. New-PSSession
  3. Adding the drive map as a startup script on logon – this however does not work unless I manually login to Target VM after each snapshot revert

Prerequisites used:

  1. PSRemoting is enabled on both driver and target VMs
  2. The IPs are added as trusted hosts on both
  3. WinRM is configured to process requests
  4. ExecutionPolicy is Unrestricted
  5. Firewall disabled
powershell
asked on Stack Overflow May 9, 2017 by Rasika Gopalakrishnan • edited May 9, 2017 by James C.

2 Answers

0

Instead of mapping the drive... why not just run the file against the remote machine?

Invoke-Command -ComputerName $targetVm `
               -Credential $credentials `
               -FilePath Z:\example\file.ps1
answered on Stack Overflow May 9, 2017 by gvee
0

Try test-wsman remotemachine to check if remote is running.

answered on Stack Overflow May 9, 2017 by Adam

User contributions licensed under CC BY-SA 3.0