Score:1

Ansible powershell scripts not working - script is not recognized as the name of a cmdlet

cz flag

I'm trying to stop windows services using ansible but I get the error 'script is not recognized \r\nas the name of a cmdlet."

Here is the task in the Ansible yaml file:

  - name: Check if ERL is already installed
    win_service:
      name: RabbitMQ
      state: stopped

This is the error when executing playbook:

TASK [Check if ERL is already installed] **************************************************************************************************************************************************************************************************************************************
fatal: [localhost]: FAILED! => {"changed": false, "module_stderr": "/home/user1/.ansible/tmp/ansible-tmp-1629089159.6-1896-227877656238414/AnsiballZ_win_service.ps1 : The term \r\n'/home/user1/.ansible/tmp/ansible-tmp-1629089159.6-1896-227877656238414/AnsiballZ_win_service.ps1' is not recognized \r\nas the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was \r\nincluded, verify that the path is correct and try again.\r\nAt line:1 char:1\r\n+ /home/user1/.ansible/tmp/ansible-tmp-1629089159.6-1896-22787765623841 ...\r\n+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\r\n    + CategoryInfo          : ObjectNotFound: (/home/user1/.an...win_service.ps1:String) [], CommandNotFoundException\r\n    + FullyQualifiedErrorId : CommandNotFoundException\r\n \r\n", "module_stdout": "", "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error", "rc": 1}
br flag
so ... is there a file at `'/home/user1/.ansible/tmp/ansible-tmp-1629089159.6-1896-227877656238414/AnsiballZ_win_service.ps1'`? if so, does the account in question have permission to see/access/use it?
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.