0

I have the following script that grabs an Excel file and loads it to an SQL Server database. It works perfectly fine when executed in Powershell ISE:

Import-Module DBATools
Import-Module ImportExcel

$File = "S:\Shares\Reporting\File.xlsx"
$Instance = "10.24.10.100"
$Password = ConvertTo-SecureString "Password" -AsPlainText -Force
$Credential = New-Object System.Management.Automation.PSCredential ("User", $Password)
$Database = "ESS_TAB"
$Table = "DB_DATA_AUTO"

$Data = Import-Excel -Path $File | ConvertTo-DbaDataTable
Write-DbaDataTable -SqlInstance $Instance -SqlCredential $Credential -Database $Database -InputObject $Data -Table $Table

If I try to run it from anywhere else I just get a cursor. There is never and error it just runs endlessly.

John
  • 1
  • 1
    State from previous runs can linger in the ISE. If you restart it, does it still work? – mklement0 Jan 17 '23 at 20:29
  • 2
    As an aside: The PowerShell ISE is [no longer actively developed](https://docs.microsoft.com/en-us/powershell/scripting/components/ise/introducing-the-windows-powershell-ise#support) and [there are reasons not to use it](https://stackoverflow.com/a/57134096/45375) (bottom section), notably not being able to run PowerShell (Core) 6+. The actively developed, cross-platform editor that offers the best PowerShell development experience is [Visual Studio Code](https://code.visualstudio.com/) with its [PowerShell extension](https://marketplace.visualstudio.com/items?itemName=ms-vscode.PowerShell). – mklement0 Jan 17 '23 at 20:31
  • Check permissions – Bogdan Sahlean Jan 18 '23 at 07:18

0 Answers0