Evaluate Weigh the pros and cons of technologies, products and projects you are considering.

Small changes make a difference in PowerShell 5.0

Coming to the next versions of Windows, PowerShell 5.0 adds remote file-editing capabilities, as well as improvements to Desired State Configuration.

Windows PowerShell 5.0 includes lots of new features and capabilities that can improve the overall experience....

While some capabilities will only appeal to hardcore PowerShell developers, there are other new features and capabilities that will have a broader appeal. One such capability is remote file editing.

For a while, admins could establish a remote session to another Windows server through PowerShell. The new remote file-editing feature builds onto this existing capability, making it possible to establish a remote session and then edit a file on the remote computer.

Establishing a remote session works in much the same way as it always has. You can use the Enter-PSSession command, followed by the –ComputerName parameter and the name of the target system.  Next, simply enter the PSEdit command followed by the path and filename on the remote system.

If, for example, you wanted to edit a file named C:\Files\File.txt on a system named Server1, the commands for doing so would be:

Enter-PSSession –ComputerName Server1

PSEdit C:\Files\File.txt

Another updated PowerShell function is the Desired State Configuration. For those who aren't familiar with Desired State Configuration, it allows administrators to compare Windows servers against a desired state, and then take corrective action if the servers in question have deviated from the desired configuration.

The Desired State Configuration function has existed for a while now, but Microsoft has added a new parameter to it. This new parameter allows you to place a throttle limit on the desired State Configuration function. The idea behind this is that the Desired State Configuration function often runs against a large number of servers simultaneously. Doing so can consume an excessive amount of system resources. The throttle limit allows administrators to limit the number of concurrent Desired State Configuration operations that occur, thereby limiting system resource consumption.

Setting up throttle limits

The syntax involved in the Desired State Configuration function remains the same as previous versions, but with one difference; Microsoft has introduced a command-line switch known as –ThrottleLimit. This switch must be followed by the maximum desired number of simultaneous Desired State Configuration operations.

Getting the small details right

Perhaps the most welcome changes to PowerShell 5.0 involve its interface -- not the command set. One criticism of Windows PowerShell has been that the copy-and-paste functionality can yield somewhat unpredictable results. Microsoft has completely revised how copy and paste works.

The new functionality was introduced in the Windows 10 preview. If you go to the Windows PowerShell Properties sheet, you will notice that a new tab called Experimental has been added to the interface.

One of the big problems with copy and paste in Windows PowerShell was that if you selected multiple lines of code to copy, PowerShell treated each line individually rather than treating the block of code as a single command. For example, if you copied a long command that occupied four lines on the screen and then pasted that command into the PowerShell interface, PowerShell would insert line breaks between each line. This would result in a number of error messages. Figure 1 shows a check box that enables line-wrapping, which eliminates this problem.

Another annoying point of previous versions of the PowerShell interface was that if you resized the window, portions of the commands sometimes became hidden beyond the boundaries of the window. In version 5.0, however, you can shrink a window and have the text within it wrap to accommodate the new window size -- without hiding any text in the process.

This was last published in January 2015

Dig Deeper on Windows PowerShell Scripting

PRO+

Content

Find more PRO+ content and other member only offers, here.

Start the conversation

Send me notifications when other members comment.

By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Please create a username to comment.

-ADS BY GOOGLE

SearchServerVirtualization

SearchCloudComputing

SearchExchange

SearchSQLServer

SearchWinIT

SearchEnterpriseDesktop

SearchVirtualDesktop

Close