I have declared a powershell variable to get the packages installed on Windows 2016 server by defining a variable and i want to pipe it to a text file.
$jvn=Get-Command java | Select-Object Version
I have tried using
$jvn=Get-Command java | Select-Object Version | Out-File -FilePath .\jvn.txt
but this prints on the screen , not in text file ,
i want the output in the text File as Java Version 8.0.202.26
$jvn=Get-Command java | Select-Object Version | Out-File -FilePath .\jvn.txtis how you write to text file. It will not print to screen if you do this.$jvn=Get-Command java | Select-Object @{N=’Java Version’; E={$_.Version}} | Out-File -FilePath C:\test\jvn.txt