When using the ..Tasks..Generate Scripts method the order that objects are scripted are critical when using indexed views and objects that reference them using the NOEXPAND hint.
If you have view2 that references view1 (which is an indexed view) and use the NOEXPAND hint in view2 the script will fail because all the view definitions are created first before the clustered indexes. This means that when view2 gets created it complains about the NOEXPAND because at that point view1 is not considered to be an indexed view. The index for view1 is added further down the script.
To solve this issue the clustered index for view1 should be created directly after the view1 definition, this would then make the NOEXPAND hint inside view2 valid.