Feeds:
Posts
Comments

Archive for the ‘Windows Server’ Category

This past weekend I was rebuilding a storage array to increase the storage capacity and also reconfigure the drives to optimize the arrangement for better performance on our SQL Server.  The original arrangement was two Dell PowerEdge 1950 servers connected to a  Dell MD3000 Storage array.  This setup was using Windows Server 2003 Clustered for High Availability.  We had a single Raid 5 array in the MD3000 and on it were three partitions, one for the Quorum, One for Data and one for Log files.

Our new configuration was designed to increase the drive space and also split off the partitions onto separate raid arrays.  So, we created a RAID 10 for the Log Files, a RAID 5 for the Databases, and then another Raid 10 which contained the Quorum partition and also a partition for the Temp DB.

When we brought up the server after the reconfiguration we discovered that the Cluster Service would not start.  This was due to the fact that the Quorum drive had been moved and was no longer at the location that Cluster Service expected it.

After several minutes of searching I found this TechNet article http://technet.microsoft.com/en-us/library/cc738770(v=ws.10).aspx.  Basically, in order to start up the Cluster Service without the Quorum resource you need to edit the service and put in a switch.

Edit the ClusterService and add “/fixquorum” as a startup parameter and then start the service.  Once the service has started up with the /fixquorum option you can then run clusterrecovery.exe.  Clusterrecovery.exe will allow you to substitute a new disk for the Quorum disk.  Once you have done that and its replaced the quorum disk you will then be able to restart your ClusterService with the /fixquorum option and it should start up correctly.

Cheers!

Advertisements

Read Full Post »

Today I am getting the opportunity to attend the Techstravaganza 2012 event http://www.techstravaganza.com at Microsoft’s office in NYC.  I hope to pick up a lot of good information on PowerShell and SharePoint.

Read Full Post »

I was going through some old files and thought I would post this one as a good example of using VBScript.

I had a request to automate the upload of a file to an FTP site.  This example dates back to 2006 so I know there are better ways to do this now, but it is a good example of the flexibility of VB Scripting.

‘ VBScript source code

Dim Fso : Set Fso = CreateObject(“Scripting.FileSystemObject”)
Dim WshNetwork : Set WshNetwork = CreateObject(“Wscript.Network”)
Dim WshShell : Set WshShell = CreateObject(“WScript.Shell”)
Const LogFile = “C:\VBScript\FTP.log”
‘Declares the log file.
Set FSO = CreateObject(“Scripting.FileSystemObject”)
Dim strFileName : strFileName = “C:\VBScript\holdings.csv”

‘Checks to see if the file is ready.
If not Fso.FileExists(strFileName) then
‘File is not ready exit out and wait
Set WshShell = WScript.CreateObject(“WScript.Shell”)
RunString = “%comspec% /c echo ************************ “ & WeekDayName(WeekDay(Now), True) & ” “ & Now & ” FILE NOT READY ************************ “
Return = WshShell.Run(RunString & ” >> ” & LogFile & ” 2>&1″, 0, TRUE)
WScript.quit
Else

RunCmd

Sub RunCmd()
Set WshShell = WScript.CreateObject(“WScript.Shell”)
RunString = “%comspec% /c echo ********************************************** “
Return = WshShell.Run(RunString & ” >> “ & LogFile & ” 2>&1″, 0, TRUE)
RunString = “%comspec% /c echo “ & WeekDayName(WeekDay(Now), True) & ” ” & Now & “, “& strFileName & ” is available – sending via FTP”
Return = WshShell.Run(RunString & ” >> “ & LogFile & ” 2>&1″, 0, TRUE)
RunString = “%comspec% /c echo ********************************************** “
Return = WshShell.Run(RunString & ” >> “ & LogFile & ” 2>&1″, 0, TRUE)
‘FTP the file to client
RunString = “%comspec% /c %WINDIR%\System32\ftp.exe -i -n -s:C:\VBScript\instructions.txt “
Return = WshShell.Run(RunString & ” >> “ & LogFile & ” 2>&1″, 0, TRUE)
RunString = “%comspec% /c echo ********************************************** “
Return = WshShell.Run(RunString & ” >> “ & LogFile & ” 2>&1″, 0, TRUE)
RunString = “%comspec% /c echo FINISHED: “ & WeekDayName(WeekDay(Now), True) & ” “ & Now
Return = WshShell.Run(RunString & ” >> “ & LogFile & ” 2>&1″, 0, TRUE)
RunString = “%comspec% /c echo ********************************************** “
Return = WshShell.Run(RunString & ” >> “ & LogFile & ” 2>&1″, 0, TRUE)
Set WshShell = Nothing
End Sub
End

