Multiple command output to file

%3CLINGO-SUB%20id%3D%22lingo-sub-905644%22%20slang%3D%22en-US%22%3EMultiple%20command%20output%20to%20file%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-905644%22%20slang%3D%22en-US%22%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20am%20trying%20to%20run%20a%20few%20commands%20and%20then%20output%20my%20results%20to%20a%20file.%20When%20I%20run%20this%20script%20below%20it%20takes%20the%20MyOutput%20results%20as%20text%20instead%20of%20executing%20them.%26nbsp%3B%20What%20am%20I%20doing%20wrong%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CFONT%20size%3D%223%22%20color%3D%22%233366FF%22%3E%24MyOutput%20%3D%20%7B%3C%2FFONT%3E%3CBR%20%2F%3E%3CFONT%20size%3D%223%22%20color%3D%22%233366FF%22%3EGet-ChildItem%20-Path%20Registry%3A%3AHKEY_LOCAL_MACHINE%5CSOFTWARE%5CDell%5C%20-Recurse%3C%2FFONT%3E%3C%2FP%3E%3CP%3E%3CFONT%20size%3D%223%22%20color%3D%22%233366FF%22%3E%22%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%22%3B%3C%2FFONT%3E%3C%2FP%3E%3CP%3E%3CFONT%20size%3D%223%22%20color%3D%22%233366FF%22%3EGet-ChildItem%20Env%3AComputerName%3C%2FFONT%3E%3CBR%20%2F%3E%3CFONT%20size%3D%223%22%20color%3D%22%233366FF%22%3E%7D%3C%2FFONT%3E%3C%2FP%3E%3CP%3E%3CFONT%20size%3D%223%22%20color%3D%22%233366FF%22%3E%24MyOutput%20%7C%20Out-File%20-FilePath%20.%5C%22DellRegValues-%20%24env%3Acomputername.txt%22%3C%2FFONT%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-905644%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EWindows%20PowerShell%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-907072%22%20slang%3D%22en-US%22%3ERe%3A%20Multiple%20command%20output%20to%20file%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-907072%22%20slang%3D%22en-US%22%3E%3CP%3ERead%20here%3A%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fpowershell%2Fmodule%2Fmicrosoft.powershell.core%2Fabout%2Fabout_redirection%3Fview%3Dpowershell-6%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Ehttps%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fpowershell%2Fmodule%2Fmicrosoft.powershell.core%2Fabout%2Fabout_redirection%3Fview%3Dpowershell-6%3C%2FA%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E
Visitor

 

I am trying to run a few commands and then output my results to a file. When I run this script below it takes the MyOutput results as text instead of executing them.  What am I doing wrong?

 

$MyOutput = {
Get-ChildItem -Path Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Dell\ -Recurse

"================";

Get-ChildItem Env:ComputerName
}

$MyOutput | Out-File -FilePath .\"DellRegValues- $env:computername.txt"

1 Reply