Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Import-DbaCsv keeping lock on file after execution #890

Open
5 tasks
ALZDBA opened this issue Sep 22, 2022 · 0 comments
Open
5 tasks

Import-DbaCsv keeping lock on file after execution #890

ALZDBA opened this issue Sep 22, 2022 · 0 comments

Comments

@ALZDBA
Copy link

ALZDBA commented Sep 22, 2022

Bug Report

General Troubleshooting steps

  • Verified running the latest release of dbachecks?

Does (Find-Module dbachecks).Version match (Get-Module dbachecks).Version.ToString()
CommandType Name Version Source


Function Import-DbaCsv 1.1.134 dbatools
image

  • Verified errors are not related to permissions?
  • Can duplicate in new/clean PowerShell session (clean = powershell -NoProfile)?

Version Information

  • Operating System (Name|Version):
  • PowerShell Version:
  • SQL Server (Edition|Version):

Steps to Reproduce

<--
PLEASE include as much information as possible if this is a bug report.
The more you include the faster we can identify the problem and get it fixed
-->

  • Attach any screenshots (if possible/allowed)
  • Attach output from PowerShell console (if possible/allowed)

Description of Bug

<--
PLEASE include as much information as possible if this is a bug
Explain what it does that you would like it not to do
or
What it doesnt do that you would like it to do :-)
-->
$AllCSV = Get-ChildItem -Path $SourceFolder -Filter '*.csv' | Select -ExpandProperty Fullname | sort
foreach ( $csv in $AllCSV ) {
Import-DbaCsv -path $csv -SqlInstance $MyAppConfig.SQLServer -SqlCredential $cred
Move-Item -Path $csv -Destination $ArchiveFolder -Force ;
}

Move-Item : The process cannot access the file because it is being used by another process.
At C:\Users\itsme\Documents\Powershell\DEV\Import-Results\Import-Events2SQLServer.ps1:275 char:17

  • ... Move-Item -Path $csv -Destination $ArchiveFolder -Force ...
  •             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
  • CategoryInfo : WriteError: (C:\Res...0922_130643.csv:FileInfo) [Move-Item], IOException
  • FullyQualifiedErrorId : MoveFileInfoItemIOError,Microsoft.PowerShell.Commands.MoveItemCommand
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant