{"action":"created","issue":{"url":"https://api.github.com/repos/ansible/ansible-modules-core/issues/2147","labels_url":"https://api.github.com/repos/ansible/ansible-modules-core/issues/2147/labels{/name}","comments_url":"https://api.github.com/repos/ansible/ansible-modules-core/issues/2147/comments","events_url":"https://api.github.com/repos/ansible/ansible-modules-core/issues/2147/events","html_url":"https://github.com/ansible/ansible-modules-core/issues/2147","id":108178844,"number":2147,"title":"win_file failing with $fileinfo.Directory property not existing on directory creation.","user":{"login":"ccelebi","id":936251,"avatar_url":"https://avatars.githubusercontent.com/u/936251?v=3","gravatar_id":"","url":"https://api.github.com/users/ccelebi","html_url":"https://github.com/ccelebi","followers_url":"https://api.github.com/users/ccelebi/followers","following_url":"https://api.github.com/users/ccelebi/following{/other_user}","gists_url":"https://api.github.com/users/ccelebi/gists{/gist_id}","starred_url":"https://api.github.com/users/ccelebi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ccelebi/subscriptions","organizations_url":"https://api.github.com/users/ccelebi/orgs","repos_url":"https://api.github.com/users/ccelebi/repos","events_url":"https://api.github.com/users/ccelebi/events{/privacy}","received_events_url":"https://api.github.com/users/ccelebi/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/ansible/ansible-modules-core/labels/bug_report","name":"bug_report","color":"fbca04"},{"url":"https://api.github.com/repos/ansible/ansible-modules-core/labels/P2","name":"P2","color":"fad8c7"},{"url":"https://api.github.com/repos/ansible/ansible-modules-core/labels/windows","name":"windows","color":"777777"}],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":12,"created_at":"2015-09-24T17:42:05Z","updated_at":"2015-11-03T18:21:35Z","closed_at":"2015-11-03T16:04:01Z","body":"##### Issue Type:\r\n\r\n  - Bug Report\r\n\r\n##### Ansible Version:\r\n```\r\n$ ansible --version\r\nansible 2.0.0 (devel 24b9e2e6d1) last updated 2015/09/24 10:23:50 (GMT -400)\r\n  lib/ansible/modules/core: (detached HEAD e8227dea7a) last updated 2015/09/24 10:23:57 (GMT -400)\r\n  lib/ansible/modules/extras: (detached HEAD f2faf70996) last updated 2015/09/24 10:23:57 (GMT -400)\r\n  config file = /Users/ccelebi/ansible/ansible.cfg\r\n  configured module search path = None\r\n```\r\n##### Ansible Configuration:\r\n```\r\nhost_key_checking=true\r\n```\r\n##### Environment:\r\n\r\nrunning on OSX, virtualenv for python and managing windows with powershell v4.\r\n```\r\n> $PSVersionTable.PSVersion\r\n\r\nMajor  Minor  Build  Revision\r\n-----  -----  -----  --------\r\n4      0      -1     -1\r\n```\r\n\r\n##### Summary:\r\n\r\nTrying to create a directory on a windows machine using core module win_file. When manually run on the windows host I do not see the object property .Directory. As stated in the code, only files have a .Directory property.\r\n\r\n##### Steps To Reproduce:\r\n\r\nTask below:\r\n```\r\n- name: Create temp directory\r\n  win_file:\r\n      path=C:/temp\r\n      state=directory\r\n```\r\n\r\nor \r\n\r\n```\r\n- name: Create temp directory\r\n  win_file:\r\n      path=C:\\\\temp\r\n      state=directory\r\n```\r\nresults in the error message:\r\n```\r\n+         If ( $state -eq \"directory\" -and $fileinfo.Directory )\r\n+              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\r\nfatal: [xxx.xxx.xxx.xxx]: FAILED! => {\"changed\": false, \"failed\": true, \"msg\": \"The property 'Directory' cannot be found on this object. Verify that the property exists.\"}\r\n```\r\n\r\nI verified this on the windows host with the following: \r\n```\r\nPS C:\\Users\\Administrator> $fileinfo = Get-Item C:\\temp\r\n\r\nPS C:\\Users\\Administrator> Get-ItemProperty -Path $fileinfo | Format-list -Property * -Force\r\n\r\nPSPath            : Microsoft.PowerShell.Core\\FileSystem::C:\\temp\r\nPSParentPath      : Microsoft.PowerShell.Core\\FileSystem::C:\\\r\nPSChildName       : temp\r\nPSDrive           : C\r\nPSProvider        : Microsoft.PowerShell.Core\\FileSystem\r\nBaseName          : temp\r\nMode              : d----\r\nName              : temp\r\nParent            :\r\nExists            : True\r\nRoot              : C:\\\r\nFullName          : C:\\temp\r\nExtension         :\r\nCreationTime      : 9/24/2015 11:19:17 AM\r\nCreationTimeUtc   : 9/24/2015 3:19:17 PM\r\nLastAccessTime    : 9/24/2015 11:19:17 AM\r\nLastAccessTimeUtc : 9/24/2015 3:19:17 PM\r\nLastWriteTime     : 9/24/2015 11:19:17 AM\r\nLastWriteTimeUtc  : 9/24/2015 3:19:17 PM\r\nAttributes        : Directory\r\n```\r\n##### Expected Results:\r\n\r\nDirectory should be created \r\n\r\n##### Actual Results:\r\n\r\nPlaybook run fails due to the powershell failing on directory creation.\r\n\r\nFails on looking for a directory property on a path that is a directory and not a file. The logic doesn't continue on to the logic to handle the directory creation.\r\n```\r\n+         If ( $state -eq \"directory\" -and $fileinfo.Directory )\r\n+              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\r\nfatal: [10.1.10.102]: FAILED! => {\"changed\": false, \"failed\": true, \"msg\": \"The property 'Directory' cannot be found on this object. Verify that the property exists.\"}\r\n\r\n```\r\n\r\nCode:\r\n```\r\nIf ( $state -eq \"directory\" -and $fileinfo.Directory )\r\n        {\r\n            Fail-Json (New-Object psobject) \"path is not a directory\"\r\n        }\r\n```"},"comment":{"url":"https://api.github.com/repos/ansible/ansible-modules-core/issues/comments/153443497","html_url":"https://github.com/ansible/ansible-modules-core/issues/2147#issuecomment-153443497","issue_url":"https://api.github.com/repos/ansible/ansible-modules-core/issues/2147","id":153443497,"user":{"login":"jhawkesworth","id":8440323,"avatar_url":"https://avatars.githubusercontent.com/u/8440323?v=3","gravatar_id":"","url":"https://api.github.com/users/jhawkesworth","html_url":"https://github.com/jhawkesworth","followers_url":"https://api.github.com/users/jhawkesworth/followers","following_url":"https://api.github.com/users/jhawkesworth/following{/other_user}","gists_url":"https://api.github.com/users/jhawkesworth/gists{/gist_id}","starred_url":"https://api.github.com/users/jhawkesworth/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jhawkesworth/subscriptions","organizations_url":"https://api.github.com/users/jhawkesworth/orgs","repos_url":"https://api.github.com/users/jhawkesworth/repos","events_url":"https://api.github.com/users/jhawkesworth/events{/privacy}","received_events_url":"https://api.github.com/users/jhawkesworth/received_events","type":"User","site_admin":false},"created_at":"2015-11-03T18:21:35Z","updated_at":"2015-11-03T18:21:35Z","body":"thanks for closing this off @ccelebi "}}