How to open PowerShell, all methods. Windows PowerShell: what is this program How to open a power shell on Windows 10

After switching to the Windows 10 operating system, many users noticed the "Launch PowerShell" button in the Explorer interface. In this regard, a lot of questions appeared on the network, users were interested in what kind of Windows PowerShell program it was and what it was for. If you are also interested in this question, then this material should help you.

Windows PowerShell is a scripting language and a program with an interface command line to run these scripts. This language was released in 2006 as part of the second service pack for Windows XP and since then PowerShell has been part of all operating systems from Microsoft. In 2008, the second version of this language appeared, and since Windows 7 it has been used. Files with Windows PowerShell scripts have the PS1 extension and can be run as familiar BAT and CMD files.

Windows PowerShell is a scripting language that was developed primarily for Microsoft business customers who need powerful tools to automate the tasks of managing Windows servers and computers. The .NET platform developed by Microsoft since 2002 was used as the basis for this language.

Windows PowerShell lets you automate a wide variety of tasks. With it, you can manage files, services, processes, accounts, and settings. The PowerShell language understands many commands from the regular Command Windows strings(CMD), but it also has its own language, consisting of its own commands, here called cmdlets.

Cmdlets (in English cmdlets) are formed according to the Verb-Noun rule, for example, Get-Help. You can learn the basics of Windows PowerShell using Help (the "Get-Help" cmdlet). For general information, simply type "Get-Help", for help on a specific cmdlet, type "Get-Help Cmdlet-Name". For example, if you enter the command "Get-Help Get-Process", we will get help about the Get-Process cmdlet.

How to run a Windows PowerShell program

You can run a Windows PowerShell program different ways. The easiest option is to simply use the search in the Start menu. To do this, open the Start menu, type search query"Windows PowerShell", then open the found program.

You can also use a combination Windows key-R and enter the "powershell" command.

In Windows 10, the PowerShell program can be launched from any folder. To do this, click on the "File" button in the upper left corner of the Explorer and select "Start Windows PowerShell".

How to use the Windows PowerShell program

As we have already said, with the help of the PowerShell program, you can automate many routine tasks in the Windows operating system. As an example, we will demonstrate some of the features that this tool has in order to understand how to use it.

Emptying the basket. There is a special cmdlet for clearing the recycle bin called "Clear-RecycleBin". This cmdlet is useful when writing scripts for servicing computers. When you run the cmdlet, you must specify the drive on which you want to empty the Recycle Bin. Example:

Clear-Recycle Bin c:

The screenshot below shows how this cmdlet is executed. After entering the "Clear-RecycleBin c:" command, a confirmation message appears. In order to continue running the cmdlet, you need to type the letter "Y" and press Enter.

If you add "-Force" to the "Clear-RecycleBin c:" cmdlet, then the recycle bin will be cleared without asking for confirmation. Screenshot below.

File archiving. To archive and unpack files, the Compress-Archive and Expand-Archive cmdlets are provided. For example, in order to archive the folder "C:\test\" into the archive "C:\archive\test2.zip", you need to run the following cmdlet:

Compress-Archive -LiteralPath C:\test\ -DestinationPath C:\archive\test2.zip

As a result of executing the above command, the file “test2.zip” will appear in the “C:\archive\” folder, in which the contents of the “C:\test\” folder will be archived.

List of cmdlets for Windows PowerShell

