Problem with Invoke-Command and functions
i have written following code
cls function getbar() { $bar = "bar" $bar } function getfoo() { $foo = "foo" $bar = getbar $foo $bar } $cred = get-credential "domain\user" $result = invoke-command -credential $cred -computername localhost -scriptblock ${function:getfoo} write-host $result[0] write-host $result[1]
gives error
term 'getbar' not recognized name of cmdlet, function, script file, or operable program. check spelling of name, or if path included, verify path correct , try again.
+ categoryinfo : objectnotfound: (getbar:string) [], commandnotfoundexception
+ fullyqualifiederrorid : commandnotfoundexception
why not able find function?
val it: unit=()
it's same if doing in local session. once get-bar defined in a session, other fuctions or script run in session can use - no, need define once.
[string](0..33|%{[char][int](46+("686552495351636652556262185355647068516270555358646562655775 0645570").substring(($_*2),2))})-replace " "
Windows Server > Windows PowerShell
Comments
Post a Comment