Shuttle mission length was limited by lots of consumables, including propellant and canisters for the life support system.
The Station-to-Shuttle Power Transfer System (SSPTS) could provide electrical power to the Shuttle, but it only allowed the shuttle to remain docked for an extra 4 days. Only Discovery and Endeavour were equipped with the SSPTS.
The Space Shuttle was most often utilized in its last 10 years of operations as a construction vehicle that hauled pieces of the enormous ISS into orbit. Since much of its time on these missions was spent docked to the station, it seemed logical to design a way for the Orbiter to draw power from the massive solar panels and batteries of the ISS. These solar panels enjoy the renewable resource of sunlight as their power source whereas the shuttle’s fuel cells have a limited amount of cryogenic reactant on board. By being able to run the fuel cells at their minimum power of about 2 kW, the team would be able to increase their cryogenic margins and remain in orbit for 2-3 extra days. These added days allowed critical time for extra-vehicular activities (EVA) or other work on the ISS.
The system that connected the Orbiter power system to that of the ISS was called the Station to Shuttle Power Transfer System (SSPTS). This system was able to increase the docked duration from about 6-8 days to approximately 9-12 days by transferring responsibility of up to 8 kW of the Orbiter’s load to the ISS. This power transfer was achieved by adding two power transfer units (PTUs) to the Orbiter which converted the 120VDC input power from the station to 28VDC expected by the main buses (Fig. 27).
An additional limit is the year-end rollover on the Shuttle's computers, which was worked around by not having the Shuttles fly on New Year's Eve.