I have a function, it works perfectly if I run it directly from my target 
server.

powershell.exe  -ExecutionPolicy ByPass -file 
"C:\Scripts\USERNAME\dfsadd_func.ps1"; dfsadd -junction Apps -obj_name 
toast -prd_vserver PROD -dr_vserver DR -prd_state online -dr_state offline

With success seen below.
Path                               TargetPath              State  
 ReferralPriorityClass ReferralPriorityRank
----                               ----------              -----  
 --------------------- --------------------
\\DOMAIN.net\Apps\toast \\PROD\Apps\toast Online  sitecost-normal       0  
                 
\\DOMAIN.net\Apps\toast \\DR\Apps\toast Offline sitecost-normal       0


Through ansible
I've tried both win_shell and win_command like so
  - name: Create DFS links
#    win_command: powershell.exe -ExecutionPolicy ByPass -file 
C:\Scripts\USERNAME\dfsadd_func.ps1; dfsadd "{{ vol_junction }} {{ obj_name 
}} {{ prd_vserver }} {{ dr_vserver }} {{ prd_state }} {{ dr_state }}"
    win_shell: powershell -file C:\Scripts\USERNAME\dfsadd_func.ps1';' 
dfsadd " -junction {{ vol_junction }} -obj_name {{ obj_name }} -prd_vserver 
{{ prd_vserver }} -dr_vserver {{ dr_vserver }} -prd_state {{ prd_state }} 
-dr_state {{ dr_state }}"


With varying combinations of how to include that semi-colon, how to *not 
*include 
the semi-colon, whatever.

Mostly, to this result.

fatal: [HOSTNAME.DOMAIN.net]: FAILED! => {
    "changed": true,
    "cmd": "powershell -file C:\\Scripts\\USERNAME\\dfsadd_func.ps1';' 
dfsadd \" -junction Apps -obj_name toast -prd_vserver PROD -dr_vserver DR 
-prd_state online -dr_state offline\"",
    "delta": "0:00:00.968771",
    "end": "2020-03-05 07:36:02.440099",
    "msg": "non-zero return code",
    "rc": 1,
    "start": "2020-03-05 07:36:01.471327",
    "stderr": "Processing -File 'C:\\Scripts\\USERNAME\\dfsadd_func.ps1;' 
failed because the file does not have a '.ps1' extension. Specify a valid 
Windows PowerShell script file name, and then try again.",
    "stderr_lines": [
        "Processing -File 'C:\\Scripts\\USERNAME\\dfsadd_func.ps1;' failed 
because the file does not have a '.ps1' extension. Specify a valid Windows 
PowerShell script file name, and then try again."
    ],
    "stdout": "Windows PowerShell \r\nCopyright (C) 2016 Microsoft 
Corporation. All rights reserved.\r\n\r\n",
    "stdout_lines": [
        "Windows PowerShell ",
        "Copyright (C) 2016 Microsoft Corporation. All rights reserved.",
        ""
    ]
}


I don't have much hair left to remove, so I can't pull much more out, 
anyone have any good advice?

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/1d2255a0-4344-4693-956f-772d2ee231bb%40googlegroups.com.

Reply via email to