ps1

Parsing Raw Text (Part 2)

In the previous tip we explained how you can use Select-String and a regular expression to extract valuable information from raw text results: PS...

read more

Parsing Raw Text (Part 1)

Sometimes, you may want to extract valuable information from pure text results. One easy way is the use of Select-String. This example extracts only...

read more

Adjusting Simple UIs

In the previous tip you learned how you can use Show-Command to create simple UIs for text-based commands: #requires -Version 3.0 function...

read more

Creating Simple UIs

Function and cmdlet parameters basically are the technique how PowerShell creates „user interfaces“. These text-based interfaces can...

read more

Extending Robocopy

PowerShell can add value to existing commands such as robocopy. Take a look at the below function--it uses robocopy to copy files, and adds the...

read more

Copy Color-Coded Code

When you select code in the PowerShell ISE and copy it to the clipboard, it is copied in RTF format and preserves all color coding and font...

read more

Capturing Linux Output

If you run PowerShell on Linux, you can combine Linux and PowerShell commands. To take the output of a Linux command and assign it to a PowerShell...

read more

Test for File or Folder

Test-Path can check whether a file or folder exists. If you add -PathType and specify Leaf (for files) or Container (for folders), the result can be...

read more

Creating Time Spans

You can use New-TimeSpan to define “amounts” of time, and then add or subtract them from dates. Here is an example: $1Day = New-TimeSpan...

read more

Finding Unapproved Verbs

Cmdlets and functions should use only approved verbs to make it easier on user to find commands, and improve consistency. Here is quick audit code...

read more

Creating File Shares

In Server 2012 R2 and Windows 8.1, there are many useful new modules with cmdlets such as New-SmbShare which creates new file shares easily. If you...

read more

Using Custom Scopes

When you change variables, you might need to clean up later and ensure that you reverted them back to some default value – unless you use...

read more
1 44 45 46 47 48 128