Basically this script will check to see if a file exists and if it does it will send the file via FTP to a remote location and log all the output to a log file.   This is a good simple script to quickly and repeatedly perform a task and log it.

Read Full Post »

Today I was setting up PowerShell 2010 for testing on a VM and I ran into an issue during the install that is apparently quite common. I had successfully installed the prerequisites and was attempting to install the actual product when I got the following error.

Setup is unable to proceed due to the following error(s):
A system restart from a previous installation or update is pending. Restart your computer and run setup to continue.
For the list of pre-requisites needed to install the product please refer to:
http://go.microsoft.com/fwlink/?LinkId=106209
Correct the issue(s) listed above and re-run setup.

After doing some research I found this link at Microsoft’s TechNet site about common installation issues. 

The fix for my dilemma was to find this registry key

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\PendingFileRenameOperations

To delete the orphaned PendingFileRenameOperations registry key  

  1. Open a registry editor, such as Regedit.exe or Regedt32.exe.
  2. Navigate to HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\
  3. In the right navigation pane, right-click the PendingFileRenameOperations key and select Delete.
  4. Close Registry Editor.

After deleting the registry key (MAKE A BACKUP JUST IN CASE) I was able to continue on and complete my installation of SharePoint 2010.

Read Full Post »

I was reading Joe Keohan’s Blog about copying files via PowerShell and that got me to thinking about a process I already had.  Each night we copy files from a shared folder and post them to our intranet site for internal use.  We currently are using a batch file to handle this but I thought it was time to rewrite it in PowerShell. 

I had two main processes that I needed to handle.  The first was to copy the files to the local folder for the intranet and the second was to send an email to someone with those files attached so he can open them on his mobile device. 

So the first step of my script was to define some variables to stand in for my file locations. 

$SourceDir = "\\SVR1\data\Reports\Trading\*.pdf"
$DestDir = "c:\inetpub\intranet\research\reports\"
$BlotterSource = "\\SVR1\data\Reports\Blotters\*.pdf"

Then I use the Test-Path cmdlet to determine if the reports exist at the source location.  Normally this cmdlet would return True if the files exist and False if they do not.  But I use it in an If statement to say if it evaluates to True then do something else.  The something else is to start the file copy. 

 

If (Test-path $SourceDir )
{
    Copy-Item $SourceDir -Destination $DestDir -Force
}

If (Test-path $BlotterSource)
{
    Copy-Item $BlotterSource -Destination $DestDir -Force
}

I do this twice, once for one location and then again for the second location. 

And once my script is finished copying the files I use the send-mailmessage cmdlet to email the files to the recipient.  Since I have multiple files I’d like to attach I use a Get-ChildItem cmdlet to get all the file names and pipe them into the send-mailmessage cmd. 

This is what the finished script looks like. 

$SourceDir = "\\SVR1\data\Reports\Trading\*.pdf"

$DestDir = "c:\inetpub\intranet\research\reports\"

$BlotterSource = "\\SVR1\data\Reports\Blotters\*.pdf"

If (Test-path $SourceDir )

{ Copy-Item $SourceDir -Destination $DestDir -Force }

If (Test-path $BlotterSource)

{ Copy-Item $BlotterSource -Destination $DestDir -Force }

Get-ChildItem $DestDir | Where {-NOT $_.PSIsContainer} | foreach {$_.fullname} | send-mailmessage -from "Reporting <reporting@anyone.com>" -to "Jonathan <jonathan@anyone.com>", "Rob <rob@anyone.com>" -Cc "Greg <greg@anyone.com"> -subject "Daily Research Reports" -smtpServer mailserver.anyone.com -Body "Here are the daily research files for your review"

Now that the script is done I just schedule it via Windows Task Scheduler and we’re all set.  Now the files will get copied and emailed quickly and efficiently.

Read Full Post »

After finishing my script from the previous post I thought there has to be a better way to write this and reduce the lines of code.  Not that 5 separate lines is a lot.  But, if the list of items to print grew larger say to 15 documents, and was in different subdirectories then it might get complicated.  So, I set about trying to find a way to use the ForEach-Object cmd.  After some trial and error I have come up with this. 

$Directory = "\\SVR1\DATA\Reports\Trading\"

Get-ChildItem -path $Directory -recurse -include *.pdf | ForEach-Object {Start-Process -FilePath $_.fullname -Verb Print -PassThru | %{sleep 10;$_} | kill }

 

This will loop through the “Trading” directory and all subdirectories and print out the pdf documents it finds.  The one thing I still want to refine is the ability to close out Acrobat.  Right now it closes Acrobat after printing each document only to reopen it again for the next document.  I will look into just closing it at the end one time.  But for now this is at least a decent working script I plan to get a lot of use out of. 

Read Full Post »

Older Posts »