![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| Guest | returning values to original script Hi, I have a script called menu.ps1 which calls another PS script, getvalues.ps1. In getvalues.ps1, I do some console interaction with the user. Depending on the interaction, I need to return a value back to the original menu.ps1 script. I tried to do a return "$value" but that didn't work. What did work was to define a global variable via: $global:testvar. Is that the best way to return a value back to the original script? I rather not use a global variable if I didn't to. Thanks, |
My System Specs![]() |
| | #2 (permalink) |
| Guest | Re: returning values to original script "Frank" <Frank@discussions.microsoft.com> wrote in message news:4BA19C3B-93B1-4974-8198-4CB22128CB34@microsoft.com... > Hi, > > I have a script called menu.ps1 which calls another PS script, > getvalues.ps1. In getvalues.ps1, I do some console interaction with the > user. Depending on the interaction, I need to return a value back to the > original menu.ps1 script. I tried to do a return "$value" but that didn't > work. What did work was to define a global variable via: $global:testvar. > Is that the best way to return a value back to the original script? I rather > not use a global variable if I didn't to. > Basically anything output by a script that is not redirected to a file or captured by a variable is consider the output of a script. Try this: 24> 'gps | ?{$_.PM -gt 50MB}' > memhogs.ps1 25> $hogs = .\memhogs.ps1 26> $hogs Handles NPM(K) PM(K) WS(K) VM(M) CPU(s) Id ProcessName ------- ------ ----- ----- ----- ------ -- ----------- 472 15 68496 31820 278 40.30 4336 dexplore 210 9 123580 67140 226 1,411.63 1356 dwm 1847 51 173084 100272 433 1,957.20 4020 iexplore 711 32 95136 38468 310 ...21.83 4720 iexplore 458 11 83912 52356 239 143.56 4128 powershell 738 21 60228 45632 189 1,883.27 3624 sidebar 636 20 66636 63912 163 1168 svchost\ In fact the trickier problem is getting rid of unwanted script output i.e. some innocous like this: "Starting script memhogs.ps1" is added to the output of your script. To avoid that you would do this: write-host "Starting script memhogs.ps1" -- Keith |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| WMI command against sql cluster node not returning any values | PowerShell | |||
| Script to Export Multiple registry values? | VB Script | |||
| How to pass values from script to external batch files | PowerShell | |||
| How to get in a vbs script the sum of values of a Excel cells in a certain range? | VB Script | |||
| quoting original text doesn't work if original mail is UTF-8 | Vista mail | |||