We study nanoindentation of silicon using nonequilibrium molecular dynamics simulations with up to a million particles. Both crystalline and amorphous silicon samples are considered. We use computational diffraction patterns as a diagnostic tool for detecting phase transitions resulting from structural changes. Simulations of crystalline samples show a transition to the amorphous phase in a region a few atomic layers thick surrounding the lateral faces of the indentor, as has been suggested by experimental results. Our simulation results provide estimates for the yield strength (nanohardness) of silicon for a range of temperatures.