Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Function MyFunction{
- Param
- (
- [string]$S = "MyServer",
- [string]$U,
- [string]$P
- )
- # Find the SQL Engine version
- $Q = "select serverproperty('ProductVersion')"
- if($U)
- {
- $R = Invoke-Sqlcmd -ServerInstance $S -Query $Q -Username $U -Password $P -Verbose
- Write-Host "SQL Athenticated"
- }
- else
- {
- $R = Invoke-Sqlcmd -ServerInstance $S -Query $Q -Verbose
- Write-Host "Windows Athenticated"
- }
- return $R.column1
- }
- Invoke-Expression "$R = Invoke-Sqlcmd -ServerInstance $S -Query $Q $(if($true){""-Username $U -Password $P""})"
- Function MyFunction{
- Param
- (
- [string]$S = "xps15",
- [string]$U,
- [string]$P
- )
- # Find the SQL Engine version
- $Q = "select serverproperty('ProductVersion')"
- $auth=@{}
- if($U){$auth=@{UserName=$U;Password=$P}}
- $R = Invoke-Sqlcmd -ServerInstance $S -Query $Q -Verbose @Auth
- return $R.column1
- }
- Function MyFunction{
- Param
- (
- [string]$S = "MyServer",
- [string]$U,
- [string]$P
- )
- # Find the SQL Engine version
- $Q = "select serverproperty('ProductVersion')"
- if($U)
- {
- $auth=@{UserName=$u;Password=$p}
- Write-Host "SQL Authenticated"
- }
- else
- {
- $auth=@{}
- Write-Host "Windows Authenticated"
- }
- $R = Invoke-Sqlcmd -ServerInstance $S -Query $Q -Verbose @Auth
- return $R.column1
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement