Renaming files is a common operation in windows, it’s simple enough to select a file and rename it using the context menu. But what if you have many files or need to automate file renaming? PowerShell reduces this operation to several simple commands with a for each object loop.
After a file copy is complete, how can you be sure the entire file was copied? This can be done with the file length command in PowerShell. This will compare the length in bytes of each file and, combined with an if statement, is a way to perform remediation on a failed file copy automatically.
PowerShell offers simple ways to perform administrative tasks such as checking the status of a service. This can be combined with an if statement to act on a stopped service automatically. These commands can be incorporated into a much larger script to check multiple services.
Drive space is a finite resource, ask any server administrator. No one wants to see the message, “No space on disk”, when you are trying to save that last document. How can you clean up files that you don’t need? As always, PowerShell makes it simple.
When numbers are stored as a string in a database, it is difficult to sort them, so they are readable to human users. PowerShell makes this operation simple, to take a string value, cast it as an integer, sort it by numeric value and create an output file with the sorted values.