For Windows PowerShell, there are a huge number of different cmdlets and it will not work to describe them all in one article. Therefore, we suggest that you familiarize yourself with the most popular of them:

  • Get-Help - getting help;
  • Update-Help – help update;
  • Get-Command - search for cmdlets;
  • Get-Alias ​​- search for aliases for cmdlets;
  • Get-PSDrive - view connected drives;
  • Get-Member - view the properties and methods that an object has;
  • Get-WindowsFeature - view information about available server roles and features;
  • Install-WindowsFeature (similar to Add-WindowsFeature) - installs roles or features on the desired server;
  • Uninstall-WindowsFeature (similar to Remove-WindowsFeature) - removes server roles or features;
  • Get-History - view the history of commands that were entered in this session;
  • Get-Variable - view the list of variables and their values;
  • New-Variable - creating a new variable;
  • Set-Variable - setting the value of a variable;
  • Clear-Variable - deleting the value of a variable;
  • Remove-Variable - remove a variable and its value;
  • Format-List - view the result of the command as a list of properties, where each line has a separate property;
  • Format-Table - view the result of the command in table format;
  • Format-Wide - view the result of the command as a wide table that shows only one property for each object;
  • Format-Custom - view the result of the command using a custom view;
  • Export-Csv - export data to CSV format;
  • Import-Csv - import data from a CSV file;
  • Export-Clixml - export data to XML format;

You can get a complete list of Windows PowerShell cmdlets by running the "Get-Command -CommandType cmdlet" cmdlet.

Some time has already passed since the launch of the final release of the latest operating system from Microsoft and not only enthusiasts testing intermediate builds, but also those users who have downloaded the long-awaited update have already managed to get acquainted with it. Is it good new system or not? Is this the latest innovative product or just the G8 that was supposed to come out at the time? These are questions that cannot be answered unambiguously anyway. In addition to the obvious innovations, which include the Start menu that appeared in the system, the browser Microsoft Edge, compatibility with Xbox, search and task view integrated with Cortana, there are a number of other innovations that not every Windows 10 user knows about.

And one of these innovations is the ability to install software products directly by means Windows shells PowerShell, which will be discussed later in this article. Despite the fact that this functionality appeared back in April 2014, along with the release of Windows Management Framework 5.0 Preview, it could become native only with the final release of the “tens”. So, let's see which module is responsible for this functionality and how you can install software products without downloading installation files.

Windows PowerShell OneGet Module

Since the release of Windows Management Framework 5.0 Preview, Windows PowerShell has several new features designed to make it easier to manage computers. These features include two intriguing technologies, namely Windows PowerShell Desired State Configuration and Certified for Windows network switches.

In the case of Certified for Windows Network Switches, a number of Windows PowerShell cmdlets have been added that are responsible for managing Windows-certified network switches. That is, there are 19 new cmdlets that you can find by running the “Get-Command *-NetworkSwitch*” command in the PowerShell shell. Since the technology is quite serious and deserves special attention, in this article I will limit myself to a small description and will not consider this technology in more detail.

But the second technology should be discussed in more detail. When Windows installation Management Framework 5 or operating Windows systems 10 you can use the tool that allows you to significantly simplify the search and installation on your computers software. OneGet is such a tool. OneGet is a package management aggregator, that is, a module using special repositories that provides a single interface for discovering, installing, and inventorying software. In other words, this technology, on the one hand, provides a set of cmdlets that allow the end user to manage installation packages (which we will discuss a little later), and on the other hand, it provides an interface for writing vendor packages.

Before we begin to deal with the module itself, you should pay attention to several definitions that are closely related to this technology, namely:

  • Package. In a nutshell, a package is a program that is built and installed from a specific source using any accessible system package management. Typically, a package provides compiled code, with additional meta information, which may include a description of the package, its version, or "dependencies". A package management system, for example, to execute automatic update software product to new version, in order to ensure that all package dependencies will be installed, must process such meta information and, if necessary, must automatically install any missing packages;
  • repository. According to Wikipedia, repositories are places where data is stored and maintained. Most often, the data in the repository is stored in the form of files available for further distribution over the network. Repositories were originally used by Linux systems, allowing you to install packages needed to run the system from other locations. Most repositories are free, but some companies provide access to their own repositories for paid subscription. We will talk about OneGet repositories a little later;
  • Package Manager. Represents a set software tools responsible for automating the process of installing, updating, configuring, and uninstalling software packages. Typically, packages include a database that lists software prerequisites and dependencies, as well as product version information to prevent non-working software products from being used. Package managers include the Linux apt-get or NuGet, which later appeared on Windows systems. In turn, OnetGet is a logical extension of NuGet, acting as an aggregator for all available package managers, called providers.

