SharePoint logs and IIS logs backup/archive and Compress to a file

The data keeps on growing as the SharePoint Farm being adopted more into the company and customers. It brings more challenges in terms of keeping up with the pace of requests and data administration. We are going to address today one part of that problem which is managing SharePoint LOGS weather it is ULS, Diagnostic and Analytic logging. Also it includes IIS logs. To address this challenge I did wrote a small script to migrate these logs to a different directory and them zip these logs and move to a network storage or to another directory on the local hard drive. 

Some of the challenges to achieve this were 

·        There are IIS logs with same file names in different directories (mainly IIS logs) we need to maintain the directories structure to not miss any logs. 

·        The criteria to move these logs out is based on a number of day , like I need to move all the logs 15 or older away from the default logs folder or drive. 

·        Then zip these logs and add to same archive file as this script has to run daily and we have a single archive file on that machine and to maintain the zip name to reflect the server name to easy recognition on the network store. 

·        All this to be scripted in batch scripting and using a free compress utility (7z) command line utility to include compress in the script. 

·        Donwload 7z and install it to program files as we need to add this install path to environment variable PATH to use it in script directly 

 

PowerShell Version 3 – Intellisense

_______________________________________________________________________________
Windows PowerShell 3.0 is now available to download for Windows 7, Windows Server 2008 R2, and for Windows Server 2008. Windows PowerShell 3.0 comes in the Management Framework 3.0. You can download Windows PowerShell 3.0 from the Microsoft Download Center.  

 
Not going into deep of powershell V3 features, the one most I like initially was intellisense.  Also you can run a single cmdlet with selecting its parameters in the GUI to the right of the powershell ISE window. 

 
Check out the pics. … More to come later posts
 
 
 

Reset SharePoint PassPhrase

Passphrase for SharePoint saves the farm from accidental addition of servers by known or unknown admins. One way its saves but if we does not document it somewhere or lost it then the only way to retreive it is to reset the passphrase

The passphrase resides some where in SharePoint Configuration database encrypted. We need to set a new passphrase using the cmdlet Set-SPPassPhrase. Before we need to pass the new passphrase we need to convert it to secure string.
Follow the steps:
Note: Run these cmdlets on a server which is still part of a server, if the server is disconnected already from the farm then it cannot connect to configuration database to update the passphrase.
Open a sharepoint Management (powershell) Shell

$Pass = ConvertTo-SecureString -AsPlainText -Force

It will prompt to enter the passphrase now
Set-SpPassPhrase -PassPhrase $Pass
It will ask you to reenter the passphrase you need to enter the passphrase you already gave it in earlier step.