Removing Accidental Deletion Protection By default, AD objects are protected from accidental deletion. To remove this protection for all objects in...
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
Using Green Checkmarks in Console Output
In a previous tip you have seen that the PowerShell console supports all characters available in a TrueType font. You just need to convert the...
Using Symbols in Console Output
Did you know that console output can contain special icons like checkmarks? All you need to do is set the console to a TrueType font like...
Removing Whitespace (and Line Breaks)
You may know that each string object has a method called Trim() that trims away whitespace both from the beginning and end of a string: $text = '...
Understanding break, continue, return, and exit
Understanding Control Flow: break, continue, return, and exit Do you know off-hand what "break", "continue", "return", and "exit" do? These are...
Getting Registry Values and Value Types
Get-ItemProperty can easily read registry values, but you do not get back any information about the registry value type. Get-ItemProperty -Path...
Using “more” in the PowerShell ISE
PowerShell ISE In the PowerShell console, you can pipe commands to the old-fashioned “more.com”, or better yet, to Out-Host –Paging. This will...
Measuring Website Response (and Execution Times)
PowerShell 3.0 and later Sometimes it is important to know just how long a command takes. For example, to monitor web site response times, you could...
Exporting Out-GridView Content
PowerShell 3.0 and later Out-GridView is a very useful cmdlet to output results to an extra window. Unlike outputting to the console, Out-GridView...
Finding Explicit Permissions
All PowerShell versions Typically, NTFS permissions in the file system are inherited. You can, however, add explicit permissions to files and...
Accessing COM Objects without ProgID
All Versions Typically, to access COM objects, these objects need to register themselves in the Windows Registry, and PowerShell needs the...
Changing GPO Description/Comment
GroupPolicy Module When you create a new Group Policy, you can set a comment (or description). There is no apparent way, however, to change the...
Replacing NTFS Permissions with SDDL Information
All PowerShell versions With Get-Acl, you can output the security information from files and folders as plain text in SDDL format (Security...
Getting the Number of Lines in a String
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...
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
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:...
HTML-Scraping with RegEx
Scraping Website Data with PowerShell To scrape valuable information from websites with PowerShell you can download the HTML code and then use...