| $site = New-Object Microsoft.SharePoint.SPSite("http://adbmoss") # Connect to the site collection http://adbmoss and store the object in the $site variable $site | get-member # Display all the properties and methods for the object in $site $site.set_readonly($True) # Set the site collection to read only. No updates are allowed $site.set_readonly($False) # Set the site collection back to read-write $root = $site.rootweb # Connect to the root site in the site collection and store the object in $root $root | get-member # Display all the properties and methods for the object in $root $root.lists | format-table -property title, author # Display title and authors for all the lists in the root site $root.lists | ?{$_.iscatalog -eq $null} | format-table -property title, author # Filter the lists to show only the user lists. The $_ symbol refers to the object in the piple line. The ? symbol is an alias for the where-object commandlet. $root.listtemplates | format-table -property name # Show all the available list templates for the root web $TempCal=$root.listtemplates["Calendar"] # Store the Calendar template in a variable $TempCal $root.lists.add("Events","Company Events", $tempCal) # Create a list called “Events” with Description “Company Events” on the calendar template import-csv dept.csv | %{$root.lists.add($_.Dept, $_.Descr,$root.listtemplates[$_.Temp])} # Create a new list for ever line in a CSV file where the name for the list is saved in the Dept column of the file, the description is in the Descr column, and the type of list to create is in the Temp column. First check that the lists are correctly created before you continue. The % symbol is an alias for the foreach-object commandlet and places each instance of the collection in the pipeline one after the other. import-csv dept.csv | %{$root.lists[$_.Dept].delete()} # Use the CSV file again to delete all the create lists again. |