All PowerShell Versions Here is a clever trick how to find out how many lines a string (not a string array!) contains: $text = @' This is some...
database-tools
Categories
- Free tools
- SQL Compliance Manager
- SQL Defrag Manager
- SQL Diagnostic Manager for MySQL
- SQL Diagnostic Manager for SQL Server
- SQL Diagnostic Manager Pro
- SQL Inventory Manager
- SQL Query Tuner for SQL Server
- SQL Safe Backup
- SQL Secure
- SQL Workload Analysis for SQL Server
- Uptime Infrastructure Monitor Formerly Uptime
Finding Minimum and Maximum Values
All PowerShell Versions To find the smallest and largest item in a range of numbers, use Measure-Object: $list = 1,4,3,1,3,12,990 $result = $list |...
Getting Files with Specific Extensions Only
All PowerShell versions When you use Get-ChildItem to get a list of files, you may have noticed that the -Filter parameter occasionally returns more...
Testing UNC Paths
Test-Path can test whether or not a given file or folder exists. This works fine for paths that use a drive letter, but can fail with pure UNC...
Exporting and Importing Credentials in PowerShell
Credential objects contain a username and a password. You can create them using Get-Credential, and then supply this object to any cmdlet that has...
Use $PSScriptRoot to Load Resources
Beginning in PowerShell 3.0, there is a new automatic variable available called $PSScriptRoot. This variable previously was only available within...
Getting More Than 1000 Active Directory Results
By default, Active Directory returns only the first 1000 search results when you use an ADSISearcher. This is a security mechanism designed to...
Converting Binary SID to String SID
Active Directory accounts contain the SID in binary form. To convert the byte array into a string representation, use a .NET function like this: #...
Converting Excel CSV to UTF8
When you export Microsoft Excel spreadsheets to CSV files, Excel by default saves CSV files in ANSI encoding. That's bad because special...
Make Parameters Mandatory and Optional at the Same Time
An often overlooked feature in PowerShell is the ability to make a function parameter both optional and mandatory - at the same time. Let's for...
Enabling Visual Styles
When you use Windows Forms dialogs and windows, you may have noticed that they show differently, depending on whether you launched your script from...
Test Local User Account Credentials
Here is a snippet that verifies a local user account. Simply submit a username and a password. You get back either $true or $false: $username =...
Using RegEx to Filter Files
Get-ChildItem supports basic wildcards, but it does not support the rich feature set of regular expressions. If you combine Get-ChildItem with...
Finding User Account with WMI
WMI represents all kinds of physical and logical entities on your machine. It also has classes that represent user accounts which include both local...
Increase SQL Server Performance Using Multiple Files
By default, SQL Server databases are comprised of two files: the primary data file (or .mdf) and the log file (or .ldf). It is, however, possible to...
Change Order of CSV Columns
If you have a CSV file and would like to change the order of columns, simply import it into PowerShell, use Select-Object to change the order, and...
Check Windows License Status
In a previous tip we explained how you can use slmgr, a built-in VBScript, to check Windows licensing state. The core information used by this...
Tips for Optimizing XML in SQL Server
I’ve worked on a project that used XML heavily inside SQL Server. We really utilized SQL Server’s XML support almost to the full extent,...
Chapter 18. WMI: Windows Management Instrumentation
Stripping Decimals Without Rounding
When you divide numbers and just want the decimals before the decimal point, you could cast the result to integer. However, this would also round...
Removing Multiple White Spaces
Removing multiple white spaces from text is easy in PowerShell. Simply use -replace operator and look for whitespaces ("\s") that occur...
Sending Emails with Special Characters
PowerShell has built-in support for sending emails: Send-MailMessage! All you need is an SMTP server. However, with standard encoding you may run...
Ignoring Empty Lines
To read in a text file and skip blank lines, try this: $file = 'c:\sometextfile.txt' Get-Content $file | Where-Object { $_.Trim() -ne...
Writing Registry Key Default Values
If you need to set the default value for a registry key, you can use either of these approaches: Set-ItemProperty -Path HKCU:\Software\Somekey -Name...
Aqua Data Studio is crashing, not responding, or showing other signs of unstable behavior. What do I do?
Aqua Data Studio is crashing, not responding, or showing other signs of unstable behavior. Response Jonathan Powers over 11 years ago Unstable...
Aqua Data Studio is running out of memory. How do I increase it?
Aqua Data Studio is running out of memory. How do I increase it? Response Jonathan Powers over 11 years ago Memory Allocation in Aqua Data Studio If...
Aqua Data Studio gets disconnected after a certain period of time.
Aqua Data Studio gets disconnected after a certain period of time. Response Tariq Rahiman over 11 years ago Timeouts: ADS periodically gets...
How do I connect to Teradata with LDAP?
How do I connect to Teradata with LDAP authentication using Aqua Data Studio? Response Niels Gron over 11 years ago The authentication mechanism for...
HTML-Scraping with RegEx
To scrape valuable information from websites with PowerShell you can download the HTML code and then use regular expressions to extract what you are...
Case-Sensitive Hash Tables
PowerShell hash tables are, by default, not case sensitive: PS > $hash = @{} PS > $hash.Key = 1 PS > $hash.keY = 2 PS > $hash.KEY 2 If...