Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/powershell/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Powershell 从域上的服务器在非域目标上远程执行脚本_Powershell - Fatal编程技术网

Powershell 从域上的服务器在非域目标上远程执行脚本

Powershell 从域上的服务器在非域目标上远程执行脚本,powershell,Powershell,我遇到了一个非常具体的问题: 我的基础设施: 组织域中服务器上的驱动程序脚本–基于用户登录使用委派凭据 目标VM–不在组织域上–需要传递的不同本地凭据 共享网络驱动器,其数据应可供“2”访问–与“1”的凭据相同 我需要做的是: 来自域上服务器的触发器驱动程序脚本 将目标VM还原为某些现有快照(使用PowerCLI) 在目标VM上映射驱动器–使用域相关凭据 执行放置在共享网络驱动器上的一些powershell脚本(这会在内部访问同一位置上的一些.dat和.bin文件) 我的问题是无法使用Invok

我遇到了一个非常具体的问题:

我的基础设施:

  • 组织域中服务器上的驱动程序脚本–基于用户登录使用委派凭据
  • 目标VM–不在组织域上–需要传递的不同本地凭据
  • 共享网络驱动器,其数据应可供“2”访问–与“1”的凭据相同
  • 我需要做的是:

  • 来自域上服务器的触发器驱动程序脚本
  • 将目标VM还原为某些现有快照(使用PowerCLI)
  • 在目标VM上映射驱动器–使用域相关凭据
  • 执行放置在共享网络驱动器上的一些powershell脚本(这会在内部访问同一位置上的一些.dat和.bin文件)
  • 我的问题是无法使用
    Invoke命令
    连接到目标VM以执行驱动器映射脚本。我得到的错误是:

    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 WinRM无法处理该请求。使用时发生以下错误,错误代码为0x8009030e 协商身份验证:指定的登录会话不存在。它可能已经被终止了。 可能是因为: -Kerberos接受域用户名,但不接受本地用户名。 但是我没有任何域名,因为虚拟机不在域上 我所尝试的:

  • 使用脚本块中的脚本路径调用命令
  • 新会话
  • 在登录时将驱动器映射添加为启动脚本–但是,除非在每次快照还原后手动登录到目标VM,否则此操作不起作用
  • 使用的先决条件:

  • PSRemoting在驱动程序和目标VM上都已启用
  • IP作为受信任主机添加到两个主机上
  • WinRM配置为处理请求
  • 执行策略不受限制
  • 防火墙禁用

  • 而不是映射驱动器。。。为什么不直接在远程机器上运行文件呢

    Invoke-Command -ComputerName $targetVm `
                   -Credential $credentials `
                   -FilePath Z:\example\file.ps1
    

    请尝试
    test wsman remotemachine
    检查remote是否正在运行。

    您对问题的解释非常详细,但您没有包括遇到问题的代码。您需要编辑问题以包含代码。听起来您可能需要使用
    Invoke命令
    上的
    -Authentication
    选项来指定Kerberos以外的内容(取决于您将目标VM设置为接受什么)。