Initially, Microsoft limits the use of most of the available providers by providing a base set that allows you to discover and install additional providers to manage your software. Key providers include:

  • Bootstrap– a provider that allows other providers to be discovered;
  • MSI– a provider designed to process MSI files;
  • MSU– in turn, the vendor responsible for handling Microsoft update files;
  • ARP(Add/Remove programs) - a provider responsible for inventory data about any software product that is registered in the "Remove or change a program" component of the system;
  • PowerShellGet- A provider that allows you to manage various PowerShell modules.

Full list of OneGet providers with their brief description you can find from the following link.

The OneGet module itself includes 10 Windows PowerShell cmdlets, most of which will be covered in the next section of this article. These cmdlets include:

  • Find-Package - search for packages;
  • Get-Package - returns a list of all packages installed on the computer;
  • Get-PackageProvider - returns a list of providers that are on this computer connected to OneGet;
  • Get-PackageSource - Returns a list of package sources that are registered with a particular package provider.
  • Install-Package - allows you to install one or more software products;
  • Register-PackageSource - adding a package source for the specified package provider;
  • Save-Package - allows you to save the package to the local computer without subsequent installation;
  • Set-PackageSource - change for the specified package provider the source of the package;
  • Uninstall-Package - removal of one or more software packages;
  • Unregister-PackageSource - Remove a registered package source.
    • Installing software using OneGet

      So it's time for the process of installing software products. Next, you will see how you can install the package provider, find the required software, install it, and also how you can uninstall unnecessary application and download the installation package of the software product to your computer. Let's start in order.

      Installing the Chocolatey Package Provider

  1. Open Windows PowerShell and to display a list of package sources that are registered with OneGet at local computer run the command Get-PackageSource. Note that if you specify a specific package provider in the command, then the Get-PackageSource cmdlet will only show you the sources associated with the provider you specified. AT otherwise the command returns all package sources that are registered with OneGet. Since we need to view the package sources for all providers, the command will run without any additional parameters. Be sure to note that at this stage you have not yet installed an additional package provider that will be used to install software products. You can see the output of the command in the following image:

  2. As you can see in the previous illustration, the Chocolatey provider is not installed on our local machine. Therefore, this needs to be corrected. Note that to add a package provider, PowerShell's ExecutionPolicy must be set to Unrestricted. Otherwise, you will not be able to add the supplier. Let me remind you that the cmdlet Get-ExecutionPolicy allows you to display the execution policies for the current session. The execution policy is part of the Windows PowerShell security policy that determines whether configuration files can be loaded and scripts can be executed, and which scripts require a digital signature to run. The default value is " Restricted” (does not load configuration files and does not execute scripts), so if you have not changed the value of the execution policy for yourself, run the command Set-Executionpolicy Unrestricted. Since the default execution policy scope is LocalMachine, so that the policy settings apply only to the current user, you can add the parameter to the applied command –Scope with meaning CurrentUser. The output of these two commands can be seen in the following illustration:

  3. At this stage, we can see the list of providers that are registered with OneGet on the current computer. To do this, you can use the cmdlet Get-PackageProvider. This cmdlet, as I already mentioned a little above, returns a list of package providers that are already connected to OneGet. Optionally, you can filter the results based on all or part of one (several) vendor names. For example, to see which providers are connected to this moment, you must run the cmdlet Get-PackageProvider without any additional options. As you can see in the following illustration, initially I had 4 such providers connected to my computer, which I already told you about today. Now, to install the Chocolatey provider on your computer, you need to run the command Get-PackageProvider -Name Chocolatey -ForceBootstrap, where the –ForceBootstrap parameter is responsible for automatic installation supplier. Note that, as a general rule, when you install the Chocolatey provider, the NuGet provider must also be installed. As you can see in the following illustration, after reusing the cmdlet Get-PackageProvider, the provider we are installing should already appear in the list:

