powershell 调用winform dll
//1.加载dll,调用winform窗体,使用指定构造函数
param{
$filePath=""
}
[void][reflection.assembly]::LoadFile($filePath)
$a=New-Object namespace.classctor(args)
$a.DoSth()
分析,变量声明$,静态方法::,新建对象 New-Object 调用 doSth()
对象写法:
$sessions = $TSRemoteServer.GetSessions() if($sessions) { $aSE = @() foreach($s in $sessions) { $aSE += @{"SessionId" = $s.SessionId; "UserAccount" = $s.UserAccount.Value; "ConnectionState" = $s.ConnectionState; "WindowStationName" = $s.WindowStationName; "LoginTime"= $s.LoginTime; "IdleTime"=$s.IdleTime } } $result = $aSE }