5 [You shall have] a perfect and just weight (Deut. 25:15) -- According to the Gaon, these words indicated that his first mission was being the light of Mashiach ben Yosef. Following the command to use a perfect and just weight, we read about wiping out Amalek, and immediately afterwards, we find: when you come to the Land [Deut. 26:1], which is similar to the verse when you come to the Land and plant [Lev. 19:23], etc. All these are thus related and of equal importance. From this the Gaon learned about his great mission regarding the revealed end. The Gaon wrote that a perfect weight is a characteristic of Din from the left side. Only when on his way to the Land of Israel, did the Gaon realize that he had reached the level of faithful shepherd [appellation of Moshe Rabbeinu] in the verse: [Isa. 54:7] with abundant mercy I will gather you. [Those words, in gematria, equal the Gaons name: ! .] Therefore, the Gaon felt that he did not have the permission of Heaven to enter Eretz Israel. He then directed his students to act like the aspect of Joshua: that is, to begin fulfilling the obligation of ingathering exiles.
36. (Isa. 54:2) expand the site of your tent, etc. -- The commandment to expand the borders is the mission of Mashiach ben Yosef as God had told the prophet Jonah, who was on the level of Mashiach ben Yosef, to restore the border of Israel (II Kings 14:25). Likewise the verse: in distress...in expansiveness, means that it was his mission to expand the boundaries in the war against Amalek, who was the destroyer, according to the Midrash. The enemy, the destructions are gone forever which is related to the verse: God wages war against Amalek. The verb expands is used in opposition to the verb destroys [the order of the letters and are in reverse order in the two words].
44. (Deut. 32:7) remember the days of old, understand the years of generation after generation -- This refers to the first Mashiach who fights Amalek in an eternal war. The Lord wages war against Amalek in generation after generation. That is the mission of Joshua who was Mashiach ben Yosef.
47. ([mentioned in] Ex. 17:13) the sword of Joshua -- This is the sword of the first Mashiach who fights Amalek as revealed in the great force of the name of God that is concealed in the words the war of the Lord and in the combination of two names of God, "" (value of 91), that is also the value of the word  go out, used in connection with fighting Amalek.
55. (Ex. 17:16) the hand is on the throne of God [God swears]: the Lord wages war against Amalek from generation to generation -- This is the mission of Joshua who is Mashiach ben Yosef.
62. Joshua bin Nun -- together with Mashiach ben Efraim who wages war against Amalek. Akiba ben Yosef is in the line of Joshua, and this is affirmed in gematria . Likewise, it states [Ps. 132:6] we heard about it in Efrata, which refers to Joshua from the tribe of Efraim (Zevachim 54b).
67. (Isa. 9:6) Davids throne -- This refers to Mashiach ben Yosef.In the same verse we find: to establish it and sustain it through justice and righteousness. Preceding this verse, the Psalm states: for a child has been born to us etc. According to the holy Ari (on the blessing )[see 127], there is a great and holy obligation when we say the prayer that we always concentrate on praying that Mashiach ben Yosef will not be killed by the wicked Armilus. As it says: I will raise  the fallen tabernacle of David (Amos 9:11). Wherever the verb is used, it refers to Mashiach ben Yosef. See above (#133) about the aspect of My sheaf rose. This idea is also hinted at in the world (with a )which is equal to 566 [as is ]. The purpose of his work in gathering in the exiles is to establish Davids throne in our war against the wicked Armilus as revealed in the verse the Lord wages war against Amalek.
72. (Isa. 28:6) counterattack [lit.: return the war to the gate] -- The word is composed of the initial letters of Mashiach ben Yosef, whose mission it is to wage war against Amalek in the gates of Jerusalem at the entrance to the city.
78. (Ex. 17:16) God wages war against Amalek from generation to generation -- All this is the task of Joshua, who was Mashiach ben Yosef, and this task has continued in every generation and has become more and more difficult in the footsteps of Mashiach ben Yosef, and this is the war against Armilus (as explained above in 67 from the aspect of Davids throne).
131. horns of an ox -- as is written, (Deut. 33:17) his horns are like those of an ox, with them he gores nations. The main idea refers to Mashiach ben Yosef, as the Gaon explains at length in his remarks on this verse (in his work Aderet Eliyahu), for Mashiach ben Yosef is in the line of Joshua, who took part in the war the Lord wages against Amalek from generation to generation. The horns of an ox is refer to the war of Gog and Magog, which is divided into many parts, like the parable in the Midrash. In the parable, a king became angry at his son, and swore to throw a huge stone at him. Later on, he regretted what he had said, etc.Its an important principle that all pain and anguish that Israel suffers because of the nations of the world, generally and well as personally, even more so in connection with the ingathering of the exiles--all these decrease the amount and intensity of suffering during the war of Gog and Magog (see the beginning of the section on Efraim is My fistborn as is known). Happy are you, dear sons of Zion who stand in the breach against savage descendants of Hagar, as promised to us that Mashiach ben Yosef will gore nations, and the Lord will provide the salvation. Now the best and surest path and medicine to lighten, even remove all the tribulations of Gog and Magog and all the tribulations of Eretz Israel, is to correct ones conduct by setting up people of Truth in the Holy City. This will lead to the redemption of Truth and sanctification of the Holy Name, which are the main purpose of all our deeds during the beginning of the Redemption. We have already explained above that, according to the Gaon, while the footsteps of the Mashiach progress through the ingathering of the exiles, the Sitra Achra becomes stronger and stronger in his main purpose, which is to deny and uproot truth and righteousness, as our Sages have said: during the footsteps of the Mashiach, truth will be missing [Sota 49b], etc. In order to counter this, we must act and fight with all our strength with the help of God, to overcome the Sitra Achra with good deeds and with all the corrections, as noted and explained below.
148. (Ex. 17:14) place it in the ears of Joshua, that I will surely erase the memory of Amalek, etc.-- In gematria, the word ! in the ears of equals  secret for the way to fight Amalek is at first secretly, as already explained above, because work in gathering in the exiles is the waging of war against Amalek in order to subdue Samael in the gates of Jerusalem. Joshua is part of the mission of Mashiach ben Yosef. The Gaon also hinted at what is found in the verse: It is the honor of God [Prov. 25:2] to conceal a matter, and those two words equal , see above (#98) on the aspect the secret of the Lord is for those who fear him.