Now we can generate full list of all packages available in the providers and pipe it to the cmdlet Export-CliXML to create an XML representation of objects and save them in an XML file. Keep in mind that the list you export will be constantly changing and over time more and more packages will be added to the repositories you use. Accordingly, do not forget to replace the file you export from time to time. In order to export the list of packages and save this list in the C:\TestPosh folder, you need to run the following command: find-package | Export-CliXML C:\TestPosh\Test.xml

Please note that the export procedure will definitely take you some time. After the command finishes executing and an XML file is created on your computer, import it and, for ease of viewing, using the pipeline and the command gridview, which is responsible for displaying the results of the command in a window in the form of an interactive table, you can see which packages will be available for installation. Naturally, you can open this list of packages with any application that can process XML files, for example, by means of the same Excel. This command, as you can see in the following illustration, looks like this: Import-CliXML C:\TestPosh\Test.xml | Out GridView

Since the provider is already installed, you can proceed to the next part of this procedure, which is

Installing software using PowerShell

Before installing software products, we should look at what is already installed on the computer. To accomplish this task, you can use the cmdlet Get-Package, which returns a list of all software packages installed on the local machine, either through OneGet or other application installation tools. Optionally, you can also run the cmdlet Get-Package and on remote computers by running it as part of an Invoke-Command, an Enter-PSSession, or a script.

In the event that you want to receive information on specific software, for example, on installed products Microsoft Office 2013, you can use the –Name parameter along with this cmdlet with the appropriate value, for example, Get-Package -Name "office 2013". The output of this cmdlet is visible below:

Before installing the software, let's try to decide what we need to install. Since only Office 2013 and a few other applications are installed on the machine, next I will show you how you can install software products such as Adobe Creative Cloud, Adobe Reader, Notepad++, as well as Process Explorer, Process Monitor and WinRar.

Due to the fact that before the installation process itself, we need to localize the packages themselves, we should use the capabilities of the cmdlet Find-Package. As you noted a little earlier, this cmdlet allows you to search for installation packages in the package sources available on the local computer. In the event that you do not use any parameters with this cmdlet, the command will display a complete list of all applications, as was noted earlier.

For example, let's first try to find Adobe applications, which are available for installation from the Chocolatey provider we added. To do this, in addition to the cmdlet itself, it is enough to specify the parameter –Name and enter the desired software product as its value. Because installation packages may have a product name after the word Adobe, enter the product name as follows: Adobe* as shown in the following illustration. As you can see, the OneGet module found the following installation package in the repository: adobe-creative-cloud version 1.0. In principle, this is one of the products you are looking for, which means that it should be installed. To do this, as you can also see in the following illustration, you need to use the capabilities of the cmdlet Install-Package. To install Creative Cloud run the following command Install-Package -Name adobe-creative-cloud –Force, where the Force parameter, as is customary in PowerShell, overrides the restrictions that prevent the command from executing until changes begin to violate security requirements. The output of these commands can be seen in the following illustration:

Now, after the first software product has been installed, let's try to search certain version Adobe Reader. To do this, in addition to the already known command Find-Package –Name AdobeReader parameter should be added –AllVersions, which returns all available versions of a package, or all versions of a package that are in the range specified in the options MinimumVersion and MaximumVersion. Please note that this parameter is optional, since the search initially displays the latest version of the software product. Now, from all the available versions, we should choose the one that should be installed on the computer, for example, let it be the version 2015.007.20033 . in order to install this particular version of the reader, you should for the command Install-Package -Name AdobeReader add parameter –RequiredVersion with meaning 2015.007.20033 , which specifies the exact version of the package you want to install. You can also set the maximum available version product by adding parameter MaximumVersion with the corresponding value. The output of these commands is shown in the following illustration:

If you need to install the latest version of a software product and at the same time don't want to type multiple commands in PowerShell, you can generalize the package search and installation using a pipeline. For example, in the case of installing the latest version text editor Notepad++ you can run the following command: Find-Package -Name NotepadPlusPlus | Install-Package –Force. Thus, you search for a package in the repository and, if you find a result, immediately install it in silent mode. The installation process for this software product is shown below:

