Private proxy functions
maybe interesting demonstation of scope you'd never want use in practice, throwing out discussion:
you can create proxy function quite this:
function private:get-acl {get-acl | select -expand access}
when create proxy function cmdlet, have use
$executioncontext.invokecommand.getcommand('get-childitem', [system.management.automation.command types]::cmdlet)
in function script block invoke cmdlet function going proxy. because in order of precedence functions resolve before cmdlets, , without function becomes self-referential , goes loop.
the private: option prevents function being visible in child scopes. since functions run in own scope effect hide existence of proxy function itself, and prevent loop.
it means function available in scope created in. added profile, change behaviour of get-acl used command line, same command used in child scope (e.g. using &{get-acl}, invoke-command {get-acl} or used in a called script) not see proxy function , use cmdlet instead.
[string](0..33|%{[char][int](46+("686552495351636652556262185355647068516270555358646562655775 0645570").substring(($_*2),2))})-replace " "
justin rich
http://jrich523.wordpress.com
powershell v3 guide (technet)
please remember mark replies answers if , unmark them if provide no help.
Windows Server > Windows PowerShell
Comments
Post a Comment