Skip to content

Instantly share code, notes, and snippets.

@zippy1981
Created March 5, 2012 22:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zippy1981/1981612 to your computer and use it in GitHub Desktop.
Save zippy1981/1981612 to your computer and use it in GitHub Desktop.
Illustrates Foreach-Object scope weirdness.
$script:filename = ""
1..100 | % {
$script:filename = "$($env:temp)\deleteme-$($_).txt"
"Code: $(Get-Random 4-9)-$($_)"
} | Set-Content $script:filename
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment