Archive

Archives pour 09/03/2010

Pinger un ordinateur avec un script Powershell.

Faire un ping d'un ordinateur. Permet vérifier que l'ordinateur est en ligne avant de lancer une action sur lui via un script.

?View Code POWERSHELL
$computername = Read-Host "Please enter the computer name"
$ping = new-object System.Net.NetworkInformation.Ping
$reply = $ping.send($computerName)
if ($reply.status –eq “Success”)
{
write-host "$ComputerName is online."
}
Categories: Windows Tags: , ,

Afficher la configuration IP d’un serveur distant.

Permet d'afficher la configuration IP des cartes actives sur un serveur distant.

?View Code POWERSHELL
Get-WmiObject  -Class "Win32_NetworkAdapterConfiguration"  -ComputerName "server001" | Where-Object {$_.IpEnabled -Match "True"} | Select-Object DNSHostName,DHCPEnabled,IPAddress,IPSubnet,DefaultIPGateway,DNSServerSearchOrder,WINSPrimaryServer,WINSSecondaryServer,MACAddress,DNSDomain,Description
Categories: Windows Tags: , ,

Collecter les events logs à distance.

Ce script permet de collecter dans un fichier Excel les events log des résultats des online defrag sur tous les serveurs de boites aux lettres de l'organisation. Un fois que vous avez le résultat des défragmentation online, vous pouvez évaluer si il est pertinent d'effectuer une défragmentation offline sur certaines Databases.
?View Code POWERSHELL
$a = New-Object -comobject Excel.Application
 
$a.Visible = $True
 
$b = $a.Workbooks.Add()
$c = $b.Worksheets.Item(1)
 
$col = 1
$ligne = 1
 
$c.Cells.Item(1,1) = "Server"
$c.Cells.Item(1,2) = "Database"
$c.Cells.Item(1,3) = "Date"
$c.Cells.Item(1,4) = "Free space"
 
$ligne++
 
$ExchServer = Get-MailboxServer
foreach ($Server in $ExchServer){
 
$WmidtQueryDT = [System.Management.ManagementDateTimeConverter]::ToDmtfDateTime([DateTime]::Now.AddDays(-1))
$1221 = Get-WmiObject -computer $Server -query ("Select * from Win32_NTLogEvent Where Logfile='Application' and Eventcode = '1221' and TimeWritten >='" + $WmidtQueryDT + "'")
 
foreach ($event in $1221){
$database = $event.message.split('"')[1]
$size = $event.message.split('"')[2].split(" ")[2]
$date = $event.ConvertToDateTime($event.timewritten)
 
	$col = 1
	$c.Cells.Item($ligne,$col) = [string]$Server
	$col++
	$c.Cells.Item($ligne,$col) = [string]$database
	$col++
	$c.Cells.Item($ligne,$col) = [string]$date
	$col++
	$c.Cells.Item($ligne,$col) = [string]$size
	$ligne++
 
}
}
Categories: Exchange 2007 Tags: , , ,

Afficher la version de Exchange.

Permet d'afficher la version des serveurs Exchange de l'organisation et les rôles.

?View Code POWERSHELL
Get-ExchangeServer | ft Name,Edition,ExchangeVersion,ServerRole,IsMemberOfCluster
Voici également les numéros de version de Exchange et les dates de sortie: April 1996 - Microsoft Exchange Server 4.0 - 4.0.837 August 1996 - Microsoft Exchange Server 4.0 (a) - 4.0.993 May 1996 - Microsoft Exchange Server 4.0 SP1 - 4.0.838 August 1996 - Microsoft Exchange Server 4.0 SP2 - 4.0.993 November 1996 - Microsoft Exchange Server 4.0 SP3 - 4.0.994 April 1997 - Microsoft Exchange Server 4.0 SP4 - 4.0.995 May 1998 - Microsoft Exchange Server 4.0 SP5 - 4.0.996 March 1997 - Microsoft Exchange Server 5.0 - 5.0.1457 June 1997 - Microsoft Exchange Server 5.0 SP1 - 5.0.1458 February 1998 - Microsoft Exchange Server 5.0 SP2 - 5.0.1460 November 1997 - Microsoft Exchange Server 5.5 - 5.5.1960 July 1998 - Microsoft Exchange Server 5.5 SP1 - 5.5.2232 December 1998 - Microsoft Exchange Server 5.5 SP2 - 5.5.2448 September 1999- Microsoft Exchange Server 5.5 SP3 - 5.5.2650 November 2000 - Microsoft Exchange Server 5.5 SP4 - 5.5.2653 October 2000 - Microsoft Exchange 2000 Server - 6.0.4417 January 2001 - Microsoft Exchange 2000 Server (a) - 6.0.4417 July 2001 - Microsoft Exchange 2000 Server SP1 - 6.0.4712 December 2001 - Microsoft Exchange 2000 Server SP2 - 6.0.5762 August 2002 - Microsoft Exchange 2000 Server SP3 - 6.0.6249 September 2003- Microsoft Exchange 2000 Server post-SP3 - 6.0.6487 April 2004 - Microsoft Exchange 2000 Server post-SP3 - 6.0.6556 August 2004 - Microsoft Exchange 2000 Server post-SP3 - 6.0.6603 March 2008 - Microsoft Exchange 2000 Server post-SP3 - 6.0.6620.5 August 2008 - Microsoft Exchange 2000 Server post-SP3 - 6.0.6620.7 October 2003 - Microsoft Exchange Server 2003 - 6.5.6944 May 2004 - Microsoft Exchange Server 2003 SP1 - 6.5.7226 October 2005 - Microsoft Exchange Server 2003 SP2 - 6.5.7638 March 2008 - Microsoft Exchange Server 2003 post-SP2 - 6.5.7653.33 August 2008 - Microsoft Exchange Server 2003 post-SP2 - 6.5.7654.4 December 2006 - Microsoft Exchange Server 2007 - 8.0.685.24 or 8.0.685.25 November 2007 - Microsoft Exchange Server 2007 SP1 - 8.1.0240.006 August 2009 - Microsoft Exchange Server 2007 SP2 - 8.2.0176.002 October 2009 - Microsoft Exchange Server 2010 - 14.00.0639.021
Categories: Exchange 2007 Tags: