Monthly Archives: April 2013

PowerSQL -Recycle SQL Instance (Remote or Local)

We have a scheduled maintenance window to recycle SQL SERVER Instance once in 30 days hence created a PowerShell job where function being placed along with parameters(servername and instancename) and executed it across all SQLinstance. (Named or Default instance) Default instance-> MSSQLSERVER  and … Continue reading

Posted in PowerShell, SQL | Tagged | Leave a comment

PowerSQL – Generate Only Index Script of All Tables or Specific Tables

Background of this implementation-As a part of Performance tuning, We noticed huge avg_disk_queue_length on F drive after analysis, we’ve recommended to move two tables(data and index)to different drive all together a different filegroup.  This would give the best IO performance. Those … Continue reading

Posted in PowerShell, SQL | Tagged | 2 Comments

PowerSQL – Database Backup Report across all Servers – Centralized Approach

This topic provides and describes the quickest way to find when and what databases are being backed up recently.Backups are most important part of a recovery strategy. In this case, I’m explaining this process in three steps 1) Instance names … Continue reading

Posted in PowerShell, SQL | 5 Comments

PowerShell – Get an UNC of a remote folder

To Read/Write/Rename/Copy/Delete a file configured across ‘N’ of servers in the same path, this script is going to be very handy. One example – Citrix Migration – IMA data store Input – ServerName and Input folder path. $server =”Server01“ $InputPath=”C:\Program … Continue reading

Posted in PowerShell | Leave a comment

SQL – Table data – HTML Format & Email Sending using T-SQL

1) Configure DBMail  – In this case the ‘TEST’ profile being created for the demo 2) Create Table – TLOG_Metrics 3) Insert the dumnmy values or You can schedule a job to store the data in TLOG_Metrics table 4) Execute … Continue reading

Posted in SQL | 3 Comments

PowerSQL – Find and Replace string on multiple file of local or remote machine

Copy and Paste the below content in Set-FindandReplaceString.PS1. Please read the instructions carefully. Try to do a dry run on some test folders for better results. ############################################################################# # Description : Find and Replace string on any local or remote machine # … Continue reading

Posted in PowerShell | Leave a comment

Power Shell or Windows – Rebooting of servers local or remote computers

Rebooting of servers local or remote Using PowerShell and Windows Powershell command Start->Run->Powershell press enter PS:\>RESTART-COMPUTER -COMPUTERNAME SERVER01, SERVER02,LOCALHOST Windows Command Start->Run->cmd press enter c:\>shutdown /m \\server01 /r /f /t 02 /m \\Server A remote computer to shutdown – server01 … Continue reading

Posted in PowerShell | Leave a comment

SQL – DBCC CLEANTABLE – DROP UNUSED COLUMNS

Drop those columns which are no more in use. For example, After Upgrade from MOSS 2007 to SharePoint Server 2010, we have noticed that all of the upgraded databases in SharePoint Server 2010 were almost 40% – 60% larger in size … Continue reading

Posted in SQL | Leave a comment

PowerShell – Find Disk Drive Details of local or remote Server

Name of the Function : Get-DiskDriveDetails Input Parameter : ServerName Ouptut : Grid view, you can sort and force condition on specific output column Function call : Get-DiskDriveDetails HQDB001 In this case HQDB001 is Name of the Server Code: Function Get-DiskDriveDetails([String]$server){Get-WMIObject Win32_LogicalDisk … Continue reading

Posted in PowerShell | Leave a comment

PowerShell – Find top 10 Largest files of a local or remote Drive

Name of the function: Get-LargestFile The Input parameters are ServerName and Drive. Function call PS:\>Get-LargestFile -server HQDB001-drive e In this case HQDB001[ServerName] and E[Drive] **************************** Code:- *********************** Function Get-LargestFile { Param([String]$server,[char]$drive) Get-ChildItem \\$server\$drive$ -recurse -force -ErrorAction SilentlyContinue | Select-object Name,DirectoryName, @{Label=’Size’;Expression={($_.Length/1GB).ToString(‘F04′)}} … Continue reading

Posted in PowerShell | 2 Comments