June 16, 2020

1758 words 9 mins read

PowerShell vs CMD: Unlocking the Power of Windows

PowerShell vs CMD: Unlocking the Power of Windows

Windows PowerShell, as its name suggests, is a powerful automated task framework from Microsoft. The tool, which debuted alongside Windows 7, includes more than 130 standard command-line tools for functions and enables administrators to perform tasks on local and remote Windows systems. It may be more complicated, but PowerShell’s functionality is far more advanced than Microsoft’s previous comman

d-line interfaces (CLIs). These began with command.com, which was the interpreter for MS-DOS and the shell in Windows 9x systems. Microsoft superseded this in Windows NT with CMD.exe, which added features like better error messages, command line completion, and native access to the command history. SEE MORE The best Registry hacks for fixing annoying Windows features SEE MORE 8 killer new Windows 10 features for 2019 SEE MORE Best Windows 10 tips and tricks for power users PowerShell began as a project called the Microsoft Shell (AKA Monad) in 2002, but it wasn’t until 2006 that the company renamed it and integrated it into Windows 7. Since then, PowerShell has been an integrated component in the Windows OS. Although CMD.exe coexists with PowerShell, its influence is gradually eroding. Microsoft officially replaced it with PowerShell as the default command shell accessible from File Explorer in November 2017. So why the shift to PowerShell? CMD.exe was a limited tool. You could use it to run basic administrative commands on a machine, but you couldn’t manage 400 at once, nor could you manage things remotely, such as virtual servers in the cloud.  Though CMD.exe doesn’t do those things, PowerShell supports add-on functionality to manage machines in Microsoft’s Azure cloud, such as creating, controlling, and monitoring virtual machines, and configuring cloud storage. Jeffrey Snover, the head of the PowerShell project team, designed the tool as the missing link between Microsoft’s GUI-based administrative tools and the rich set of application programming interfaces (APIs) that expose the company’s .NET framework. He wanted a single command-line tool to support both developers and administrators. In this sense, PowerShell was one of the first forays into what became DevOps, a practice that promotes collaboration between developers and operations teams. What can PowerShell do?  Unlike CMD.exe, PowerShell is an object-oriented tool. Objects are representations of items like files and directories that have their own properties and actions that you can call upon in the CLI. PowerShell understands everything in Windows as an object but also lets you create your own object types. PowerShell enables admins to get at these objects using more sophisticated commands than you’ll find in CMD.exe. One of the tool’s key innovations is its use of commandlets (CMDlets). These are small programmes (as little as a dozen lines of code) that can carry out specific tasks using .NET’s APIs. They can execute an object’s methods, query and change its attributes, and return objects as their results. CMDlets come in a simple verb-noun form and enable you to get things done quickly. For example, typing Get-Member gives you information about an object, like its properties or attributes. Get-Member won’t do much on its own, though. You need a pipeline, another thing that wasn’t available in CMD.exe. Unix and Linux users have enjoyed pipelines for decades, and it’s just one command that PowerShell supports from the Bash shell that’s common to those systems. A pipeline lets you take the output of one command and ‘pipe’ it to another, which takes it as input. You depict a pipeline using |. Say you want to create an object in PowerShell: $message = Write-Output ‘PowerShell is awesome’ You’ve just used the Write-Output CMDlet to assign some text to what many languages would call a variable. Except in PowerShell, it’s not a variable; it’s an object with its own methods and properties. You can list them all by piping the $message object to Get-Member:`$message | Get-Member' You can pipe lots of CMDlets together to create extensive chains of commands, like a conveyor belt of workers adapting something and passing it on to the next person. Piping aside, this kind of object-oriented programming will be familiar to developers who work with languages like Python. You can even make the object give up certain information about itself using the object’s name, a dot, and the property name. For example: $message.Length returns 21 You can create CMDlets yourself in a variety of languages, including Microsoft’s own C#. An alternative approach to creating your own PowerShell programmes is to write scripts, which are collections of PowerShell commands collected together into a file that you can run. Although cmd.exe also allows scripts, PowerShell provides its own interactive scripting environment (PowerShell ISE) with a range of extra features like Intellisense, which gives you context-aware method and property options as you’re typing. There’s another thing PowerShell gives you that cmd.exe doesn’t: the ability to create modules. These are packages of related scripts and/or CMDlets that call upon each other to help carry out a bigger task. You can share lots of complementary scripts and CMDlets far more easily as a module. Sharing is a big part of the PowerShell story. For example, there’s a PowerShell gallery containing thousands of scripts and modules from developers. PowerShell keeps evolving In 2016, PowerShell was taken open source as PowerShell Core, and since then it has been ported over to Linux and macOS as an alternative to the common Bash shell. However, if you’re planning on installing PowerShell on something other than Windows, you’re also going to have to lift .NET Core (the open source equivalent to Windows .NET) onto the system too. It’s also important to keep in mind that some functionality won’t transfer over - for example, it won’t support the ISE scripting environment. PowerShell has been updated and expanded upon over the years since, with new functionality and support for classes (objects that can be used as templates to create other objects), as well as integrations with things like Visual Studio Code - which is available for both the native Windows and open source versions. So now you know its history and how it works, the question then becomes: Should you use it? The learning curve might seem steep at first, but it’s actually easier to use than you might think. If you can get past that initial hump, then you’ll find that PowerShell offers some genuinely worthwhile features, even if you don’t use each one of them all the time. After all, it’s better to have a powerful toolbox with a set of tools you rarely use, than relying on a 20-year-old set of pliers.

Date: 2019-09-30

URL: http://feeds.itpro.co.uk/~r/ITPro/Today/~3/1ro4U5KYDms/powershell-vs-cmd-unlocking-the-power-of-windows

itpro.co.uk

Microsoft Surface Laptop Go review: Another shrunk-down Surface (2020-11-03) Its Go time once again for Microsoft After the excellent Surface Go 2 a smaller and more affordable alternative to the main Surface Pro series the company has applied the same thinking to its Surface Laptop line The result is the Surface Laptop Go Microsofts smallest clamshell laptop to date - albeit one that inherits many qualities of its parent products Microsoft Surface Laptop Go review: Design.. Microsoft Surface Laptop Go review: Another shrunk-down Surface
BBC hit with over 250,000 phishing emails every day (2020-11-02) The British Broadcasting Corporation BBC receives over a quarter of a million malicious email attacks every day according to a Freedom of Information FOI request bythe Parliament Street think tanks cyber security team The BBC blocked an average of 283597 scam or spam emails a day over the first eight months of 2020 reportingan average of 6704188 malicious emails per month Between January and Augus..
Phishing attacks surge ahead of Black Friday and Cyber Monday (2020-11-17) Security researchers have observed a sharp increase in the number ofphishing exploits in the run-up to Black Friday and Cyber Monday According to a new Check Point Software report phishing emails have increased by over 13 times in the last six weeks Currently one in every 826 emails delivered is a phishing attempt compared to less than one in 11000 at the start of October SEE MORE What is phishing..
Microsoft warns of growing “digital divide” between state and private schools (2020-12-04) Just 1% of public primary schools are able to provide hardware for pupils to take home compared to 38% of private schools according to a new surveyby Microsoft The figures were only slightly better for secondary level with just 7% of state schools able to provide devices for students against 20% of private schools SEE MORE The coronavirus pandemic has transformed the workplace more than any disrup..
Lenovo ThinkBook 13s review gallery (2020-12-02) This business-focused laptop is a bargain for undemanding businesses
OnePlus 7T Pro review gallery (2020-11-27) The latest from OnePlus doesnt dazzle but doesnt disappoint
Qualcomm’s Snapdragon 888 will power next year’s Android flagships (2020-12-02) Qualcomm has unveiled the latest model of its flagship smartphone chip awarding it a lucky number according to Chinese tradition The Snapdragon 888 which was announced at this weeks Qualcomm Technologies Snapdragon Tech Summit Digital 2020 as the companys first 5n smartphone SoC features the third-generation of Qualcomms Snapdragon X60 5G Modem-RF System It supportsmmWave and sub-6GHzacross all ma..
How to move Windows 10 from your old hard drive to SSD (2019-03-31) Solid-state drives SSDs offer a marked improvement in speed and stability over their older spinning disc counterparts and while at one time SSDs were considered expensive luxuries its now possible to grab 1TB drives for around 100 These falling prices have made the humble mechanical hard drive near obsolete for all but the largest of storage needs and if you were to buy a new PC or laptop today it..
5G will reach more than one billion people by end of 2020 (2020-11-30) 5G coverage is expected to reach 15% of the worlds population more than one billion people by the end of this year according to a new report by Ericsson The Swedish telecoms companyhas raised its year-end 2020 estimate for global 5G subscriptions to 220 million out of which 175 million of those - almost 80% - will be based in China This is due to the faster-than-average 5G uptake in China where th.. 5G will reach more than one billion people by end of 2020
Marriott International fined £18.4m for 2014 data breach (2020-10-30) The UK data regulator has issued Marriott International with a watered-down 184 millionfine for a data breach that affected339 million guest records worldwide The sum has been significantly reduced from the initial 99 million notice of intent to finethat theInformation Commissioners Office ICO first issued the hotel chain in July 2019 SEE MORE British Airways dodges 183 million data breach fine af..