Category: Powershell

PowerShell Write-Progress

Windows PowerShell Write-Progress The purpose of this cmdlet is to provide a green bar, which confirms that a time-consuming script is indeed running.  The secret of getting Write-Progress to work is positioning the cmdlet in the loop correctly. Windows PowerShell Write-Progress Topics Understanding the Elements of a Write-Progress Script Example …

PowerShell Remove-PSDrive

PowerShell's Get, Then Remove Technique My main task for Remove-PSDrive is when testing scripts.  If I want to run code for a second time, it often makes sense to undo the previous instruction. I also want to emphasise the simple, but useful Get-xyz, then Remove-xyz technique. Topics for Windows PowerShell …

PowerShell Start-Sleep

PowerShell’s Start-Sleep Cmdlet Most scripting languages have the ability to pause, in the case of PowerShell look for a built-in cmdlet called Start-Sleep.  However, I ask myself, ‘Do I really need to pause a script?’  The answer often comes back, ‘Windows services have built-in controls to wait, thus I rarely …

PowerShell 3.0 Redirection

PowerShell 3.0 New Redirection Commands From the beginning PowerShell has had the ability to redirect output with | (pipeline), Out-File and the old (>).  Now in PowerShell 3.0 we have the ability to tweak (>) so that we can save warnings and debug information to a text file. Windows PowerShell …

PowerShell Get-NetIPConfiguration

PowerShell 3.0’s Best Network Cmdlet Get-NetIPConfiguration reminds me of IPConfig, and it shows the basic TCP/IP information much more easily than using PowerShell Gwmi classes. Tutorial for PowerShell’s Get-NetIPConfiguration Basic Get-NetIPConfiguration Command More Information with Get-NetIPConfiguration Tuning the Output of Get-NetIPConfiguration Get-NetIPConfiguration – Alias GIP Creating a Function Get-IPConfig  ♣ …

PowerShell Set-Content

PowerShell Script Files: Set-Content Cmdlet I don’t use Set-Content very often; this is because for routine tasks that need to save content to a file I prefer to use Out-File.  The one job that I have for the Set-Content cmdlet is editing a file with -Replace.  What makes me wary …

PowerShell Get-Childitem -Filter

PowerShell GCI -Filter Parameter Filter is the most useful parameter to refine the output of PowerShell cmdlets such as Get-ChildItem (gci).  I much prefer -Filter to -Include or -Exclude. Topics for Get-ChildItem -Filter Example 1: List Only .dll Files with GCI -Filter Example 2: Compare -Filter with -Include PowerShell Commands …