Powershell Script for regular DBA activities

  • er.mayankshukla

    SSCarpal Tunnel

    Points: 4190

    Comments posted to this topic are about the item Powershell Script for regular DBA activities

  • akljfhnlaflkj

    SSC Guru

    Points: 76202

    Pretty nice bit of code, thanks.

  • er.mayankshukla

    SSCarpal Tunnel

    Points: 4190

    Thanks !!

  • Angelindiego

    SSCertifiable

    Points: 6048

    [System.Reflection.Assembly]::LoadWithPartialName("System.windows.forms") | Out-Null

    This first line of code throws me an error says it can't find it....so is it specific to a certain version of SQL??

    TIA!!


    Thank you!!,

    Angelindiego

  • er.mayankshukla

    SSCarpal Tunnel

    Points: 4190

    This assembly is required to call filesave and folderdialog box via powershell.

    Do you latest .net framework installed on your machine ?

  • er.mayankshukla

    SSCarpal Tunnel

    Points: 4190

    I use to call this powershell script via batch file.

    Here is the code for the batch file

    @echo off

    powershell -executionpolicy bypass -File C:\Users\mayank\Documents\Powershell\SqlMisc.ps1

    pause

    Just change the path for the powershell script

  • Angelindiego

    SSCertifiable

    Points: 6048

    er.mayankshukla - Wednesday, January 11, 2017 8:27 PM

    I use to call this powershell script via batch file.Here is the code for the batch file@echo offpowershell -executionpolicy bypass -File C:\Users\mayank\Documents\Powershell\SqlMisc.ps1pauseJust change the path for the powershell script

    THANK YOU!!!!!!!!


    Thank you!!,

    Angelindiego

  • Jeff Moden

    SSC Guru

    Points: 997113

    Such utilities can be easily used by the developers in the team without making them approach to DBA for such tasks on various development or testing environments.

    Who fixes it when either the MDF drive or the backup drive get's filled up?  Who fixes it when one developer does a restore over a database of another that has a lot of critical test data in it?

    I give my Developers a whole lot of freedom on the Dev boxes but backups and restores won't ever be one of them.

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.
    "Change is inevitable... change for the better is not".
    "Dear Lord... I'm a DBA so please give me patience because, if you give me strength, I'm going to need bail money too!"

    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

  • Sergiy

    SSC Guru

    Points: 109837

    > Who fixes it when either the MDF drive or the backup drive get's filled up?

    They can do it them self.

    They are all sysadmins, if they can execute those commands.

    So, they do not need anybody else to maintain the server.

  • georgian2133

    SSC Veteran

    Points: 298

    Tried to run the  script in our environment it gives below error.
    Please help to fix it. 

    Exception calling "Open" with "0" argument(s):
    "A network-related or instance-specific error occurred while establishing a connection to SQL Server.
    The server was not found or was not accessible.
    Verify that the instance name is correct an d that SQL Server is configured to allow remote connections.
    (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)"

Viewing 10 posts - 1 through 10 (of 10 total)

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