Solved

PowerShell Script 'Hangs' in 3.0

Posted on 2013-12-12
4
586 Views
Last Modified: 2016-02-10
The attached script worked fine in 2.0, however the progress bar did not display. The server was running 2.0 and I upgraded to 3.0. At that point in time, the script no longer runs. It starts out, displays the progress bar, with 0% complete, and then hangs.

If I check task manager, I can see DTExec.exe running, and the data all gets imported, but the script shows no progress. I have to finally kill it with a Ctrl-Break.

Also the script works fine on another server running 3.0.

The script is relatively generic, but via the parms file, it executes DTExec.exe (32-bit) with parameters to execute an SSIS package. There were no problems until I upgraded the other server with PS 3.0. On both servers the version is 3.0, Build = -1, Revision = -1.

I've included the log file from a good run.
0002.ImportData.txt
0002.ImportData-20131212-111527.log
0
Comment
Question by:dbbishop
  • 2
  • 2
4 Comments
 
LVL 68

Accepted Solution

by:
Qlemo earned 500 total points
Comment Utility
I suspect the Invoke-SqlCmd being blocked, though you are not using locks and allow for dirty reads in that query. Did you check whether that cmdlet returns? Since you have issues with that particular machine with both PS2 and PS3, something here seems to be buggy.

Other than that, some parts seem to be overly complicated. Instead of the System.Diagnostics classes, you could just use PS background jobs, which are much easier to handle.
Also you are checking modules and ODBC on each call of GetParameterValue, instead only once at start of the script. I understand you want to encapsulate the check, but I would do so in another function you only have to call once.

IMHO, this part:
	$msg = "In order to properly import data, the Microsoft Office System `n"
	$msg += "Driver, Data Connectivity Components must be installed.`n"
	$msg += "These drivers allow import of data from Microsoft sources (e.g.`n"
	$msg += "Excel spreadsheets, Access databases, etc.). The components`n"
	$msg += "can be downloaded from Microsoft at the following link:`n"
	$msg += "http://www.microsoft.com/en-us/download/details.aspx?id=23734`n`n"
	$msg += "Would you like to download and install these components now`n"
	$msg += "(you must have Internet connectivity to download)?"

Open in new window

would be better written as
	$msg = @"
In order to properly import data, the Microsoft Office System
Driver, Data Connectivity Components must be installed.
These drivers allow import of data from Microsoft sources (e.g.
Excel spreadsheets, Access databases, etc.). The components
can be downloaded from Microsoft at the following link:
http://www.microsoft.com/en-us/download/details.aspx?id=23734

Would you like to download and install these components now
you must have Internet connectivity to download)?
"@

Open in new window

0
 
LVL 15

Author Closing Comment

by:dbbishop
Comment Utility
For some reason localhost did not work. I needed to use the server name. The server name is one of the values read from the parms.csv file.
0
 
LVL 68

Expert Comment

by:Qlemo
Comment Utility
You should definitely look at that. Does it work if you use the "." for the server, or "(local)"? Maybe shared memory or Named Pipe is excempt, and you need to use TCP/IP for MSSQL.
0
 
LVL 15

Author Comment

by:dbbishop
Comment Utility
It was no problem. Made to be portable so server name is in a parameter file. 'localhost' worked on the other servers I ran the code against.
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

How to leverage one TLS certificate to encrypt Microsoft SQL traffic and Remote Desktop Services, versus creating multiple tickets for the same server.
Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now