Now, since according to the above task, it remains to install Process Explorer, Process Monitor and WinRar, let's try to install several software packages at once. To do this, it is desirable to know exactly how these packages are called in the repository itself. As I wrote earlier, this can be checked using the cmdlet find-package | Out GridView. Once the package names are known, you can proceed with the installation itself. To do this, you can run the following command: Find-Package -Name procexp, procmon, winrar | Install-Package. AT this example, as you can see in the following illustration, I specifically do not specify the parameter force so that you can pay attention to the whole process of installing several software packages at the same time.

Saving and deleting programs

The last two cmdlets that will be discussed in this article are responsible for saving the installation package and removing the installed program. Let's start with saving.

In order to save the installation package, you can use the next cmdlet of the OneGet module, namely the module Save-Package. This cmdlet allows you to save packages to the local computer without installing them later. By default, this cmdlet saves the latest version of the software product, however, if you add the parameter to the current cmdlet AllVersions, all versions of the program you selected will be saved on your computer. Moreover, similar to the parameters of the search and installation cmdlets, in addition to saving all versions, using the parameters -MaximumVersion and –MinimumVersion, you can also select the version range of the package you wish to keep. To save the package on your computer, in addition to the option Name and, if necessary, a parameter that is responsible for the product version, you must specify the parameter Path with the future location of your installer.

As you can see in the following illustration, the command Save-Package -Name Procexp -Path C:\TestPosh save the latest version of Process Explorer to the C:\TestPosh folder:

If you accidentally installed the wrong package, you can always remove it using the OneGet module. To do this, use the cmdlet Uninstall-Package. As with the rest of the cmdlets in this module, you need to specify the Name parameter with the appropriate application name to remove the program, and you can also use the Force parameter to remove the program silently. For example, to remove previously installed WinRAR from your computer, you need to run the following command: Uninstall-Package -Name WinRAR -Force as below:

Conclusion

In this article, you learned about one of the features of the new operating system from Microsoft, namely the installation of software products using the Windows PowerShell command shell. I told you about the OneGet module itself, about the basic terminology used along with this technology, and about what pre-installed package providers exist. You learned how you can connect a third-party package provider to OneGet and how you can use it to find, install, save, and remove software products.

I hope that this information was useful for you and you learned something new for yourself. If you have any questions about the material of this article - ask them in the comments, I will be glad to provide any assistance.

VN:F

Rating: 9.9/ 10 (18 votes cast)

Installing programs using PowerShell in Windows 10, 9.9 out of 10 based on 18 ratings

Greetings!

Operating system Windows families has long had command line support, with a corresponding shell. However, Microsoft felt that the scripting language it supported was not flexible enough. As a result, Windows PowerShell was created as an alternative.

This command line shell is built into the system, but not everyone knows how to open it in order to execute the necessary commands in it. We will fill this gap by describing in detail and demonstrating in the images how to easily call Windows window PowerShell on Windows 10

Instructions for opening the Windows PowerShell window in Windows 10

The operating system provides several ways to open and use Windows PowerShell. Let's look at the easiest way first.


Video instruction

Well, about opening a useful tool built into the system called PowerShell, which was created to execute various commands and scripts based on them, we told in detail, now you can complete this material. I really hope that this material answered all your questions. See you!

It is difficult to find a person who would not wait new Windows 10. Interest was caused not only by visual, but also by functional changes. As planned by the developers, built-in applications make life easier for users, making it more comfortable. Problems with the store are possible in different occasions, but mostly they are related to upgrading to version 10. In some cases, not only the store is missing, but also the Edge browser.

Reinstallation can be done in different ways. But they are all related to the utility PowerShell, since the Windows 10 Store uninstall button in the app settings section is usually disabled. For this reason, this article also contains detailed information about getting up and running in PowerShell Windows 10.

