Is every G-invariant function on a Lie algebra a trace? I am in the (slow) process of editing my notes on Lie Groups and Quantum Groups (V Serganova, Math 261B, UC Berkeley, Spring 2010.  Mostly I can fill in gaps to arguments, but I have found myself completely stuck in one step of one proof.  One possibility that would get me unstuck is a positive answer to the following (which may be obviously false or trivial, but I'm not thinking well):

Question: Let $\mathfrak g$ be a finite-dimensional Lie algebra over $\mathbb K$, and if necessary you may assume that $\mathbb K = \mathbb C$ and that $\mathfrak g$ is semisimple.  Then $\mathfrak g$ acts on itself by the adjoint action, and on polynomial functions $f : \mathfrak g \to \mathbb K$ via derivations.  A polynomial $f: \mathfrak g \to \mathbb K\,$ is $\mathfrak g$-invariant if $\mathfrak g \cdot f = 0$.  For example, let $\pi: \mathfrak g \to \mathfrak{gl}(V)$ be any finite-dimensional reprensentation.  Then $x \mapsto \operatorname{tr}_V \bigl(\pi(x)^n\bigr)$ is $\mathfrak g$-invariant for any $n\in \mathbb N$.  Is every $\mathfrak g$-invariant function of this form?  Or at least a sum of products of functions on this form?

When $\mathfrak g$ is one of the classical groups $\mathfrak{sl},\mathfrak{so},\mathfrak{sp}$, or the exceptional group $G_2$ the answer is yes, because we did those examples in the aforementioned class notes.  But I have no good grasp for the $E$ series, and I don't know if the statement holds for non-semisimples.
What I'm actually trying to prove is a weaker statement, but I figured I'd ask the stronger question, because to me the answer is not obviously "no".  The weaker statement:

Claim: Let $\mathfrak g$ be a finite-dimensional semisimple Lie algebra over $\mathbb C$.  Then every $\mathfrak g$-invariant function is constant on nilpotent elements of $\mathfrak g$.  (Recall that $x\in \mathfrak g$ is nilpotent if $\operatorname{ad}(x) = [x,] \in \mathfrak{gl}(\mathfrak g)$ is a nilpotent matrix — some power of it vanishes.)

It's clear that the spectrum of any nilpotent matrix is $\{0\}$, and for a semisimple Lie algebra, any nilpotent element acts nilpotently in all representations.  For the classical groups, in the notes we exhibited generators for the rings of $\mathfrak g$-invariant functions as traces of representations, and so we can just check the above claim.  But we did not do the $E$ series or $F_4$.
 A: The answer to your question is yes for semisimple Lie algebras. This is essentially the content of the Chevalley restriction theorem. See the proof at the beginning of chapter 2 of Gaitsgory's notes.
A: If the representation is fixed as the fundamental representation, then in the case of $\mathfrak{so}(2n)$, you need Pfaffians as well as traces. 
A: Here is a sketch of an alternate proof of the claim; making this rigorous may be harder than the approach you take.
Let $G$ be the lie group corresponding to the lie algebra $\mathfrak{g}$. So $G$ acts on $\mathfrak{g}$. $G$-invariant functions are, as the name suggests, invariant under this action.
If $x$ is nilpotent then we can use the $G$-action to move $x$ into the nilradical $\mathfrak{n}_+$. Let $\psi: \mathbb{C}^* \to T$ be a one parameter subgrop that paris positively with the positive roots. So, for $x$ in $\mathfrak{n}_+$, we have $\lim_{t \to 0} \psi(t) x=0$.
So $0$ is in the closure of $Gx$ and, if $f$ is $G$ invariant, we must have $f(x)=f(0)$. In particular, if $f$ is $G$-invariant and has positive degree, then $f(x)=0$.
A: The answer to the general question is "no": 

If $\mathfrak{g}$ is solvable, by Lie's theorem its commutant $\mathfrak{g}^{\prime}=[\mathfrak{g},\mathfrak{g}]$ is represented by strictly upper triangular matrices in a suitable basis in any finite-dimensional module. Hence all "trace generated" polynomials are zero on $\mathfrak{g}^{\prime}$; in other words, they factor through the abelianization $\mathfrak{g}/\mathfrak{g}^{\prime}$ and are generated by linear invariant polynomials. Unless the adjoint action of $G$ with Lie algebra $\mathfrak{g}$ on $\mathfrak{g}^{\prime}$ has a Zariski dense orbit, there are invariant polynomials that cannot be obtained in this way.

The answer to the claim is "yes", this is Kostant's theorem from his celebrated paper: 

If $G$ is a complex semisimple group then its nullcone $\mathcal{N}\subset\mathfrak{g}$ is the Zariski closure of a single adjoint orbit consisting of regular nilpotent elements. 

Kostant actually proved that the nullcone is the scheme-theoretic complete intersection defined by $rk\;G$ homogeneous positive degree algebra generators of $\mathbb{C}[\mathfrak{g}]^G$ — this is the connection with the Chevalley theorem mentioned by others. But for the present purpose, it is enough to show that regular nilpotents are Zariski open and dense in $\mathcal{N}\cap\mathfrak{n},$ and a good way of doing it was indicated by David Speyer.
