George2
George2

Reputation: 45801

Error stopping a Windows Service

I am using PowerShell 1.0 on Windows Server 2003 x64. When executing the following statement, there is error below. Not every time this error occurs, and if this error occurs and I execute this command again, there is no error again! It is so weird. Any ideas what is wrong?

Stop-Service "SQLServerAgent" -Force -ErrorAction:stop

WARNING: Waiting for service 'SQL Server Agent (MSSQLSERVER) (SQLSERVERAGENT)' 
to finish stopping...
out-lineoutput : The OS handle's position is not what FileStream expected. Do n
ot use a handle simultaneously in one FileStream and in Win32 code or another F
ileStream. This may cause data loss.

thanks in advance, George

Upvotes: 2

Views: 3132

Answers (2)

Mitch Wheat
Mitch Wheat

Reputation: 300769

This is bug in PowerShell.

Please see Lee Holmes' post for a Workaround: The OS handle's position is not what FileStream expected

Upvotes: 7

Philip
Philip

Reputation: 1551

Workarounds didn't work for me. Switched to using start-transcript at the start of the script instead. Doesn't the output of the programs you run, but there are workarounds.

Upvotes: 0

Related Questions