Learning PowerShell from scratch may seem daunting, but if you have a solid understanding of CMD, migrating your skill set over to the newer management framework might be simpler than you think.
The Windows command line, preceded by DOS in pre-Vista versions of Windows, still holds a lot of power for seasoned IT professionals. It can be leveraged to run scripted deployments, make changes to system settings, and basically make the system (or group of systems) behave exactly the way you want them to with minimal effort.
It’s the epitome of working smarter, not harder. And while CMD still exists in even the newest versions of Windows clients and servers, it is superseded by Microsoft’s PowerShell (PS) management framework. Even though the underlying premise remains the same, PS implements scripted changes differently, with immense power over everything a system can do.
In a previous article, we introduced 10 cmdlets to help make the transition from CMD to PowerShell. This time around, we’ll look at another batch of cmdlets that will help you learn how to manage devices with PS and move your existing scripts to the modern framework, which has been made open source and cross-platform with Linux and macOS.
1. List all commands
2. Clear the screen
3. Copy a file (or directory)
CMD: copy “source file/directory” “destination file/directory”
PS: Copy-Item “path/to/file/directory” -Destination “path/to/directory”
4. Delete a file
CMD: del “path/to/file”
PS: Remove-Item “path/to/file”
*Note: PowerShell cmdlet will also delete folders, not just files.
5. Remove a directory
CMD: rmdir “path/to/directory”
PS: Remove-Item path/to/directory”
6. Map network drives
CMD: net use Drive_letter “path/to/shared/folder”
PS: New-PSDrive -Name “Drive_Letter” -PSProvider “FileSystem” -Root “path/to/shared/directory”
7. Get running processes
8. Start/stop services
CMD: net start (or stop) “service name”
PS: Start-Service -Name “service name”
*Note: In PS, using “Stop-Service” will stop the desired service.
9. Get (or Set) ACLs for file/folder permissions
CMD: cacls “file or folder name” or cacls /E /P user:perm
10. Compare two files or directories
CMD: comp “path/to/file1” “path/to/file2”
PS: Compare-Object -ReferenceObject “path/to/file” -DifferenceObject “path/to/file”