Home >Tips >PowerShell with SharePoint from Scratch >Create multiple apps with function and for-loop kalmstrom.com site map icon Site map  

Create SharePoint Apps with Function and For-Loop

A PowerShell with SharePoint tutorial

PowerShell iconWhen you use PowerShell you can use a script to create multiple apps of the same kind in very short time and remove apps just as quickly.

 In the demo below, Peter Kalmström shows how to create multiple apps in just one script run, using a PowerShell function combined with a so called "for-loop".

In the previous article we created a function for app creation. The for loop calls this function several times, and Peter sets the parameters that give different app names and tells the for-loop when to stop looping through the function.

Peter continues to use the list app name "Hello World", and an integer variable makes sure that a specific number is added to each name.

for($i=1;$i -lt 11;$i++){
    Create-MyList -ListName ("Hello World" + $i) -ListURL ("HelloWorld" + $i)    
}
 
Peter also creates a for-loop that removes all the apps.

for($i=1;$i -lt 11;$i++){
    Remove-PnPList ("Hello World" + $i) -Force 
}





back icon next icon
Products Buy FAQ Services Tips Books Contact About Us Tools

Security and integrity

Copyright  Kalmstrom Enterprises AB  All rights reserved