从域

时间:2017-05-09 09:19:52

标签: powershell

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

我的基础设施:

  1. 组织域中服务器上的驱动程序脚本 - 使用基于用户登录的委派凭据
  2. 目标VM - 不在组织域上 - 需要传递的不同本地凭据
  3. 共享网络驱动器,其数据应该可以被' 2' - 与' 1'
  4. 相同的凭据

    我需要做什么:

    1. 从域
    2. 上的服务器触发驱动程序脚本
    3. 将目标VM还原为某些现有快照(使用PowerCLI)
    4. 使用域相关凭据
    5. 在目标VM上映射驱动器
    6. 执行放置在共享网络驱动器上的一些powershell脚本(这内部访问同一位置的一些.dat和.bin文件)
    7. 我的问题是我无法使用Invoke-Command连接到目标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
      

      我尝试过:

      1. 使用ScriptBlock中的脚本路径调用Command-Command
      2. 新-的PSSession
      3. 在登录时将驱动器映射添加为启动脚本 - 但除非我在每次快照还原后手动登录到目标VM,否则这不起作用
      4. 使用的先决条件:

        1. 在驱动程序和目标VM上启用PSRemoting
        2. 在两个
        3. 上添加IP作为可信主机
        4. WinRM配置为处理请求
        5. ExecutionPolicy是Unrestricted
        6. 禁用防火墙

2 个答案:

答案 0 :(得分:0)

而不是映射驱动器......为什么不直接对远程计算机运行文件

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

答案 1 :(得分:0)

尝试test-wsman remotemachine检查遥控器是否正在运行。

相关问题