简体   繁体   English

以管理员身份使用 Powershell 运行 vmware_vm_shell 的可能性

[英]Possibility to Run vmware_vm_shell using Powershell as Administrator

I feel frustated to find out if ansible module vmware_vm_shell is possible to run powershell as administrator?我很沮丧地发现 ansible 模块 vmware_vm_shell 是否可以以管理员身份运行 powershell? because few command that need to run with powershell has to be elevated to administrator role.因为很少有需要与 powershell 一起运行的命令必须提升为管理员角色。

Why i didn't use win_shell, or win_psexec?为什么我没有使用 win_shell 或 win_psexec? Because i want to try run the command in Windows VM Guest, without WinRM, so i don't need to access the VM using IPaddr, otherwise we can utilize vmtools as a connection in this case.因为我想尝试在 Windows VM Guest 中运行命令,没有 WinRM,所以我不需要使用 IPaddr 访问 VM,否则在这种情况下我们可以使用 vmtools 作为连接。

  - name: Initiate New Disk
    vmware_vm_shell:
      hostname: "{{ lookup ('env', 'VMWARE_HOST' )}}"
      username: "{{ lookup ('env', 'VMWARE_USER' )}}"
      password: "{{ lookup ('env', 'VMWARE_PASSWORD' )}}"
      vm_id: "{{ vmname }}"
      vm_username: "administrator"
      vm_password: "password123"
      vm_shell: 'C:\Windows\System32\WindowsPowershell\v1.0\powershell.exe'
      vm_shell_args: '-ExecutionPolicy Bypass -command "Initialize-Disk -Number {{newdisk_osnum}}"'
      vm_shell_cwd: 'C:\Users\administrator\Desktop'
      wait_for_process: yes
      validate_certs: no
    delegate_to: localhost
    register: initdisk_shell

Finally after few days full of pain, i found the way out, in ansible tower has feature to "Privilege Escalation" option in the job template configuration.终于经过几天的痛苦,我找到了出路,在 ansible 塔的工作模板配置中具有“权限升级”选项的功能。 after i enabled this option, finally vmware_vm_shell is able to run powershell command as administrator.在我启用此选项后,最后 vmware_vm_shell 能够以管理员身份运行 powershell 命令。 So i don't need to run command using winRM which have to disable few option that cause few vulnerability所以我不需要使用 winRM 运行命令,它必须禁用一些导致很少漏洞的选项

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM