When you call powershell.exe with -File you cannot run multiple commands after that, it's designed to run a script with potential arguments. You can even see in the error from powershell it thinks the file it needs to run is `C:\Scripts\USERNAME\dfsadd_func.ps1;' (with the semicolon) so that's why it is saying the extension is wrong.
If you are trying to run a function that is sourced from a file do the following - 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 Please bear in mind the double hop problem with WinRM where you will be unable to talk to downstream servers in your task unless you use something like become or your auth is CredSSP or Kerberos with credential delegation enabled. -- 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 ansible-project+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/efdc8a5e-0262-4ca8-913b-bbbecc97cf75%40googlegroups.com.