Category Archives: PowerShell

SQL – MultiServer SQL Inventory – PowerShell

Inventory is a vital information,whether you’re a consultant or an in-house DBA, you need to have a reliable inventory of the servers you manage.This inventory can take any number of forms but, ideally, will allow some aggregation of information. When … Continue reading

Posted in PowerShell, SQL, Uncategorized | Tagged , , , , , | Leave a comment

PowerShell – Install PowerShell

Recently got a question regarding PowerShell installation hence this post took an existence. How to Install PowerShell various versions http://technet.microsoft.com/en-us/library/hh847837.aspx http://social.technet.microsoft.com/wiki/contents/articles/21016.how-to-install-windows-powershell-4-0.aspx Can we have more than one version of Powershell? Yes, You can have multiple versions PowerShell. How to switch … Continue reading

Posted in PowerShell | Leave a comment

PowerShell : Script Method Error -Method invocation failed because [Microsoft.SqlServer.Management.Smo.ServerRole] does not contain a method named ‘Script’.

I was working on generating scripts for logins, users and server roles and I could able to to generate scripts for users and logins but where as for server roles, the script() method is not working. The script is throwing following error … Continue reading

Posted in PowerShell | Tagged , , , | Leave a comment

The RPC server is unavailable. (Exception from HRESULT: 0x800706BA)

“The RPC server is unavailable. (Exception from HRESULT: 0x800706BA)” error may occur when executing PowerShell scripts using WMI query. There can be a few reasons for this error: The remote computer is blocked by the firewall. Solution: Open the Group … Continue reading

Posted in PowerShell | Tagged , , | Leave a comment

PowerShell : Scripting Logins, Role Assignments and Server Permissions Using PowerShell

This post is a continuation of Multiple DB refresh automation using PowerShell post . The OP requested me to automate the login transfer process as well. The script should generate an outfile and execute the file on the target server. <# .ProblemStatement Copying … Continue reading

Posted in PowerShell, SQL | Tagged , , | 6 Comments

PowerShell – SQL Database Refresh -Restore – Multiple Databases

.SYNOPSIS The purpose of the script is to restore database/s from a database backup. The requirement is to refresh ‘n’ databases. .DESCRIPTION The advantage is that the flexibility of passing restoreDbList to restore specific group of databases. The Restore databases has … Continue reading

Posted in PowerShell, SQL | Tagged , , | 7 Comments

PowerShell – Backup Specific group of SQL Databases

<# .SYNOPSIS The purpose of the script is to initiate backup only for desired group of databases. The requirement is to refresh databases. .DESCRIPTION The advantage is that the flexibility of passing a list of specific group of databases for … Continue reading

Posted in PowerShell, SQL | Tagged , , , | 2 Comments

PowerSehll : How to suppress the table heading and remove the blank space from a text file

There are a multiple ways to suppress and remove the first line from text file. The first scenario would be writing a suppressed heading to an output text file Or after writing, we can remove the line using trim function Or … Continue reading

Posted in PowerShell | Tagged , , | Leave a comment

PowerShell – SQL Databases Backup Status Report of Multiple Servers

  This post is a requirement from one of my blog reader. There are plenty of scripts available to get the backup status of the databases across multiple server. The  requirement is to read a server name and application names … Continue reading

Posted in Backup and Restore, PowerShell, SQL | Tagged , | 13 Comments

SQL DB Details Of Multiple Servers Using PowerShell

  One of my blog reader requested me to get the DB details(Server,DBName,Size,SpaceAvailable,LogSize,PercentUsed Log Space,compatiblilty mode, recovery model etc:-) using PowerShell hence this post is written. The power of PowerShell is to capture an output of DBCC commands and store … Continue reading

Posted in PowerShell, SQL | Tagged , | 4 Comments