search
Categories
Sponsors
VirtualMetric Hyper-V Monitoring, Hyper-V Reporting
Archive
Blogroll

Badges
MCSE
Community

Cozumpark Bilisim Portali
Posted in Windows Powershell | No Comment | 2,842 views | 18/06/2013 09:35

This is an example to show you how to fetch data from Sharepoint.
You need to send your domain credetials to log in Sharepoint server.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
$Webclient = New-Object System.Net.WebClient
$Webclient.Credentials = Get-Credential
$Servers = Get-Content C:\Servers.txt
foreach ($Server in $Servers)
{
	$AsyPortalURL = "http://sharepoint/_layouts/srchrss.aspx?k=" + $Server
	$Webpage = $Webclient.DownloadString($AsyPortalURL)
	$URL = "$WebPage" -match '<link>(.*?)</link>'
	$ServerID = $Matches[1]
	$ServerID = $ServerID.Split("ID=")[-1]
	$ServerListesi = "http://sharepoint/Lists/Server Listesi/DispForm.aspx?ID=" + $ServerID
	$Webpage = $Webclient.DownloadString($ServerListesi)
	$Webpage = $Webpage | ? {$_.trim() -ne ""}
	$Webpage = $Webpage -replace '\s+', ' '
	$IPField = "$Webpage" -match '<!-- FieldName="IP" FieldInternalName="IP" FieldType="SPFieldText" --> (.*?) </td>'
	$IPAddress = $Matches[1]
 
	$TestCon = Test-Connection $IPAddress
 
	if (!$TestCon)
	{
		$Value = $Server + "," + $IPAddress
		Add-Content -Value $Value -Path C:\pingtest.txt
	}
}

As you see that, I’m getting ip addresses of servers. After that doing test-network check for that servers.