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...
powertips
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
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...
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...
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...
Making sure PowerShell scripts run in 32-bit
If you are using code that can only run in a 32-bit environment (i.e. using old database drivers or COM objects), here is a solution that will...
Configuring WSMan Remotely for multiple computers
When working remotely in a peer-to-peer or cross-domain scenario, you will have to add all the computers you'd like to communicate with into the...
Getting Process Based On Window Title
It isn't always easy to pick the right process because the process ID or process name may not be known or ambiguous. If the process has a window...
Checking Whether Hash Table Contains Key
In the previous tip, you used a hash table to translate input values. However, unlike Switch-statements, Hash Tables have no "default" so...
List Hidden Files
Did you notice that Dir, ls or Get-ChildItem do not return hidden files? To see hidden files, you need to specify the -force parameter: Dir...
Calling VBScript From PowerShell
Sometimes, you may have an existing VBScript that already does just what you want. You can easily incorporate any VBScript into PowerShell because...
Returning Text Information From PowerShell To VBScript
In a previous tip, you learned how to call PowerShell statements and read their return value. Return values are somewhat limited because they can...
Encrypting PowerShell Scripts
Sometimes, you may want to hide the code of your PowerShell script in order to protect passwords contained within the code. One way to safely...
Accessing individual Files and Folders Remotely via WMI
WMI is an excellent way of remotely checking files or folders since it has the ability to access individual files and folders, and also works...
Converting ASCII and Characters
To convert the ASCII value to a character, use type casting like this: [char]65 To do the opposite and convert a character to its ascii value, use...
Validating a URL
To make sure user input is a valid URL, you can use the System.URI type. Try to convert the raw string into this type. If it works, the string is a...
Assigning Multiple Variables
In PowerShell, you can initialize multiple variables in just one line. The following line sets all variables to the value 1: $a = $b = $c = $d = 1...
Converting Hash Tables to Objects
Hash Tables are convenient but are not true objects. This is bad because you are unable to output the hash content to formatting cmdlets or export...