Quantcast
Channel: Windows PowerShell forum
Viewing all articles
Browse latest Browse all 21975

Use of SQLSERVER:\SQLPolicy pointing to a specific instance causes accesses to unrelated Instances

$
0
0

Running Powershell 3 on W2012 server using SQL Server 2012

Within Powershell ISE

import-module"sqlps"-disablenamechecking

 (Get-ItemSQLSERVER:\SQLPolicy\server1\Instance1).fred()

Returns (as expected)

Method invocation failed because [Microsoft.SqlServer.Management.Dmf.PolicyStore] doesn't contain a method named 'fred'.

At line:2 char:2

+ (Get-Item SQLSERVER:\SQLPolicy\server1\Instance1).fred()

+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

   + CategoryInfo         : InvalidOperation: (:) [], RuntimeException

   + FullyQualifiedErrorId : MethodNotFound

 

What is unexpected is that a trace on an unrelated Instance (Instance2) shows the following commands being executed

select SERVERPROPERTY(N'servername')

DECLARE @edition sysname; SET @edition = cast(SERVERPROPERTY(N'EDITION') as sysname); select case when @edition = N'SQL Azure' then 2 else 1 end as 'DatabaseEngineType'

It would appear that Powershell (SQLPS) has gone through every registered Instance on the ‘Server1’ and issued these commands even though I have specified a full path to ‘Instance1’.

This behaviour also occurs when a valid Operation is requested eg

     (Get-Item SQLSERVER:\SQLPolicy\server1\Instance1).EraseSystemHealthPhantomRecords()

The behaviour has impacts in the following areas:

All Instances on the server, for which the account running the commands does not have access, report an access error

Login failed for user 'xxxxxx\yyyyyyyy'. Reason: Could not find a login matching the name provided. [CLIENT: <local machine>]

All instances on server1 that are currently not running would undoubtably delay the execution while the connection attempt times out.

Is this behaviour as expected?



Viewing all articles
Browse latest Browse all 21975

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>