I am trying to use Set-SqlNetworkConfiguration
to set the TCP port of a SQL Server instance. The command looks like this:
Set-SqlNetworkConfiguration -Protocol TCP -Port 1433 -ServerInstance $ENV:ComputerName\SQLSERVER
However, the command prompts for credentials with a GUI prompt. There's the -Credential
parameter, but examples I've found use Get-Credential
which, again, shows a UI prompt.
How do I run Set-SqlNetworkConfiguration
with the current user's credentials without displaying any GUI prompts and without hard-coding credentials in a script? I have absolutely no need to explicitly set a username and password; the current user has administrator permissions for the given SQL Server instance.