Running the PowerShell utility

Store information search


Store installation


Removing the Windows 10 Store


Store quick setup method

Also for easy installation Windows Store 10, you can enter and execute the following code in PowerShell:
$manifest = (Get-AppxPackage Microsoft.WindowsStore).InstallLocation + "\AppxManifest.xml" ; Add-AppxPackage -DisableDevelopmentMode -Register $manifest

By mistake, you can run the code from the command line or application " Run". Keep in mind that the code must be run from the PowerShell shell, as detailed earlier.

Easy installation of all remote packages

If you are uninstalling only the store, you can simplify the installation process by running the command to install all remote Windows packages 10. Using the same code, it is easy to perform a mass installation of all previously deleted applications, thereby reinstalling all the necessary ones at once.

Enter code:
Get-AppxPackage -AllUsers| Foreach (Add-AppxPackage -DisableDevelopmentMode -Register “$($_.InstallLocation)\AppXManifest.xml”)
After that, it remains only to press Enter. Windows 10 will take some time to restore everything.

  • Sometimes the cause of runtime failures Windows applications 10 may become different installed antiviruses. Pay attention to them if the reinstallation does not go as described earlier.
  • It is better not to get carried away installing or removing built-in programs, as this may cause stability problems.
  • Also, if the information on your PC is important to you, it is recommended to create backups before taking any action.
  • The right thing to do is also to create checkpoint to recover in case of unacceptable errors, problems that cannot be eliminated in simpler ways.

Related videos

Experienced users of the Windows 10 operating system may have heard of the PowerShell command line utility. It may also be familiar to those with experience with Windows 7 and 8.1. After years of using the Windows command line application and .bat files, it's time to get to know a more powerful tool.

PowerShell is a valuable addition to the list Windows tools and its sheer scale may put off some users. Is it a scripting language or a command shell? Don't worry: despite the vast possibilities, anyone can master PowerShell.

Step 1: installation

First, we need the PowerShell utility itself. If you're on Windows 10, you already have PowerShell 5 installed. Windows update The 10 Anniversary Update uses version 5.1, but the difference is subtle. Windows 8 and 8.1 use PowerShell 4, which is also sufficient. Installing PowerShell on Windows 7 won't be a problem, but there are still a couple of extra steps to take. In particular, you need to additionally install the .Net Framework. You can install the Windows Management Framework, which includes PowerShell.

PowerShell has two interfaces. Experienced users can choose a full GUI, known as the Integrated Scripting Environment (ISE). For beginners, it's better to use the PowerShell console, simple text interface in Windows command line style or even DOS 3.2.

To run PowerShell as an administrator on Windows 10, click on the Start button and scroll through the list of applications to Windows PowerShell. In Windows 8.1, look for Windows PowerShell in the System folder in Windows. In Windows 7, the shell is located in the Accessories folder. As ordinary user PowerShell can be launched in the same way, using the left mouse button instead of the right one.

At any Windows versions search can be applied. For ease of use, you can pin PowerShell to the taskbar.

Step 2: Old Windows Commands

Windows command syntax in PowerShell works in the usual way. For example, cd changes folders, dir shows a list of all files and folders inside the current folder.

Depending on how you start the PowerShell console, you can start at c:\Windows\system32 or in c :\Users\ . The example in the screenshot uses the command cd..(with a space) to go up one level at a time, then run the command dir to display a list of files and folders in a directory C:\.

Step 3: Installing the Help Files

Commands like cd and dir are not active PowerShell commands. These are the so-called aliases (aliases) - replacements for real PowerShell commands. Aliases are handy for those with a lot of experience with the command line. However, they do not touch the depths of PowerShell.

To get started with PowerShell, type help and the command you need. The screenshot shows the command .

Team help says that dir is an alias for a PowerShell command Get-ChildItem. If you dial get-childitem in PS C:\>, you will see the same as when using the command dir.

