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
- 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 }}"
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.",
""
]
}
- name: Create DFS links
win_shell: |
. C:\Scripts\USERNAME\dfsadd_func.ps1 # dot source the file to load the functions
dfsadd -junction Apps -obj_name toast -prd_vserver PROD -dr_vserver DR -prd_state online -dr_state offline
The methodology I was following was "if it worked through ise, why's this not pass it properly?", I knew I was doing something wrong, I just didn't know what yet.
I'll give this a shot in the morning and report back.
After 12 punches on the card of "Jordan saves the day" do you earn a prize?
- name: Create DFS links
win_shell: |
. 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 }}"
become: yes
become_method: runas
become_user: "USER...@DOMAIN.NET"