• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

Think PowerShell

PowerShell for IT Pros

  • About
    • Who I Am
    • Why I Blog
    • Privacy Policy
  • Resources
    • More PowerShell Sites
    • Post Series Index
  • Get Help
  • Show Search
Hide Search

Aaron Rothstein

How to Make a PowerShell Progress Bar

Aaron Rothstein · Oct 20, 2017 · 2 Comments

 

Roll your own PowerShell progress bar.
Roll your own PowerShell progress bar.

Some cmdlets have a progress bar built-in. Here’s how to make your own Powershell progress bar with the Write-Progress cmdlet.

What’s happening?

In my last post, I covered how to hide PowerShell progress bars you encounter with some built-in cmdlets. More often than not though, you probably want to keep these progress bars as they are typically there to give the script executor feedback that the script is indeed running, and how far along it is in step execution.

Microsoft has done a good job recognizing which cmdlets likely will have longer execution times (like Install-WindowsFeature), but what if you have a process that you know could take a while to complete? How can you give your user feedback that the script is actively working and to give an idea of how much work has been done, while also giving an impression of how much work is left to do?

[Read more…] about How to Make a PowerShell Progress Bar

Hide PowerShell Progress Bars

Aaron Rothstein · Oct 18, 2017 · 3 Comments

PowerShell progress bar in action.
PowerShell progress bar in action.

PowerShell progress bars don’t hurt anything, but they don’t always add value. Here’s how to hide them.

Progress Bars: What are they good for?

We are a species that craves to know the current state of things, and if we can’t be told that, at least we wan’t to know SOMETHING is happening. And because of this fundamental truth, we have spinning circles, hour glasses of old, and progress bars.

My favorite progress bars are the ones that aren’t actually progress bars at all because they don’t actually tell you far how you have progressed through a process. They are more like animated gifs of a bar filling to let you know that SOMETHING is happening, much like the spinning wheel.

PowerShell progress bars are at least true progress bars; the increase in percentage and the bar itself is tied back to underlying execution logic. So if you feel compelled to watch, at least you are seeing an actual progress status.

[Read more…] about Hide PowerShell Progress Bars

PowerShell Splatting: What is it, Why Use It

Aaron Rothstein · Oct 17, 2017 · 5 Comments

Splatting with a hash table.
Splatting with a hash table.

Make your PowerShell scripts easier to read with splatting.

No one likes horizontal scrolling

The format of PowerShell cmdlets make them universally easy to use. Enter the cmdlet name, then enter the various parameter switches and values for those parameters. For a lot of commands, everything can fit cleanly on one line and within either the standard 80 character width of a standard prompt or the full screen width of your favorite editor.

However, there are going to be times you want to specify a LOT of parameters, and some of those parameter values may be lengthy in nature. The last thing you want to do though is have to start scrolling sideways or trying to wrap your “one-liner” to read it.

[Read more…] about PowerShell Splatting: What is it, Why Use It

Configuring Windows DHCP, Part 3: Creating DHCP Reservations

Aaron Rothstein · Aug 22, 2017 · 2 Comments

A DHCP reservation.
A DHCP reservation.

Need to mix the convenience of DHCP with the consistency of a static IP? Use a DHCP reservation, and create them with PowerShell.

DHCP reservations explained

DHCP empowers us to automatically assign IP addresses to clients while adhering to standardized rules (address space, lease duration, DNS servers, etc). For most clients, we typically don’t care what IP address the client ends up with on any given day, but for other devices consistently connected to the network, there are benefits to having the device get the same IP every time. A prime example that everyone can relate to is a printer. If you have the printer shared through a print server, the print server needs to be able to consistently talk to the printer on a known IP address.

“A DHCP reservation is a permanent IP address assignment. It is a specific IP address within a DHCP scope that is permanently reserved for leased use to a specific DHCP client” (tech-faq.com).

In the previous post we created DHCP scopes. Let’s see how we can use PowerShell to create a DHCP reservation within one of those scopes.

[Read more…] about Configuring Windows DHCP, Part 3: Creating DHCP Reservations

Configuring Windows DHCP, Part 2: Creating DHCP Scopes

Aaron Rothstein · Aug 21, 2017 · Leave a Comment

DHCP Scopes
DHCP Scopes

Use PowerShell to create dynamically assigned ranges of IP addresses using DHCP scopes.

What is a DHCP scope?

Per TechNet, a DHCP scope “is the consecutive range of possible IP addresses that the DHCP server can lease to clients on a subnet. Scopes typically define a single physical subnet on your network to which DHCP services are offered. Scopes are the primary way for the DHCP server to manage distribution and assignment of IP addresses and any related configuration parameters to DHCP clients on the network.”

Let’s say you have three subnets on your local network, 192.168.1.0/24, 192.168.2.0/24, and 192.168.3.0/24. The first subnet, 192.168.1.0/24, is a server and network management subnet where all IPs are statically assigned. For this subnet, you would not need to configure a DHCP scope.

For the other subnets, 192.168.2.0/24 is for your wired clients and 192.168.3.0/24 is for your wireless clients. These clients will connect and disconnect to the network throughout the day and week. For these subnets, you would configure a DHCP scope to handle the automatic assignment of IP address leases to these clients.

[Read more…] about Configuring Windows DHCP, Part 2: Creating DHCP Scopes

  • « Go to Previous Page
  • Go to page 1
  • Go to page 2
  • Go to page 3
  • Go to page 4
  • Go to page 5
  • Interim pages omitted …
  • Go to page 7
  • Go to Next Page »

Primary Sidebar

Aaron

Follow

Copyright © 2023 · Monochrome Pro on Genesis Framework · WordPress · Log in