Link to home
Start Free TrialLog in
Avatar of tonelm54
tonelm54

asked on

Invoke-Expression to output and variable

Is it possible to echo out the result of a command to the screen and variable?

What I want to do it run a chkdsk command, showing the user progress of the chkdsk but at the end storing the output result into a variable so I can email that variable along with other variables throughout the script?

Thank you
ASKER CERTIFIED SOLUTION
Avatar of footech
footech
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
just tested this and it works. Granted, you will have to jump through the hoops of enabling PSRemoting.

$results = Invoke-Command -ComputerName $computername -ScriptBlock {chkdsk c:}

$results

Open in new window


EDIT: Nevermind... this doesn't accomplish the Realtime monitoring that you requested
EDIT: Double Nevermind... you weren't asking to do this on remote machines anyway.