It was a network issue. I was continually running the script to test every little change. Attempting to reconnect to all the remote computers constantly was too much for our small slow network.
Intermittent error "a specified logon does not exist"
-
05-07-2023 - |
Question
New to Powershell and scripting. I have the following script that intermittently returns the System error 1312 A specified logon does not exist. It may have already been terminated.
Get-Content D:\Logbooks.txt | ForEach-Object {Invoke-Command -computername $_ -FilePath "D:\Folder\Script.ps1" if (-not$?){Write-Warning "$_ - SQL SCRIPT FAILED"} else {Write-Host "$_ - SQL SCRIPT SUCCESSFUL"-ForegroundColor "Green"}}
I wrote that script to execute this one.
net use \computername\D$ password /User:username
sqlcmd -S .\SQLEXPRESS -o C:\test.txt -d database -i "\computername\D$\Folder\SQL Script.sql"
I am using these to execute a SQL script on remote machines running SQL Express. All computers are running Windows 7. I also created a second admin account on the computer I am running the scripts from and using that login after the net use command. It works fine sometimes but other times I get the error from only a couple of remote computers.
La solution