{"action":"created","issue":{"url":"https://api.github.com/repos/RamblingCookieMonster/PSDeploy/issues/18","repository_url":"https://api.github.com/repos/RamblingCookieMonster/PSDeploy","labels_url":"https://api.github.com/repos/RamblingCookieMonster/PSDeploy/issues/18/labels{/name}","comments_url":"https://api.github.com/repos/RamblingCookieMonster/PSDeploy/issues/18/comments","events_url":"https://api.github.com/repos/RamblingCookieMonster/PSDeploy/issues/18/events","html_url":"https://github.com/RamblingCookieMonster/PSDeploy/issues/18","id":146222142,"number":18,"title":"Scoping Fun","user":{"login":"RamblingCookieMonster","id":6377597,"avatar_url":"https://avatars.githubusercontent.com/u/6377597?v=3","gravatar_id":"","url":"https://api.github.com/users/RamblingCookieMonster","html_url":"https://github.com/RamblingCookieMonster","followers_url":"https://api.github.com/users/RamblingCookieMonster/followers","following_url":"https://api.github.com/users/RamblingCookieMonster/following{/other_user}","gists_url":"https://api.github.com/users/RamblingCookieMonster/gists{/gist_id}","starred_url":"https://api.github.com/users/RamblingCookieMonster/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/RamblingCookieMonster/subscriptions","organizations_url":"https://api.github.com/users/RamblingCookieMonster/orgs","repos_url":"https://api.github.com/users/RamblingCookieMonster/repos","events_url":"https://api.github.com/users/RamblingCookieMonster/events{/privacy}","received_events_url":"https://api.github.com/users/RamblingCookieMonster/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2016-04-06T07:54:29Z","updated_at":"2016-04-08T04:54:46Z","closed_at":null,"body":"A user might expect the following to work, and display `Var is 2`:\r\n\r\n```powershell\r\n$var = 2\r\n\r\nDeploy Example {\r\n    By Task One {\r\n        \"Var is $var\"\r\n    }\r\n    By noop Two {\r\n        FromSource MyModule\r\n        To C:\\PSDeployTo\r\n    }\r\n}\r\n```\r\n\r\nCurrently, this will display `Var is `, given fun with scoping.\r\n\r\nAn ugly workaround would be to use environment variables, or script scope.  This might be an acceptable solution given that tools like PSDeploy, the build script, or the CI/CD tool may already populate global or environmental variables:\r\n\r\n```powershell\r\n$script:var = 2\r\n\r\nDeploy Example {\r\n    By Task One {\r\n        \"Var is $script:var\"\r\n    }\r\n    By noop Two {\r\n        FromSource MyModule\r\n        To C:\\PSDeployTo\r\n    }\r\n}\r\n```\r\n\r\nThese both successfully display `Var is 2`, but are not very friendly or intuitive to the user.\r\n\r\nPotential solution: Add code that extracts script scope variables into the current scope. This would be needed in DeploymentType scripts, and in Task based DeploymentTypes (perhaps we could inject it).\r\n\r\nAm I missing anything?  The examples above are running from the dev branch.\r\n"},"comment":{"url":"https://api.github.com/repos/RamblingCookieMonster/PSDeploy/issues/comments/207215008","html_url":"https://github.com/RamblingCookieMonster/PSDeploy/issues/18#issuecomment-207215008","issue_url":"https://api.github.com/repos/RamblingCookieMonster/PSDeploy/issues/18","id":207215008,"user":{"login":"devblackops","id":12634452,"avatar_url":"https://avatars.githubusercontent.com/u/12634452?v=3","gravatar_id":"","url":"https://api.github.com/users/devblackops","html_url":"https://github.com/devblackops","followers_url":"https://api.github.com/users/devblackops/followers","following_url":"https://api.github.com/users/devblackops/following{/other_user}","gists_url":"https://api.github.com/users/devblackops/gists{/gist_id}","starred_url":"https://api.github.com/users/devblackops/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/devblackops/subscriptions","organizations_url":"https://api.github.com/users/devblackops/orgs","repos_url":"https://api.github.com/users/devblackops/repos","events_url":"https://api.github.com/users/devblackops/events{/privacy}","received_events_url":"https://api.github.com/users/devblackops/received_events","type":"User","site_admin":false},"created_at":"2016-04-08T04:54:46Z","updated_at":"2016-04-08T04:54:46Z","body":"Perhaps something similar to how psake is doing it? https://github.com/psake/psake/blob/master/psake.psm1#L252\r\nhttp://psake.readthedocs.org/en/latest/variable-referencing/\r\n\r\nThis looks like any variables defined in the ```properties``` function are added to the script scope. This is basically like your second example.\r\n"}}