Con questo codice in PowerShell 1.0 è possibile elencare in una DataGrid Windows gli alert di SharePoint impostati su una specifica lista
PowerShell
[void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint")
[void][System.reflection.assembly]::LoadWithPartialName("System.Windows.Forms") 

#$url = "http://sharepoint2007/Documentazione/Documents/"
$url = Read-Host "Inserisci la url della lista"

$site = new-object microsoft.sharepoint.spsite $url

$web = $site.openweb()
$list = $web.getlist($url)
#$alerts = $web.Alerts | ?{$_.ListID -eq $list.id}
$alerts = $web.Alerts | ?{$_.ListID -eq $list.id} | select Title, Filter, EventType, ItemID, List, AlertFrequency, AlertTime, User

$form = new-object System.Windows.Forms.Form 
$form.width=700
$DataGridView = new-object System.windows.forms.DataGridView 
$Form.Text = "Alerts"
$array= new-object System.Collections.ArrayList 
$array.AddRange( @( $alerts | write-output ) ) 
$DataGridView.DataSource = $array
$DataGridView.Dock = "fill"
$DataGridView.AllowUsertoResizeColumns=$True
$form.Controls.Add($DataGridView) 
write-host "Guarda la finesta di alert"
$form.showdialog()
Potrebbe interessarti anche: