Stairway to SQL PowerShell Level 2: SQL PowerShell Setup and Config

  • Comments posted to this topic are about the item Stairway to SQL PowerShell Level 2: SQL PowerShell Setup and Config



    Ben Miller
    Microsoft Certified Master: SQL Server, SQL MVP
    @DBAduck - http://dbaduck.com

  • Very informative articles. Thank you for sharing!

    There is a minor error that threw me for a bit of a loop. In listing 2.3, you mention the code to load the Extended SMO assembly is:

    [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SqlServer.Smo.Extended")

    This did not work for me. I read a bit further, and noticed in Listing 2.4, the code is this:

    [System.Reflection.Assembly]::LoadWithPartialName(“Microsoft.SqlServer.SmoExtended”)

    Listing 2.3 has an extra period between "Smo" and "Extended". Removing it allowed me to get the desired output.

  • Thanks. I will submit a change.



    Ben Miller
    Microsoft Certified Master: SQL Server, SQL MVP
    @DBAduck - http://dbaduck.com

  • Great set of articles. I am really enjoying working through them.

    Is it just me or are these articles from the future?!?!? Level 2 is dated the 15th Aug 2012 and Level 3 is dated the 29th!

  • Someone got their hands on a delorean.

  • I think it just means that I am a really good author 🙂



    Ben Miller
    Microsoft Certified Master: SQL Server, SQL MVP
    @DBAduck - http://dbaduck.com

  • Hello guys!!! The article is very good. I have little to no understanding on the subject of PowerShell. I would like begining to learn the ropes. However, I can not find the PowerShell folder in my Programs Menu. I have Windows XP SP3 installed, and I am running with a non-administrator user. Can you help me in any way ?

    Thanks in advance.

    Regards.

    Ariel.

  • Ariel, if you go to the previous Level in this stairway you will see where you can get PowerShell for WinXP SP3. In the table there it shows that there is no native PowerShell in WinXP, so use the link in the Level 1 to go and get it and install it.

    Then you can go to the Level 2 and start to play.

    http://www.sqlservercentral.com/articles/Stairway+Series/90381/



    Ben Miller
    Microsoft Certified Master: SQL Server, SQL MVP
    @DBAduck - http://dbaduck.com

  • I read the Level 1 part, and I understood that PowerShell does not install nativelly in Windows XP. But my Windows XP box has Microsoft SQL Server 2008 R2 installed. For it to be installed one of the requirements is PowerShell 2.0, so I had to install it first. Could it be that the installer does not put a shortcut to the program in the Menu Folder ? Am I missing something else ?

    Thanks for the very fast answer.

    Regards.

    Ariel.

  • Ariel,

    It's under Start/All Programs/Accessories/Windows PowerShell

    I have SS2008 Express and don't seem to recall that PS 2.0 was needed for the installation.

    I installed PS 2.0 using the download shown in the Level 1 article.

  • Ben,

    Exactly what kind of syntax is this SQLSERVER:\SQL\localhost\default?

    I can understand that in place of 'localhost' you can put the computer name and in place of 'default' you can put the instance name. But what exactly is the 'SQLSERVER:\SQL' part? How can it vary?

    This even works pointed to a SS 2005 and SS 2000 installation. Neat!

    And I discovered the right click by pure chance which is the equivalent of PASTE. Neat!

  • I really appreciated the article. It took me a little bit to get the last few examples to work, but it was only because I was using "localhost" rather than my machine's name/instance. Once I got that sorted, I had success with all of it. I look forward to future steps.

  • SQLSERVER:\SQL is a PSDrive and path.

    If you use Get-PSDrive you will see that there is a SQLSERVER: drive and SQL is a path under SQL Server.

    You can see which paths you have access to in the drive by using:

    cd SQLSERVER:

    dir

    You will see that SQL is the path for the SQL database engine, and there are more.



    Ben Miller
    Microsoft Certified Master: SQL Server, SQL MVP
    @DBAduck - http://dbaduck.com

  • Hi all, I'm having a little bit of a problem with one of the command lines erroring out and I am not sure why. When I try:

    "$server = Get-Item SQLSERVER:\SQL\localhost\default"

    I get several lines of the same error:

    "WARNING: Could not obtain SQL Server Service information. An attempt to connect

    to WMI on 'localhost' failed with the following error: An exception occurred

    in SMO while trying to manage a service. --> Failed to retrieve data for this"

    Any clue why? Any help appreciated. P.S. When I try using the SMO, instead of using the provider, all is fine and dandy.

    TIA,

    Raphael

  • This is due to not having Administrative privileges on the machine you are going against. So on the remote machine you have to be able do administrative things so being in the BUILTIN\Administrators group. And on the local machine, the Powershell window being run in Adminstrator Mode (right click and choose Run As Administrator).

    Let me know if that does not help, but I have seen that error message because of these issues.



    Ben Miller
    Microsoft Certified Master: SQL Server, SQL MVP
    @DBAduck - http://dbaduck.com

Viewing 15 posts - 1 through 15 (of 33 total)

You must be logged in to reply to this topic. Login to reply