Category Archives: PowerShell

Find failed SQL Job in last 24 Hours using Powershell

This post is based on the request to get failed SQL jobs in last 24 hours and output should be displayed in a HTML format. The verification of SQL job steps code is taken from the below blog. http://www.sqlservercentral.com/blogs/sqlsandwiches/2012/01/29/find-failed-sql-jobs-with-powershell/ The … Continue reading

Posted in PowerShell, SQL, T-SQL | Tagged , | 12 Comments

PowerShell – Backup Individual database and delete all it’s respective files by keeping a recent file

Problem Statement The requirement is to backup individual database and after successful backup the script should retain the most recent file and delete the rest from a directory for that specific database. The below Powershell script is used to backup a … Continue reading

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

PowerShell- Monitoring Multiple Services On Multiple Servers Using WMI Class -Win32_Service

The requirement is to check only those services where startup mode set to Auto and services that stopped. In my previous post have used Get-Service cmdlet which do not bind any such information hence I’m querying Win32_Service. This class has StartMode and … Continue reading

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

Mailbox Statistics report with Email addresses

Script to collect and export the mailbox properties from Get-Mailbox and Get-MailboxStatistics cmdlets to a CSV file This script can be extended based on the required attributes Get-Mailbox -ResultSize Unlimited  |  Select-Object DisplayName,  SamAccountName,servername,database, RecipientTypeDetails,PrimarySmtpAddress, HiddenFromAddressListsEnabled, @{label=”ItemCount”;expression={(Get-MailboxStatistics $_).ItemCount}}, @{label=”TotalItemSize”;expression={(Get-MailboxStatistics $_).TotalItemSize}},   @{label=”DeletedItemCount”;expression={(Get-MailboxStatistics $_).DeletedItemCount}}, @{label=”TotalDeletedItemSize”;expression={(Get-MailboxStatistics $_).TotalDeletedItemSize}}, @{label=”MailboxGuid”;expression={(Get-MailboxStatistics $_).MailboxGuid}}, @{label=”LastLogoffTime”;expression={(Get-MailboxStatistics $_).LastLogoffTime}},  @{label=”LastLogonTime”;expression={(Get-MailboxStatistics $_).LastLogonTime}},IssueWarningQuota, ProhibitSendQuota   Export-Csv “Path to the output file ” -NoTypeInformation

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

How to Replace Multiple Strings in a File using PowerShell

Replace the Data Source and Initial Catalog values of WebConfig.XML Content of XML file <Configuration ConfiguredType=”Property” Path=”\Package.Connections[ConnStaging].Properties[ConnectionString]” ValueType=”String”> <ConfiguredValue>Data Source=localhost;Initial Catalog=Stage;Integrated Security=SSPI; Connection Timeout = 10</ConfiguredValue> </Configuration> PARAM( [String]$DatabaseName=’DCTarget’, [String]$XML=’c:\webconfig.XML’, [String]$DatabaseServer=’DataCenterDB01′) [string]$db = ‘Catalog=’+ $DatabaseName [string]$dbs = ‘Source=’+ $DatabaseServer (Get-Content $XML) | … Continue reading

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

Determine size of the file using T-SQL/Powershell/Ole Objects

There are many ways to find the filesize. This post is all about identifing the filesize using T-SQL,Instantiating OLE Objects and PowerShell. The requirement is to retrieve the size of the specified file. The return value is going to a … Continue reading

Posted in PowerShell, SQL, T-SQL | Tagged , , , , , | Leave a comment

INVENTORY – SQL- SSAS – SSRS – Excel Output – Email

Inventory 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, SSAS, SSRS, T-SQL | Tagged , , , , , , , | 2 Comments

PowerShell – SSRS Inventory – Automatic – Excel File – EMAIL

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. Download the file and save as SSRSInventory.PS1. It has five mandatory parameters InputFileName – Text File … Continue reading

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

PowerShellGUI Tools – Disk,Memory and Process – Modules

I’ve created a script which gives details of Disk, Memory and Process and its represented graphically. Here, the scripts are enclosed in module. At its simplest, a module is just a PowerShell script, contained in a file with a .PSM1 extension A module … Continue reading

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