Want to become a Vibe Coder? Join Vibe Coding Training here
x
C# Corner
Tech
News
Videos
Forums
Jobs
Books
Events
More
Interviews
Live
Learn
Training
Career
Members
Blogs
Challenges
Certification
Contribute
Article
Blog
Video
Ebook
Interview Question
Collapse
Feed
Dashboard
Wallet
Learn
Achievements
Network
Refer
Rewards
SharpGPT
Premium
Contribute
Article
Blog
Video
Ebook
Interview Question
Register
Login
PowerShell Script to Find Lists with Null Default View in SharePoint 2010
WhatsApp
Karthik Muthu Karuppan
Feb 19
2015
2
k
0
0
FindSPNullDefaultVie
$LogTime = Get-Date -Format yyyy-MM-dd_hh-mm
$LogFile =
".\FindSPNullDefaultViewPatch-$LogTime.rtf"
# Add SharePoint PowerShell Snapin
if
( (Get-PSSnapin -Name Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue) -eq $
null
) {
Add-PSSnapin Microsoft.SharePoint.Powershell
}
$scriptBase = split-path $SCRIPT:MyInvocation.MyCommand.Path -parent
Set-Location $scriptBase
#Deleting any .rtf files in the scriptbase location
$FindRTFFile = Get-ChildItem $scriptBase\*.* -include *.rtf
if
($FindRTFFile)
{
foreach($file
in
$FindRTFFile)
{
remove-item $file
}
}
start-transcript $logfile
function
FindSPNullDefaultView{
[cmdletbinding()]
param(
[parameter(ValueFromPipeline=$True,ValueFromPipelineByPropertyName=$True,Mandatory=$True)]
[string[]]$url
)
Begin{
$const_verbosepreference = $verbosepreference
$verbosepreference =
"Continue"
Try { [
void
] [System.Reflection.Assembly]::LoadWithPartialName(
"Microsoft.SharePoint"
) }
Catch {
Write-Warning
"Failed to Load REQUIRED .NET Framework Assembly Class...exiting script!"
Break
}
$array = @()
}
Process{
Try{
$SiteCollection = New-Object Microsoft.SharePoint.SPSite($url)
Foreach($Site
in
$SiteCollection.AllWebs){
Write-Verbose
"$($Site.Url)"
Foreach ($List
in
$Site.Lists){
Try{
If($List.DefaultView -eq $
null
){
$props = @{
Title=$($List.Title)
ItemCount=$($List.ItemCount)
Author=$($List.Author)
LastItemModifiedDate=$($List.LastItemModifiedDate)
ParentWebUrl=$($List.ParentWebUrl)
BaseType=$($List.BaseType)
RootFolder=$($List.RootFolder)
Hidden=$($List.Hidden)
}
$array += New-Object PSObject -property $props
}
} Catch { Write-Verbose
"Unable to load $List.DefaultViewUrl"
}
}
}
$SiteCollection.Dispose();
} Catch { Write-Verbose
"Unable to locate site for $($url)"
}
}
End{
$array
$verbosepreference = $const_verbosepreference
}
}
$siteCollectionURL = read-host
"Enter the site collection url "
FindSPNullDefaultView $siteCollectionURL
stop-transcript
SharePoint
Find Lists with Null Default View in SharePoint
Up Next
PowerShell Script to Find Lists with Null Default View in SharePoint 2010