About

MS MVP Logo

View Marc Lognoul [MVP]'s profile on LinkedIn

Disclaimer

The information and materials in this site are provided "AS IS" with no warranties, and confering no rights. This site does not represent the thoughts, intentions, plans or strategies of our employers, customers, friends or family, solely our own personal opinions.

Now in Native x64: Reading an Excel sheet using PowerShell and ADO.Net

by Marc 19. July 2010 09:49

Long ago I blogged about using PowerShell to read out an XLS(X) file using ADO.Net. Until recently, only the x86 version of the ODBC driver was available.

Fortunately, Microsoft recently release a x64 version of the drivers as part of the Microsoft Access Database Engine 2010 Redistributable Package. Download link:

Interestingly, while this package is labeled “Office 2010”, the provider's names references “Office 12” (2007) –> this should have be released earlier :)

Marc

Tags:

PowerShell | Scripting and Automation | Office

Using PowerShell to Retrieve all Servers in a SharePoint Farm

by Marc 16. January 2009 21:59

I often have to perform maintenance or configuration activities on all servers members of a SharePoint farm suchs as archiving or parsing logs, recycling IIS application pools… While you could simply store all servers’ name in a plain text file, I always prefer a more dynamic way and as usual now, PowerShell will do the job.

Begin with loading the assembly…

[Void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint")

Then connect to the farm:

$spFarm = [Microsoft.SharePoint.Administration.SPfarm]::Local

And finally populate an array with all servers:

$spServers = $spFarm.Servers|Select Farm,DisplayName,Address,Role

Now the problem with this array is that it also contains servers that are not real servers but rather “network names” such as the SMTP host for mail-out or the SQL database server name and instance. If you want to retrieve only server where SharePoint is installed and running, use this filter

$arrServers = $spFarm.Servers|Where {!($_.Role -eq 'Invalid' -and $_.Status -eq 'Online')}|Select Farm,DisplayName,Address,Role

Note: the Role will help you identifying a WFE from and application Server, for example. The address is the real host name used for network connectivity while the Display Name is, like its name suggests it, the text used for displaying the Central Admin.

And cut!

PS: Finally my “assistant director” Anthony (the Minghella of PowerShell, the Hopkins of automation or should I say, the Zuiker of scripting;)) has finally caught his digital pen to shoot ahem.. I mean write, his first post. Welcome online Antho!

Tags:

PowerShell | Scripting and Automation | SharePoint

Sysinternals goes Live

by Marc 5. June 2008 16:13

Sysinternals Tools are now available as a "Live" service and can be accessed from http://live.sysinternals.com or \\live.sysinternals.com\tools\.

If , like me, you like to keep them "available offline", feel free to use of of those script to automate download. Both HTTP or CIFS protocols can be used:

Cheers!

Tags:

Tools | Scripting and Automation