As indicated at the bottom of the screenshot, the help files for PowerShell are not installed automatically. To get them, run PowerShell as an administrator and type update-help. Installing the help files will take several minutes, a number of modules may be missing - for example, Help for NetWNV and SecureBoot were not installed in this case. When everything is ready, the full help system will always give the right tips.

Now type the command get-help and any command you are interested in ("cmdlet" on PowerShell language, cmdlets in Russian), its description will be shown. For example, get-help get-childitem gives a list of options get-childitem. You can also display different possible options. For example

get-help get-childitem -examples

produces seven detailed usage examples get-childitem. Team

get-help get-childitem -detailed

includes these seven examples and detailed explanations each parameter in the cmdlet get-childitem.

Step 4: Getting help with settings

On the screenshot you may have noticed two lists under SYNTAX for get-childitem. Having two different syntaxes means you can use two ways to run a cmdlet. How to keep the syntax separate from each other and what do the parameters mean? The answer is simple if you know the trick.

For details on cmdlet parameters get-childitem or any other use parameter -full:

get-help get-childitem -full

This gives a list of what you can do with the cmdlet and what will happen. Look at the screenshot.

Viewing the description of the parameters allows you to notice that get-childitem makes it possible to get an object child(such as a subfolder name or filename) at the specified location, with or without matching certain characters. For example:

get-childItem "*.txt" -recurse

returns a list of "*.txt" files in the current folder and all subfolders (due to the -recurse). Whereas

get-childitem “HKLM:\Software”

returns a list of all top-level registry keys in HKEY_LOCAL_MACHINE\Software.

If you have ever tried to get into the registry using the Windows command line or .bat files, you will be able to appreciate the functionality of this access option.

Step 5: Learning Names

There is a reason why the cmdlets shown so far look similar: get-childitem, update-help, get-help use the same verb-noun pattern. This convention applies to all PowerShell cmdlets where the verb comes before the single noun. This will appeal to those who at one time suffered from the inconsistency of command names in VB and VBA.

Take a look at the most common cmdlets:

set location: sets the current working location to a specific location

get-content: get file contents

get-item: get files and folders

copy-item: copies an object from one location to another

remove-item: deletes files and folders

: Gets processes running on the local or remote computer

get service: Gets services running on local or remote computer

invoke-webrequest: gets content from a web page on the internet

To see how a particular cmdlet works, use get-help as in the case

get-help copy-item -full

Based on the description in the help, you can understand what the cmdlet needs. For example, if you want to copy all files and folders from Documents in c:\temp, use

copy-item c:\users\ \documents\* c:\temp

By entering this command, you will see some interesting features of the PowerShell environment. For example, if you type copy-i and press the Tab button, PowerShell will fill Copy Item. If a cmdlet is mistyped and PowerShell cannot recognize it, a full description of what went wrong is given.

Try this cmdlet:

invoke-webrequest askwoody.com

You will get a short list of titles, images, links, and other web page content. Pay attention to get-help to the list invoke-webrequest, which "returns a collection of forms, links, images, and other important HTML elements” is exactly what should be shown on the screen.

Some cmdlets help manage PowerShell itself:

get-command: list of all available cmdlets

get-verb: list of all available verbs

clear-host: Clear the screen of the host program

Different parameters allow you to reduce commands and narrow the range of useful options. For example, to view a list of all cmdlets that work with Windows services, type

get-command *-service

All verbs available with a noun will be shown service. Here is their list:

Get Service

New Service

Restart Service

Resume Service

Set Service

start-service

Stop Service

Suspend Service

You can combine these cmdlets with others.

Step 6: Using Pipes

If you are familiar with the Windows command line or batch files then you know about redirection and pipes. Redirection (the > symbol) and pipes (the | symbol) take the result of an action and attach it elsewhere. For example, you can redirect the result of a command dir to a text file or pass the result of the command ping to the team find to filter interesting results, like

dir > temp.txt

ping askwoody.com | find "packets" > temp2.txt

Here in the second team find looking for a string packets, taken from the askwoody.com address by the command ping and merges all matching lines into a file called temp2.txt.

