Closed sysnetstriver closed 2 years ago
Files identified in the description: None
If these files are incorrect, please update the component name
section of the description or use the !component
bot command.
Files identified in the description:
lib/ansible/modules/windows/win_psexec.ps1
If these files are incorrect, please update the component name
section of the description or use the !component
bot command.
Thank you very much for your interest in Ansible. Ansible has migrated much of the content into separate repositories to allow for more rapid, independent development. We are closing this issue/PR because this content has been moved to one or more collection repositories.
For further information, please see: https://github.com/ansible/ansibullbot/blob/devel/docs/collection_migration.md
The psexec module is not the problem. That was just an additional attempt to get it to work. The primary problem is ansible.windows.win_powershell and ansible.windows.win_shell.
Summary
I have tried 3 different task methods to get Ansible to execute a powershell command or a ps1 script with the command in an elevated Administrator shell. I am a DOMAIN Admin and the computer is domain joined. All other powershell module tasks prior to this one work with my domain admin SA account. The command in the problem task is
Import-Module -Name DellBIOSProvider -Verbose -Force
. When I test this locally under my DOMAIN admin account it fails at the operation of ..New-PSDrive.. could not be created, please run with Administrator privileges. So to get it working I have to run powershell as Admin (system32) and the Import-Module command completes the New-PSDrive operation without fail. But Ansible is not executing the command or ps1 script in elevated mode it seems even with me using become_method become and become_user for local-admin execution. I have searched for days on how to get this to work. I found one other person that describes my problem on github but the conversation was then moved to private Github issue and I found this info on stackoverflow Powershell script in elevated mode . None of these implementations work. The output of Get-PSDrive should show the DellSmBIOS PS drive after successful import so that subsequent playbook tasks can use the new ps-drive for pwrsh configuration calls but the it is not there because Ansible is running it under my domain admin sa account.Issue Type
Bug Report
Component Name
ansible.windows.win_powershell
Ansible Version
Configuration
OS / Environment
Control host: NAME="Ubuntu" VERSION="18.04.6 LTS (Bionic Beaver)" ID=ubuntu ID_LIKE=debian PRETTY_NAME="Ubuntu 18.04.6 LTS" VERSION_ID="18.04" HOME_URL="https://www.ubuntu.com/" SUPPORT_URL="https://help.ubuntu.com/" BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/" PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy" VERSION_CODENAME=bionic UBUNTU_CODENAME=bionic
Target OS: Windows 10 Professional Version 21H2 OS Build 19044.1889
Steps to Reproduce
Expected Results
I expect that at the
Import-Module.......
step which runs the script/command to result in theNew-PSDrive
being created so that all subsequent tasks can interact with that PS drive for configuration calls via the powershell commands. But the problem is that the module appears to not be imported because I am getting these errors. Note that I did test this locally on the Windows endpoint and it shows that the module will only import when the command or script is executed in an Elevated administrator shell, not when it is executed from my domain admin user account SA shell, which is the same user account I am running the playbook from the control host as.Local test output when attempting to import module with my domain admin account in pwrsh:
EXPECTED RESULT: Local test output when executing from Administrator Elevated shell showing success of Dellsmbios PS Drive:
EXPECTED RESULT after importing module showing the new ps drive DellSmbios:
Output showing my user account is an admin:
Actual Results
As you can see, once it gets to the task
Verify the import for DellSMBIOS
, the new PS Drive does not show up in the task which occurs after the Import Module task. You can see there are errors in each task after this one that refer to the ps drive not being there so it cannot perform any operations. The playbook I copied above is the most recent implementation attempt to get this to work. The results are the same no matter which task method I choose to implement. As you can see in the playbook I have written 3 different iterations with varying approaches for trying to accomplish this objective. I have also tried changing the install location of the Powershell module to not be inC:\Program Files\WindowsPowerShell\Modules
to instead be located inC:\Users\arichardson.sa\Documents\WindowsPowershell\Modules
thinking that the Path change would solve the elevation privilege problem but it did not. Same result.PLAYBOOK OUTPUT AND RECAP:
Code of Conduct