Solved

PowerShell Script 'Hangs' in 3.0

Posted on 2013-12-12
4
594 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
ID: 39714715
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
ID: 39714818
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
ID: 39714845
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
ID: 39715109
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

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to prepare an HTML email signature template file containing dynamic placeholders for users' Azure AD data. Furthermore, it explains how to use this file to remotely set up a department-wide email signature policy in Office …
A brief introduction to what I consider to be the best editor for PowerShell.
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…
Internet Business Fax to Email Made Easy - With  eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, f…

912 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

19 Experts available now in Live!

Get 1:1 Help Now