How to call a method with output parameters in PowerShell?

前端 未结 2 999
一向
一向 2021-01-03 17:56

I\'m working on a script to get started in PowerShell. I\'m trying to convert a working VBScript script that enumerates mapped network drives on a remote Windows computer.

相关标签:
2条回答
  • 2021-01-03 18:31
    $explorer = gwmi Win32_Process -computerName computerName -filter "Name='explorer.exe' and SessionID=0"   
    $explorer.GetOwner() | select user,domain
    
    0 讨论(0)
  • 2021-01-03 18:46

    Using the [ref] modifier

    SomeMethod( [ref] $a );
    

    Notable blog entries

    • http://geekswithblogs.net/Lance/archive/2009/01/14/pass-by-reference-parameters-in-powershell.aspx
    • http://weblogs.asp.net/soever/archive/2009/03/26/powershell-return-values-from-a-function-through-reference-parameters.aspx
    0 讨论(0)
提交回复
热议问题