I played with the code and now im stuck at this error
PS C:\Users\ksadmin> New-SCSMView -Folder $folder -criteria $criteria -managementpack $mp -displayname "test" New-SCSMView : Object reference not set to an instance of an object. At line:1 char:13 + New-SCSMView <<<< -Folder $folder -criteria $criteria -managementpack $mp -displayname "test" + CategoryInfo : InvalidOperation: (test:String) [New-SCSMView], NullReferenceException + FullyQualifiedErrorId : NewView,SMLets.NewSMViewCommand