concept computer name in category powershell

appears as: computer names, computer name, The computer name, computer names
Windows PowerShell in Action, Third Edition

This is an excerpt from Manning's book Windows PowerShell in Action, Third Edition.

You have many machines that need testing. Typing in the computer names one at a time is still too tedious. You can create a list of computers, either from a text file or in your code, and test them all:

You can simplify the approach because the -CimSession parameter on Get-Dsc-Configuration (and other cmdlets that have a -CimSession parameter) will take an array of computer names (or a single computer name) instead of a CIM session object. If you use a computer name, a CIM session will be created, used, and destroyed in the background. This is approach is fine if you’re performing a single action, but a CIM session is recommended if you’re performing multiple actions because it’s a more efficient technique.

18.3.1. Parameterizing the computer name

If you have a number of machines you need to apply exactly the same configuration to, the easiest approach is to parameterize the computer name.

Listing 18.4. Parameterizing the computer name
Configuration AddFile { param ( [Parameter(Mandatory=$true)] [string[]]$ComputerName 1 ) Import-DscResource –ModuleName PSDesiredStateConfiguration Node $ComputerName { 2 File TestFile { Ensure = 'Present' Type = 'File' DestinationPath = 'C:\TestFolder\TestFile1.txt' Contents = 'My first Configuration' Force = $true } } } AddFile -OutputPath .\MOF -ComputerName 'W16TGT01', 'W16DSC02' 3