I believe it is known that if I is a set of nonmeasurable cardinality, then any homomorphism $Z^I\to Z$ factors through a finite power. Here $Z$ is the group of integers. Can anyone give a reference for this?

This runs under the name Łoś–Eda Theorem. A reference is the book Paul C. Eklof, Alan H. Mekler: Almost free modules (2002): Call a set $I$ $\omega$measurable, if its cardinality is greater or equal to the first measurable cardinal. This is equivalent to $I$ being uncountable and supporting a nonprincipal countably complete ultrafilter. First note that $\mathbb{Z}$ is slender (Cor. III.2.4). Then, by Cor. III.3.6 (and the discussion before Lemma III.3.5), if $I$ is not $\omega$measurable, the natural map $$\phi: \bigoplus_{i \in I} Hom(\mathbb{Z},\mathbb{Z}) \to Hom(\prod_{i \in I}\mathbb{Z},\mathbb{Z}),\; (g_i)_i \mapsto \big(\; (m_i)_i \mapsto \sum_i g_i(m_i)\;\big)$$ is an isomorphism. Remarks: 1) If $I$ is $\omega$measurable, not all homomorphisms $\prod_I \mathbb{Z} \to \mathbb{Z}$ factor through a finite subset of $I$. For, let $D$ be a nonprincipal countably complete ultrafilter on $I$ and let $K_D = \lbrace x \in \prod_I \mathbb{Z} \mid I \setminus \sup(x) \in D\rbrace$. Then it's not hard to show that the composition $\prod_I \mathbb{Z} \twoheadrightarrow \prod_I \mathbb{Z}/K_D \cong \mathbb{Z}$ doesn't factor through a finite subset of $I$ (the latter isomorphism uses II.3.3). 2) Irrespective whether $I$ is $\omega$measurable or not, there is a canonical isomorphism $$Hom(\prod_{i \in I}\mathbb{Z},\mathbb{Z}) \cong \bigoplus_D Hom(\mathbb{Z},\mathbb{Z})$$ where $D$ runs through all countably complete ultrafilters on $I$ (Cor. III.3.7). 