The first of these commands works fine in PowerShell. To run the second command, you need something like

ping askwoody.com | select string packets | out-file temp2.txt

The use of redirection and pipes greatly expands the capabilities of the Windows command line: instead of endlessly scrolling down the screen in search of a text string, you can filter the desired Windows commands.

Powershell has support pipe, and it is not limited to text. PowerShell allows you to pass an entire object from one cmdlet to another, where the object is a combination of data (called properties) and actions (methods) that can use that data.

The tricky part starts when the objects are lined up. The objects supplied by one cmdlet must match the type of objects accepted by the receiving cmdlet. Text is a very simple type of object, so if you're working with text, aligning objects is a simple task. Other objects are not so elementary.

How to understand it? Use cmdlet get-member. If you want to know what type of object a cmdlet handles, run it through get-member. For example, if you are trying to understand the processes running on a computer and have narrowed down the options to cmdlets , here is how to know the result of the cmdlets:

get process | get-member

Running this cmdlet produces a long list of properties and methods for , but at the very beginning of the list you can see the type of object that creates :

TypeName: System.Diagnostics.Process

The screenshot below also shows the properties entitled get-process Handles, Name, NPM, PM, SI, VM and WS.

If you want to manipulate the result to work with this cmdlet (instead of displaying a long list of active processes on the monitor), you need to find another command that takes as input System.Diagnostics.Process. Use PowerShell again to find the right cmdlet:

get-command -Parametertype System.Diagnostics.Process

This cmdlet produces a list of cmdlets that can process System.Diagnostics.Process.

Some cmdlets are known for accepting almost any kind of data. Chief among them is . This cmdlet passes through itself each object sent through the pipe, one by one, and applies the specified selection criteria to it. There is a special marker called $_ , which allows you to use each item in the pipe, one at a time.

Let's say you want to get a list of all processes running on the computer with the name "svchost", that is, you want to match the property Name process svchost. Use command:

get process | where-object ($_.Name -eq "svchost")

Cmdlet looking at every object System.Diagnostics.Process, compares .Name this object with "svchost"; if there are matches, they are displayed on the monitor. Look at the screenshot.

Step 7: Analyze Useful PowerShell Commands

By now, you already know enough to be able to damage the computer, so be careful. Let's see, for example, frequently requested PowerShell commands.

These commands only work on Windows 10 and only when running PowerShell on behalf of the administrator. They are designed to reinstall pre-installed Windows 10 apps and can be useful for those who first uninstalled these programs and then decided to return them. The commands looks like this:

Get-AppXPackage | Foreach (Add-AppxPackage -DisableDevelopmentMode -Register “$($_.InstallLocation)\AppXManifest.xml”)

If you run this command, ignore the warnings indicated in red, and when the command is completed, restart your computer; all pre-installed programs in Windows 10 will appear in their places.

Here is how this command works. Get-AppXPackage checks all application packages in the user profile. Even if you uninstall an app, it remains in the user's profile list.

Cmdlet Get-AppXPackage returns an object TypeName Microsoft.Windows.Appx.PackageManager.Commands.AppxPackage, which includes the fully qualified application package name and the location of the corresponding XML manifest file. If you run the cmdlet get-appxpackage, you'll see a long list of app packages. The screenshot shows a description of the Xbox app.

Cmdlet Foreach cycles through each object in AppXPackage, sending them to the cmdlet Add-AppxPackage. According to get-help for Add-AppxPackage, there are two key switches:

  • Switch -Register used to register existing application package installations, you can set options Disable DevelopmentMode and Register
  • Switch -DisableDevelopmentMode tells Windows to re-register an existing application package that has been deactivated, unregistered, or corrupted.

Line " $($_.InstallLocation)\AppXManifest.x ml" describes where the file is located manifest.xml. If you look at the files AppXManifest.xml, you will see a complex list of application IDs, executable files and a large number of visual elements associated with the application.

After the reboot, any added app packages are downloaded and installed from the Windows Store.

Internet