To find out which NTFS access permissions have been assigned directly to a file or folder, check for the property "isInherited". This will...
Powershell
Managing NTFS Permissions
In a previous tip we showed how you can add NTFS permission rules to a folder. To find out what kind of permissions are assignable, take a look at...
Create Folder with NTFS Permissions
Often, you may need to create a new folder and also set NTFS permissions for the folder. Here is a simple example that creates a new folder and...
Splitting Long Lines
To improve readability, you can break PowerShell lines into separate lines. Get-Service | Where-Object { $_.Status -eq 'Running' }...
Prompting for Function Parameters
With a simple trick, you can add a dialog window that helps users to provide the function parameters for your function. Simply use...
Using PowerShell’s Help Window for General Output
To display text information, you can of course launch notepad.exe, and use the editor to display the text. Displaying text in an editor is not such...
Playing Sound in the Background
If your script takes some time to complete, you may want to play a system sound file. Here is a sample illustrating how this can be done: # find...
Finding Executable
Many file extensions are associated with executables. You can then use Invoke-Item to open a document with this executable. Finding out just which...
Splitting Text at Uppercase Letters
To split a text at each uppercase letter, without having to provide a list of uppercase characters, try this example: $text =...
Finding Uppercase Characters
If you'd like to find uppercase characters, you could use regular expressions. However, you would then provide a list of uppercase characters to...
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...
Test Nested Depth
When you call a function, PowerShell increases the nest level. When a function calls another function, or script, this will again increase the nest...
Aborting Pipeline
Sometimes you might want to abort a pipeline when a certain condition is met. Here is a creative way of doing this. It works all the way back to...
"Continue" and Labels
When you use the "Continue" statement inside a loop, you can skip the remainder of this loop iteration, and continue with the next....
Get Memory Consumption
To get a rough understanding how much memory a script takes, or how much memory PowerShell puts aside when you store results in a variable, here is...
Use Closures to Lock Variables to Script Blocks
When you use variables inside a script block, the variables are evaluated when you run the script block. To lock variable content, you can create a...
Mutually Exclusive Parameters (Part 2)
Mutually exclusive parameters in PowerShell functions use the "ParameterSetName" attribute to assign parameters to different parameter...
Mutual Exclusive Parameters
Sometimes, PowerShell functions have parameters that should be mutually exclusive: the user should only be able to use either one, not both. To...
Parsing PowerShell Scripts
If you'd like to create your own color-coded PowerShell scripts, for example formatting them in HTML, here is a sample that gets you started....
Aborting the Pipeline
If you know beforehand how many results you expect from a pipeline, you can use Select-Object to stop the upstream cmdlets. This can save a lot of...
Passing Arrays to Pipeline
If a function returns more than one value, PowerShell wraps them in an array. However, if you pass the results to another function inside a...
Free PowerShell Module for Admins
One feedback we got on a previous tip directed us to "Carbon", a free PowerShell module crammed with useful PowerShell functions. One is...
Converting CSV to Excel File
PowerShell can easily create CSV files using Export-Csv, and if Microsoft Excel is installed on your system, PowerShell can then have Excel convert...