Results 1 to 3 of 3
  1. #1
    Join Date
    Jun 2005
    Posts
    319

    Unanswered: powershell WMI error

    On our dev server we're running this version:

    Microsoft SQL Server 2005 - 9.00.4035.00 (X64) Nov 24 2008 16:17:31 Copyright (c) 1988-2005 Microsoft Corporation Enterprise Edition (64-bit) on Windows NT 5.2 (Build 3790: Service Pack 2)

    My SSMS version is: 10.50.1600.1

    The error I get when I click on Powershell context menu from within SSMS is:

    WARNING: Could not obtain SQL Server Service information. An attempt to connect to WMI on '{database}' failed with the following error: Access is denied.
    (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))

    Any ideas?

  2. #2
    Join Date
    Jun 2005
    Posts
    319
    it might only work w/ sql 2008, I get no errors when I do the same action on my local server that is running sql 2008 R2

  3. #3
    Join Date
    Jun 2005
    Posts
    319
    OK, I tried running the script below from Windows PowerShell 2.0 Administrator's Pocket Consultant:

    first I ran sqlps as Administrator and then cd into C:\ where my script is stored and typing:

    ./sql_init

    Code:
    #
    # Add the SQL Server PowerShell Provider, if available
    $ErrorActionPreference = "Stop"
    $sqlpsreg="HKLM:\SOFTWARE\Microsoft\PowerShell\1\ShellIds\Microsoft.SqlServer.Managemement.PowerShell.sqlps"
    
    if (Get-ChildItem $sqlpsreg -ErrorAction "SilentlyContinue")
    { throw "SQL Server Powershell Provider is not installed."
    } else {
    	$item = Get-ItemProperty $sqlpsreg
    	$sqlpsPath = [System.IO.Path]::GetDirectoryName($item.Path)
    }
    
    #
    # Set global variables
    Set-Variable SqlServerMaximumChildItems 0 -scope Global
    Set-Variable SqlServerConnectionTimeout 30 -scope Global
    Set-Variable SqlServerIncludeSystemObjects $false -scope Global
    Set-Variable SqlServerMaximumTabCompletion 1000 -scope Global
    
    #
    # Load the SQL Server  Management Objects
    $assemblylist = "Microsoft.Sqlserver.Smo",
    "Microsoft.SqlServer.Dmf ",
    "Microsoft.SqlServer.SqlWmiManagement ",
    "Microsoft.SqlServer.ConnectionInfo ",
    "Microsoft.SqlServer.SmoExtended ",
    "Microsoft.SqlServer.Management.RegisteredServers ",
    "Microsoft.SqlServer.Management.Sdk.Sfc ",
    "Microsoft.SqlServer.SqlEnum ",
    "Microsoft.SqlServer.RegSvrEnum ",
    "Microsoft.SqlServer.WmiEnum ",
    "Microsoft.SqlServer.ServiceBrokerEnum ",
    "Microsoft.SqlServer.ConnectionInfoExtended ",
    "Microsoft.SqlServer.Management.Collector ",
    "Microsoft.SqlServer.Management.CollectorEnum "
    
    foreach ($asm in $assemblylist)
    { $asm = [Reflection.Assembly]::LoadWithPartialName($asm) }
    
    #
    # Load SQL Server snapins, type data and format data
    Push-Location
    cd $sqlpsPath
    Add-PSSnapin SqlServerCmdletSnapin100
    Add-PSSnapin SqlServerProviderSnapin100
    Update-TypeData -PrependPath SQLProvider.Types.ps1xml
    Update-FormatData -PrependPath SQLProvider.Format.ps1xml
    Pop-Location
    I get this error:
    Code:
    Get-ItemProperty : Cannot find path 'HKLM:\SOFTWARE\Microsoft\PowerShell\1\Shel
    lIds\Microsoft.SqlServer.Managemement.PowerShell.sqlps' because it does not exi
    st.
    At C:\sql_init.ps1:9 char:26
    +     $item = Get-ItemProperty <<<<  $sqlpsreg
        + CategoryInfo          : ObjectNotFound: (HKLM:\SOFTWARE\...owerShell.sql
       ps:String) [Get-ItemProperty], ItemNotFoundException
        + FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.GetIt
       emPropertyCommand
    I verified that registry entry exists, not sure what is causing the error. Also do I need to run the initialization script above to get access to the sql cmdlets?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •