Is there a way to display the content added to a variable when it is created? This topic contains 5 replies, has 3 voices, and was last updated by Vandrey Trindade 8 months, 1 week ago. Author Posts January 6, 2017 at 12:18 pm #61378 Vandrey TrindadeParticipant Hi, Newbie question, is there a way to show the content of a variable when it is created? e.g. Create a variable that contains an array with all distribution groups and display its content on the console $Groups = Get-Distribution I was wondering something like the Tee-Object (shows on the console and saves the result on a file) but without creating a file... January 6, 2017 at 1:29 pm #61383 Olaf SoykParticipant New-Variable -Name Groups -Value (Get-Distribution) -PassThru For new variables. And Set-Variable -Name Groups -Value (Get-Distribution) -PassThru to change the value January 6, 2017 at 1:30 pm #61386 Vandrey TrindadeParticipant Thanks Olaf! January 6, 2017 at 3:35 pm #61419 Jeremy MurrahParticipant not sure what version they added it to, but you can also use the -outvariable parameter like this: Get-Distribution -OutVariable Groups That will display on the screen and put it into $Groups January 6, 2017 at 3:57 pm #61425 Vandrey TrindadeParticipant Jeremy Murrah, Thanks, that was the best way for me! September 18, 2017 at 7:29 pm #79993 Vandrey TrindadeParticipant Hi, I found an article that explained three ways to do this. So I thought that I should share with you guys: Get-Process -Id $pid -OutVariable b ($a = Get-Process -Id $pid) Get-Process -Id $pid | Tee-Object -Variable c Same option but faster, using the pipeline: Tee-Object -InputObject (Get-Process -Id $pid) -Variable d Hope it helps =] Author Posts You must be logged in to reply to this topic.