This would write the output to a logfile:
& $Env:WinDir\\system32\\inetsrv\\appcmd.exe >test.log
But what if I wanted to keep the output
You have to do:
$test = & $Env:WinDir\system32\inetsrv\appcmd.exe
If you wanted to redirect error as well, add 2>&1 in the end.
2>&1