Beginning in PowerShell 3.0, there is a new automatic variable available called $PSScriptRoot. This variable previously was only available within...
posts-powershell
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
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
Converting SID from Binary to String Active Directory accounts contain the SID in binary form. To convert the byte array into a string...
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 characters...
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. Accessing the Raw Licensing Data in...
Stripping Decimals Without Rounding
Extracting the Integer Part of a Division Result When you divide numbers and just want the decimals before the decimal point, you could cast the...
Removing Multiple White Spaces
Removing multiple white spaces from text is easy in PowerShell. -replace operator Simply use -replace operator and look for whitespaces ("\s") that...
Sending Emails with Special Characters
Send Emails with PowerShell Using Send-MailMessage PowerShell has built-in support for sending emails: Send-MailMessage! All you need is an SMTP...
Ignoring Empty Lines
Reading Text Files and Skipping Blank Lines To read in a text file and skip blank lines, try this: $file = 'c:\sometextfile.txt' Get-Content $file |...
Writing Registry Key Default Values
Set the default value for a registry key If you need to set the default value for a registry key, you can use either of these approaches:...
Case-Sensitive Hash Tables
PowerShell hash tables PowerShell hash tables are, by default, not case sensitive: PS > $hash = @{} PS > $hash.Key = 1 PS > $hash.keY = 2...
Making sure PowerShell scripts run in 32-bit
Dealing with 32-bit Dependencies in a 64-bit Environment If you are using code that can only run in a 32-bit environment (i.e. using old database...
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...
Checking Whether Hash Table Contains Key
Understanding the Limitation of Hash Tables Compared to Switch Statements In the previous tip, you used a hash table to translate input values....
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...
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
Convert ASCII value to a character To convert the ASCII value to a character, use type casting like this: [char]65 Convert a character to ASCII...
Validating a URL
Validating User Input as a URL Using System.URI To make sure user input is a valid URL, you can use the System.URI type. Try to convert the raw...
Assigning Multiple Variables
Refer the code : In PowerShell, you can initialize multiple variables in just one line. The following line sets all variables to the value 1: $a =...