我想包几包
Invoke-RestMethod
由两个函数调用,我必须通过
WebSession
它们之间的差异很大。目标:
Login -SessionVariable MySession
# do some work while using $MySession
Logout -WebSession $MySession
这个
Login
和
Logout
函数可能如下所示:
function Login {
Param(
[String]SessionVariable
)
Invoke-RestMethod ... -SessionVariable $SessionVariable
Invoke-RestMethod ... -WebSession ???
Invoke-RestMethod ... -WebSession ???
}
function Logout {
Param(
WebSession
)
Invoke-RestMethod ... -WebSession $WebSession
}
但是我如何使用会话变量的名称呢
登录
把它传给
-WebSession
参数甚至可以重新实现SessionVariable/WebSession的概念吗
调用rest方法
? 我觉得这和一个
call-by-reference
通过
[ref]
,但如何在变量名(字符串)和实际变量之间建立桥梁?