Scenario/Problem: You need to obtain a site reference and therefore need a listing of available subsites within a specific site collection.
Solution: Use the Get-SPWeb
cmdlet with a wildcard Identity
path.
To display all subsites within a site collection, you need to use the Get-SPWeb
cmdlet with the Identity
parameter. If you provide only the site collection URL, Get-SPWeb
returns only the site collection web object. Therefore, you need to provide a wildcard path, as shown in Listing 8.11.
Get-SPWeb -Identity "http://sp2013/sites/sitecol/*"
You can also use the Site
parameter instead of the wildcard Identity
parameter to retrieve all webs, including the site collection web. Listing 8.12 shows a sample command line.
Get-SPWeb -Site "http://sp2013/sites/sitecol"
3.144.84.155