最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

invoke-sqlcmd on multiple server - limitation is that PS run with Windows admin only and SQL runs with DB admin account only - S

programmeradmin9浏览0评论

I have been trying so hard to use PowerShell command invoke-sqlcmd to run simple SQL queries on multiple SQL servers, where some are default instances servername and some are named instances ServerName\\InstanceName.

I have tried the following ways:
1: invoke-sqlcmd -ConnectionString $CN -Query $query ....
2: invoke-sqlcmd -Credential $adminSQL -Query $query ....
3: Start-Process powershell.exe -Credential $sysadminCred -ArgumentList "-NoExit", "-Command", "\$scriptBlock" ....

At first I was getting the typical error server not found....
Most of the time it was login failed because it keeps trying to use the WindowsAdmin account because I am logged in to server as WindowsAdmin, which has no DBA permission.

I hope you are successful or have done this already. Please share.

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论