What is PowerShell? Assigning a Windows Power Shell component What is PowerShell in Windows 7.

A consistent part of the tasks associated with the service of local computing networks is the execution of routine operations, which can require considerable time. Probably solutions to automate the execution of administrative tasks that could increase productivity, arose almost immediately with the advent of the profession of the system administrator.

The most common means of "saving time and getting rid of headaches" was the record and serial batch execution of the necessary operations - execution of scripts or scripts in the interpreter of the operating system commands.

Attempts to improve the state of affairs in the field of Windows management and administering using the command interface led not to adaptation of a foreign scenario for the Script language system or the creation of a super utility operating in DOS, and to the appearance PowerShell - New command shell.

As part of MS-DOS and Windows 9X, such an interpreter that allows you to process batch files (BAT files), was command.com.Subsequently (starting with Windows NT output) replaced cmd.exe.. Later, Windows Script Host appeared.

Windows Script Host. (WSH; Originally called Windows Scripting Host) - One of the Microsoft Windows elements, as part of the operating system, it started to be supplied, starting with Windows 98. Allows you to run scripts written using scripted languages VBScript./Jscript. And, as an addition, some others. Scenarios executed in WSH provide much more features than using command (BAT and CMD) files. The execution is possible in the graphics environment (WScript.exe) or in the console (CScript.exe).

However, the process of writing and executing scenarios in Windows is not developed as well as, for example, in UNIX systems. One of the reasons for this is the graphical interface of Windows, apparently and has made it so popular among ordinary, non-corporate users. The ability to manage some elements of the Windows environment using a graphical interface cannot always be implemented using system utilities performed on the command line. On the other hand, the possibility of some system programs supplied as part of Windows are not always presented in the GUI. In addition, the interpreters in Windows have a fairly limited set of teams, "sewn" in the shell itself. Windows Script Host is not integrated with the command line and in itself represents a potential danger - it uses a sufficiently large number of malicious programs.

Attempts to improve the state of affairs in the field of Windows management and administering using the command interface led not to adaptation of a foreign scenario for the Script language system or the creation of a super utility operating in DOS, and to the appearance Windows PowerShell - New command shell. According to some data, its appearance is associated with the use of a platform .NET when creating a command interface for WMI. At the moment, PowerShell is a separate application that can be installed on any system using the platform .NET 2.0 (Windows XP, Vista, Server 2003). Starting with Server 2008, PowerShell will be an embedded component of Windows-systems. If you do not have Server 2008, to get to know PowerShell, you will need to download it (perhaps you will need to install .NET).

Acquaintance
Runing PowerShell, you will not find any differences between it and cmd.exe (except for the color of the window of the PowerShell window by default - blue). Moreover, you will soon find that copy / insert operations in PowerShell are also implemented ugly, as in cmd.exe. But the first impression of the similarity of these shells, let's say, does not quite correspond to reality.

The fact that the work of the PowerShell shell is based on this NET Framework, it is its main difference from the previous command shells of Windows. PowerShell is completely object-oriented. The result of the execution of the team in PowerShell is not a certain "text itself", but the object of the platform.net. This object is the actual data and has a set of properties and methods inherent in it.

Internal commands (more precisely, command structures) for working with objects in PowerShell are called collectimi. For them, a special uniform naming in the form of a combination action is the target. For example, to obtain data, the "SET" action is used to obtain - "Get", for output - "out", etc. The target is the type of object to which the action will be applied. Cups can be viewed as mini-programs performed in the PowerShell environment. To enhance functionality, you can create your own cmdlets or install third-party cmdlets. In addition to cmdlets, PowerShell allows you to perform functions, external scripts (stored in files with the PS1 extension) and external executable files.

Powershell includes a fairly extensive reference system. To start working with it, you can execute the Get-Help command.

For a detailed help on any cmdlet or section of basic information, you must specify its name as the command parameter.

Options
Strictly speaking, following the spirit of uniform naming in PowerShell, all parameter names transmitted by cmdlet must follow the symbol "-". However, for ease of writing, some parameters can be omitted. For example, to call a CLAMM CLAND GET-CONTENT instead of full instructions

PowerShell:

Get-Help -name Get-Content

you can enter a command

PowerShell:

Get-Help Get-Content

The parameter may have any value (in the example above, the value of the Name parameter was get-content) or not to have it. In this case, it is an analogue of the switch of any functionality of the command. For example, if you need to get complete information about the Get-Content cmdlet, enter

PowerShell:

Get-Help Get-Content -Detailed

Conveyor
In PowerShell, a mechanism for transmitting data from one process to another or output to a file is implemented. Because, as noted above, PowerShell operates not with text, but objects, when the element is redirected, the object sharing is an object, along with its structure. This possibility allows you to operate with objects - select them on a given filter, sort, group them, etc. To organize such a conveyor (in the English documentation, the term uses pipeline. - Pipeline or channel) In the text of the script, a vertical feature sign is used. If such a sign is detected, the interpreter transmits objects from one cmdlet to another as input parameters.

As an example of the conveyor and the ability to access the properties of objects transmitted along it, we give the following situation. To check if some suspicious programs are executed on a computer, we want to get a list of all running processes, get paths and names of files that run them, and also see the creation of such files. In addition, sort out such a list by the date of creating in a descending order and save the 10 most "fresh" of them. Add to output information also the time of the last modification of the file. Processes with the names "System" and "IDle" from consideration will exclude, as they do not contain ways to files.

As they say, a well-defined question is already half of the decision. Take a look:
Entering the code, you can always break the string, putting the "` "sign in the place of transfer. You can even just press the ENTER key without finishing the string. In this case, PowerShell will change the invitation to \u003e\u003e, giving the user to understand that the interpreter considers the code not completed and expects the end of its input.

Like many other scripting languages, PowerShell allows you to use variables. The symbol of the variable is the "$" sign. In the case of transmitting an object by conveyor, the variable $ _ indicates the transmitted object itself.

Consider the actions of the code "by steps". First we receive a list of processes using the Get-Process cmdlet. This data is transmitted by the conveyor further and filtered under the conditions specified in the WHERE-OBJECT (we learn the processes with the names "System" and "IDLE").

The next conveyor element is the Get-Item returns the attributes of selected objects. It remains to sort them (the time of creating in a descending order) and select the values \u200b\u200bof interest to us (folder names and executable file, the creation time and last modification of the file). The last parameter, -FIRST 10 indicates that only the first 10 items from the list of objects will be displayed. Let's try to execute in the Server 2008 environment:


Enlarge image

Wonderful what you need. However, when trying to perform the same code in the Windows XP or Server 2003 environment, it was found that it looks not so smooth:


Enlarge image

When viewing the results of execution

PowerShell:

Get-Process | SELECT PATH.

it turned out that the paths of two processes - WinLogon and CSRSS - in Windows XP and Server 2003 PowerShell interprets as \\ ?? \\ C: \\ Windows \\ System32 \\. For clarification of such behavior, I turned to Vasily Gusev, a PowerShell specialist. He explained that these processes do not use Win32API, and such a different reaction to them in XP / Vista from the.Net is probably caused by the difference in the platforms of these operating systems.

Deciding that the use of error handling mechanisms (in terms of the "incomprehensible" path with the suppression of an error message output) or exceptions from the WinLogon and CSRSS processes list in this case (perhaps they are infected, and the date of their modifications in the results we are no longer We will see), the teams were changed as follows:

PowerShell:

Get-Process | Foreach-Object (if ($ _. Path -Ne $ NULL) (Get-Item ($ _. Path -REPLACE "\\\\\\? \\? \\\\", ""))) | Sort CreationTime -Desc | Select FullName, Name, CreationTime, Lastwritetime -First 10

A reader can get some idea of \u200b\u200busing conditions and regular expressions in PowerShell.

Small explanations for the code.

  • At the second stage of the conveyor, the Foreach-Object cmdlet is applied, which allows you to perform a specified operation for each object from the set transmitted to its input.
  • As mentioned above, the current object over which the operation is performed is presented with a variable $ _.
  • As a given operation, the condition of the form of the IF appears here ( condition){executable code if the condition is true}.
  • Also, as in cmd.exe, no symbols of the type are used for comparison operators< или >, and abbreviations - in this case it is "not equal to" (not equal): -ne.
  • So, if the path path contains any value (in the case of "SYSTEM" and "IDLE", the path is simply missing), using the REPLACE function all characters "\\ ?? \\" will be deleted on the way (perhaps more in detail to affect the question of regular expressions we will not),
  • and the Get-Item cmdlet will provide access to the properties of the current process.
Well, further - everything, as in the first example. The result of execution is now the same:
Enlarge image

Getting information about objects
Perhaps the reader already had a question - and how, generally speaking, you can find out what information can be obtained from the execution of a particular command? What actions can be made with the data received? For example, in the case described, where could I find out what we could get the file creation date? One of the simple ways to analyze the object returned by the command is to transfer this object to the Get-Member cmdlet. This cmdlet displays information about the type of object and all its items. As a rule, objects have a large number of diverse properties and the result of the work of Get-Member can be a very bulk text that is not very convenient to view. In this case, you can either share information on the part, or to filter it. An example of information about the object returned by the Get-Process cmdlet, which can be prepared page:

PowerShell:

Get-Process | Get-Member | Out-Host -Paging

By filling out the page, the user can choose one of the options - output another page, output another line or stop outputing data.

Data filtering is performed using the Membertype parameter defining how which kind should be displayed. For example, the team

PowerShell:

Get-Process | Get-Member-Membertype Properties

will only withdraw the properties of the object, and

PowerShell:

Get-Process | Get-Member-Membertype Methods

Only its methods. Another way to see the object properties is to assign a variable object, then dial the variable name in the console, put the point and press the Tab key. With each press, the PowerShell key will sort and substitute the methods and properties of the object. The bust in the opposite direction is possible using the SHIFT + TAB key combination.

Security
As already noted, the use of VBScript / JScript scripts represents a potential danger to the system - it is enough to click on the mouse icon. The danger is even more increasing if the user entered the account included in the Administrators group. In PowerShell, the script with the PS1 extension is not possible to run to execute using the mouse - the system will not be opened in the system not in the command shell, but in the notebook. To start the script, you need to start the PowerShell shell itself, enter the file name and press the ENTER key.

The new shell is also impossible to substitute commands. The essence of this reception used by the attackers is as follows. Usually, a user who has no administrator rights has some folders with recording permissions and executing files. Characteristic example - folder C: \\ Documents and Settings \\ username. The malware creates an executable file in such a folder with the name that coincides with the name of the shell command or the name of the executable system program. For example, I created an ipconfig.vbs document folder in the "my" folder, withdrawing a simple message. Now, if, running cmd.exe, while being in your folder, I will try to execute the Windows IPConfig command, I will get this result:


Enlarge image

For completeness, the illustration can be placed in the document folder and the executable file renamed in our case in ipconfig.exe. Then even when calling, the file will be launched from the current folder, and not from \\ System32. With PowerShell, this focus will not pass - to call the script, the path to which does not coincide with the paths specified in the system variable% Path, it is necessary to explicitly specify its location. Even in the case when the script is located in the folder, which is for the shell of the current, you must specify the path in this form :. \\ file name. The reverse track point indicates the interpreter to the current folder.

Another security mechanism is the policy of execution of scenarios. Initially, the shell is configured so that even if the script is correct, its execution will be prohibited, and the user will receive a corresponding message. Performance policy can switch to one of four modes:

  • Restricted - default setting, launching any scenarios is prohibited
  • AllSigned. - allowed the launch of scenarios having a digital signature of a reliable publisher; User Created Scripts should also be certified by the Certification Center
  • Remotesigned. - Allowed the launch of scripts if they are not trusted, but are created by a local user; scripts loaded from the Internet not having signatures are not executed
  • Unrestricted - Allowed the launch of any scenarios
The current policy mode can be found by running the Get-ExecutionPolicy command in the shell. To change the mode, run the SET-EXECUTIONPOLICY command with the necessary policy name as a parameter.
Also to tools to help improve security when working with PowerShell, I would include command parameters from the category "and what will happen if ...". There are two - Whatif and Confirm. The first allows you to determine which action and with which object will be produced, but the actual action will not be implemented. Something like modeling. The second before performing the action will request user confirmation, and in the event of an affirmative answer - to run the necessary command in fact. That is, such a type of safety net.

I will give, perhaps the most striking and fun example of using these parameters. If the user tries to execute the command

PowerShell:

Get-Process | Stop-Process.

after a few seconds it will be waiting for a blue screen with the stop-Ohm. PowerShell, as follows from the text of the command, consistently starts to "navigate" all the processes running in the system, which will lead to its critical stop. If you start

PowerShell:

Get-Process | STOP-PROCESS -WHATIF

nothing terrible will not happen - just PowerShell will show what he would do if the team was performed without a key-dashif:


Enlarge image

Pseudonyms
The shell has a built-in command pseudonyms. On the one hand, pseudonyms are used to simplify command entry. As a rule, in this case, the abbreviated name of the cmdlet is used as a pseudonym (for example, GC for Get-Content or Fl for Format-List). On the other hand, this mechanism provides compatibility of interfaces of various command interpreters. For example, having experience with cmd.exe, you are used to displaying the contents of the folder using the DIR command. The execution of this command in PowerShell will also result in the same result, although in fact the shell instead of the DIR pseudonym will execute the Get-Childitem cmdlet. The list of all available pseudonyms can be obtained using the Get-Alias \u200b\u200bcommand. The user can create its own pseudonyms using the set-alias command.

PowerShell discs
Just as Windows operates with data using the file system, the PowerShell shell works with the data storage presented in the form of disks. Physical disks of the system are not the only built-in storage-built storage facilities with which the interaction is ensured. The user can work with the registry, embedded variables and variables, certificate stores in the same way as with conventional discs, folders and files. Implementing such interaction and providing abstractions that allow the user to apply the same commands and methods to various data warehouses, providers - program.net.

List of providers available at the moment by the shell can be obtained by the Get-PSProvider command. Initially, PowerShell contains the following "discs" - pseudonyms (Alias), environment variables (ENV), physical disks of the system (C, D, etc.), functions, system registry, internal variables (variable) and certificate store.

Here is an example of reading the contents of the HKLM \\ SOFTWARE \\ Microsoft registry branch


Enlarge image

As you can see, the same commands are used that to get information about the file system. But the structure of the data obtained, naturally, is different. In addition to the names and properties for each item, the subsection number (SKC) and the record number (VC) are displayed. Using PowerShell, the user can view the registry information, add, delete and modify the keys. Let me bring yourself something like a cheat sheet on working with registry elements:


Enlarge image

And code for an example of performing various manipulations with registry keys and their parameters:

PowerShell:

# Create a new subsection with the name Valks in the HKEY_CURRENT_USER \\ Software NEW-Item -Path HKCU: \\ Software \\ Valks # add to the created section of the new string parameter named Param1 and the StringValue NEWMPROPERTY -Path HKCU value: \\ Software \\ Valks -Name Param1 -PropertyType StringValue StringValue # Create Subsection Subfolder New-Item -Path HKCU: \\ Software \\ Valks \\ Subfolder # Add another parameter - Param2 type DWORD and 12 New-ItemProperty -Path HKCU: \\ Software \\ Valks -Name Param2 -PropertyType DWORD -Value 12 # We receive a list of all parameters of Get-ItemProperty HKCU: \\ Software \\ Valks # Get the value of the parameter Param2 Get-ItemProperty HKCU: \\ Software \\ Valks | Format-List param2 # or can be considered a section to a variable $ Key $ Key \u003d Get-ItemProperty HKCU: \\ Software \\ Valks # and output the value of the desired Write-Host parameter "The value of parameter Param2:" $ key.param2 # Change the parameter Param2 to 193 Set-ItemProperty HKCU: \\ Software \\ Valks -Name Param2 -Value 193 # Change the parameter name Param1 on the parameter1 RENAME-ITEMPROPERTY -PATH HKCU: \\ Software \\ Valks -Name Param1 -NewName parameter1 # Delete the parameter1 Remove-ItemProperty HKCU: \\ Software \\ Valks -Name parameter1 # We delete the entire subsection of Valks Remove-Item HKCU: \\ Software \\ Valks

Here is another example in the form of a function that searches for programs that automatically downloaded at the start of the system. The search area is determined by an array that includes some known autorun points in the registry. The code contains comments, I hope they will explain the essence of the work.

PowerShell:

Function GetAutoexec ($ Hives) (# If the function is not transmitted by the registry key input, # Use this: $ HiveS \u003d "HKCU: \\ Software \\ Microsoft \\ Windows \\ CurrentVersion \\ Run", `" hklm: \\ Software \\ Microsoft \\ Windows \\ Hive in $ Hives) (# Title the name of the branch of the green color Write-host "Branch $ Hive" -ForegroundColor Green # check whether there is a branch in the IF registry (Test-Path $ Hive) (I get the next registry key $ param \u003d get- Item $ Hive # for each key ... Foreach ($ P in $ param) (# ... We get a list of its Foreach options ($ Key in $ P.GetValuenaSes ()) (# Display the parameter name and its value "Load $ Key from "+ $ P.GetValue ($ Key)))) # tolerate the Write-Host string" `n")) # We call the getautoexec function itself

The user can create its own discs using existing providers. Here is an example of creating a PowerShell disk with the name Win, the contents of which will be the root folder C: \\ Windows:

PowerShell:

NEW-PSDRIVE -NAME WIN -PSPROVIDER FILESSYSTEM -ROOT "C: \\ Windows"

After creating a PowerShell disk to it, you can contact it in the same way as the usual disk of the system.


Enlarge image

However, it is necessary to know that upon completion of the PowerShell session, it will be automatically deleted. Just like aliases, functions and variables created by the user during a session. In order to save the listed changes, you need to create a PowerShell profile.

PowerShell profiles
Profile is a file with PS1 extension. In fact, it is the same script performed by the shell when it starts. The shell profiles are not created automatically - they must be created by the user independently. Created profiles will be downloaded each time PowerShell starts if the execution policy is allowed to download configuration files. Possible processing up to four different profiles. Location of files in order of their loading sequence:

  • % Windir% \\ System32 \\ WindowsPowerShell \\ v1.0 \\ profile.ps1 - profile applied to all users and shells
  • % WINDIR% \\ System32 \\ windowspowerShell \\ v1.0 \\ microsoft.powershell_profile.ps1 - profile applicable to all users only PowerShell shell
  • % UserProfile% \\ My Documents \\ windowspowerShell \\ PROFILE.PS1 - Used for the current user in all shells
  • % UserProfile% \\ My Documents \\ windowspowerShell \\ Microsoft.powershell_profile.ps1 - Applies to the current user only in the PowerShell shell
Under various shells, it is necessary to take into account the fact that PowerShell may not be the only application using PS1 profile files. Some integrated development environments (IDE) can also use them. One of the characteristic examples is the PowerGUI tool developed by the Quest Software, which provides a graphical interface to work with PowerShell.
The path to the profile of the current user only the PowerShell shell is stored in the $ PROFILE built-in variable. To create it, execute the command
WMI objects are for PowerShell quite "relatives". Enough to execute the command

But a small example of a survey of all computers on the local network with the address 192.168.1.0 and the subnet mask 255.255.255.0:

PowerShell:

1..254 | Foreach-Object -Process (GET-WMIOBject -Class Win32_PingStatus -Filter ("address \u003d" 192.168.1. "+ $ _ +" "") -ComputerName.) | SELECT-Object -Property Address, ResponSetime, Statuscode

In the first conveyor element, an array of numbers from 1 to 254 is generated. At the second stage, each number from the array is substituted into the IP address, which will pitch using WMI funds. The results will be displayed in a three-column table - host address, response time and response status. In the case of the host response, the status with the code "0" is returned.

Work with COM objects
Platform.net has built-in tools that allow it to work with the COM components. This feature allows you to manage the work of various applications that support COM. As an example, we show the function to automate the Internet Explorer. We will open IE and move on to WindowsFAQ.RU. If a string is transmitted as a function parameter, we will search for it using a search engine itself if the parameter is missing - we will search for Windows word. Here is the code with comments:

PowerShell:

# We declare the function, install the default parameter - Windows Function WinFaqsearch ($ str \u003d "Windows") (# Create a COM object - Internet Explorer $ IE \u003d New-Object -Comobject InternetExplorer.Application # Indicate the browser to the $ IE.navigate transition address ( "http://windowsfaq.ru") # Making a running instance of IE visible $ ie.visible \u003d $ true # just in case, waiting for page downloads 5 seconds Start-Sleep 5 # Get the text web page $ doc \u003d $ ie.document # We are looking for a search box on a page $ text \u003d $ doc.getelementByid ("mod_search_searchword") # We enter the desired value of $ text.value \u003d $ str # get the form itself that is responsible for searching $ Forms \u003d @ ($ ie.document .Forms | Where ($ _. action -match "index.php \\? option \u003d com_search & itemid \u003d 5")) # Send a request $ Forms.submit () # We ask whether to close the IE IE instance ((($ RESP \u003d Read-host "Close Internet Explorer? [Y] Yes / [n] no") -eq "y") (if ($ ie.visible -eq $ true) ($ ie.quit ()) Remove-Variable IE) )

Conclusion
Of course, in one article it is impossible to describe all PowerShell features. In addition, Microsoft continues to work on its improvement - the second version must support the control of remote computers directly the shell itself. Other innovations are expected. Given that PowerShell will be a component of the new OS, it does not have to doubt that the scope of its use in Microsoft products will only expand.

The author is appreciated by Vasily Gusev for the help provided in the preparation of the article.

PowerShell 5.0 comes with Windows 10, but for the previous OS, the new version came out as part of Windows Management Framework 5.0 only at the end of February, and with the second attempt. Today I will tell you about some innovations, but I'll start with why you may need PowerShell.

Why do you need PowerShell

Just to study PowerShell makes no sense, and this is true for any language - scripting, software and even human. Like many Microsoft solutions, PowerShell is made with a business opportunity to automate PC management tasks and servers in organizations.

The scripted language is based on a powerful software platform.NET, so PowerShell features extended much further administration.

Once it took me to remove one column from a variety of Excel books 2013. The hand did the manual work, and the googling did not give a ready-made solution. I created a topic on the forum (yes, I also sometimes ask questions on oszone :). Any language approached me, but the decision was unexpected for me to be at PowerShell. As it turned out, you can download Excel as a COM object and manipulate them further.

Subsequently, I have repeatedly used the modification of the script to automatically update the tens of Excel books, tightening data from other files. It saved me a lot of time and strength.

I think the idea is understandable, and you can already move to the new items of PowerShell 5.0.

8 useful features

Syntax highlighting

The new console is much easier to navigate!

Red color and numbering strings, however, from another opera.

Search by history in two directions

Keyboard shortcuts: Ctrl + R and Ctrl + S
CLAMBES: Get-PsreadLineKeyHandler and Set-PsreadLineKeyHandler

Like in CMD, PowerShell has a session history with navigation arrows, a Get-History. Displays a magazine by analogy with F7. Full list of journal-related keyboard shortcuts.

Get-PsreadLineKeyHandler | ? ($ _. Function -Like "* Hist *")

The results appeared two new history search functions, which are shown in the picture below. It works it is very simple.


Unlike the GET-History, which contains the history of the current session, this magazine is globally and maintained when closing the window.

Thanks for the entrance of Anton Drovoskin and Konstantin Sidyakin from our group VK.

Creating compounds, symbolic and hard links

CLAMBES: NEW-Item., Remove-Item., Get-Childem.

My blog has enough stories, so I could not get around the possibility of creating them in PowerShell.

# Symbolic link to file new-item -iteemtype symboliclink -path c: \\ test \\ mysymlinkfile.txt -target C: \\ Test \\ 1.txt # Symbolic link to the New-ItemTeMtype folder SymbolicLink -Path C: \\ Test \\ MySymlinkfolder -Target C: \\ Windows \\ # Hard link to the file new-item -iteemtype HardLink -Path C: \\ Test \\ MyhardLinkfile.txt -target C: \\ Test \\ 1.TXT # connection new-item -itemtype junction -path c: \\ Temp \\ MyJunctionDir -Target C: \\ Windows

Honestly, team syntax mklink.remember it easier, so it may turn out faster so:

IEX "Mklink / d C: \\ Test \\ MySymlinkfolder C: \\ Windows"

Creating a temporary file

Clendle: NEW-TEMPORARYFILE.

In scripts, you often need to create a temporary file to throw out some information there. The new cmdlet was created for this.

Creating a temporary file New-TemporaryFile # Creating a temporary file and getting it the full way $ TMPFILE \u003d (new-temporaryfile) .FullName $ TMPFILE

I rarely make a clean installation of the main system, but it is regular on VM. And OneGet is very convenient for a quick auto install key set of programs.

Note. You can use this module without installing WMF 5.0. The preliminary version of the module for PS 4.0 and 3.0 is available separately - March 2016, and more recently search for searching for the download center for PackageManagement PowerShell Modules Preview.

Installing software

In this example, four programs and a complete set of utilities are installed from the Chocolatey repository. The first three commands are executed once, and a policy change must be confirmed. The fourth team quietly establishes the listed programs, and the fifth simply saves time.

# Allow install signed packages from the Internet Set-ExecutionPolicy RemoteSigned # Set supplier Chocolatey Get-PackageProvider -Name Chocolatey -ForceBootstrap # Make chocolatey trusted Set-PackageSource -Name Chocolatey -Trusted # Install program Install-Package NotepadPlusPlus, vlc, firefox, filezilla, sysinternals -Verbose -Force -ProviderName Chocolatey # Add path to executable files (SysInternals) in Path SetX Path "$ ENV: PATH; C: \\ Chocolatey \\ Bin" -m

The supplier downloads to C: \\ Chocolatey \\ lib the package based on the chocolateyinstall.ps1 script. It loads the program installer from the official site to the% Temp% \\ Chocolatey folder and starts it in a quiet installation mode. The simplest example is NOTEPAD ++.

Install-ChocolateyPackage "NotePadPlusplus" "EXE" "/ s" "https://notepad-plus-plus.org/repository/6.x/6.9/npp.6.9.installer.exe"

Software search

There are many programs in the repositories, all the most popular is exactly.

Find-Package "* zip *", "* Commander *" -ProviderName Chocolatey

Removing program

With the removal of applications, not everything is so smooth, however.

Uninstall-Package Stame Filezilla

Ideally, the deletion of the package should entail a quiet removal of the program, but the implementation depends on the author of the package and the capabilities of the installer. In practice, some packets do not contain scripts to remove, others come up with crutches in the form of Autohotkey scripts, others simply start uninstalling interactively by offering you to finish the process manually. However, if the installer is MSI, the deletion works well.

ONEGET and Silent Links:

  • Step-by-step guide for installing programs from PowerShell (Dmitry Bulanov)
  • Types of installers and keys of a quiet installation (my article 2005 is quite relevant :)
  • Windows Auto Installation Website and Software Auto Installation Forum

Discussion and survey

For experienced "scripting" and system administrators in PowerShell 5.0 there are other interesting features (for example, classes by analogy with object-oriented programming languages). Full list you will find on this TechNet page (link leads to an English version specifically because Russian has not yet contains information about 5.0).

You can mark interesting text fragments that will be available on a unique link in the browser address bar.

about the author

Syntax highlighting in PowerShell 5.0, this is the default Psreadline module. In previous versions, it can be confined and register it to download it in the profile script ($ profile variable) or load it when you need

Import-Module Psreadline

Is it possible in more detail about the quiet installation from the scripts? Not so long ago it began to use Chocolatey, I like it very much, especially the update of all programs by one team. Until I figured it with a quiet installation, I put everything in manual mode, confirmation-installation command.

6Yhtapb.

the only thing for that while I need PowerShell in Win 10 is bypassing the bug with the "Properties" non-working button in the VPN settings of the connection. Set-VPNConnection -name "Name" -Splittunneling $ True.
By the way, Vadim. Is there any information about this? We are talking about the button in the VPN properties of the connection - the network - IP version 4 - "Properties". There, you can usually remove the checkbox "Use a gateway in a remote network". The button itself is active, but when you press nothing happens. Here and helped PowerShell.

Sergey Roshkin

Thank you so much for Chocolatey
On Windows 7, did I understand on working?

Lecron.

By voting ... I use almost all options. Part of the programs in the portable form. Part - installed by handles from the disk, for those who know how to update or serious refinement have long been completed. Of these, part of the script. Part new. The part is already preset in the image.
Again, customers and tasks are different.

About PowerShell ... I think that the microsoft missed the title. At first glance, it is not clear what happened. Command Sheath / Processor or Script Programming Language. The word Shell pursues on the first, but then it's time for a long time, since she is so cool, make her default or at least promote it as the main one. But the real skies are more encouraged by the second, the replacement of WSH.

  • Lecron: But then it's time for a long time, since she is so cool, make it the default or at least promote it as the main one.

    In Win + X, you can replace CMD to PS (taskbar properties - navigation). And they promote as a major long ago - on TechNet for a long time there is nothing new about CMD, only PS.

    Of course, the target audience is IT specialists, but the same can be said about CMD and WSH. But I do not see harm for the Central Asian. I find the use of PS at home and at work, and this is not associated with administration ..

    • Lecron.

      I am not about harm. And about misunderstanding and corresponding errors.
      What it is? What sees the microsoft? Command processor working as a rule interactive mode that also can

      Work interactively in one syntax and semantics, and write the sequences of actions in others - ridiculous. This is the main problem. Such a deep one that even you do not notice it, although indirectly mentioned in the article. Mklink syntax is not easier, but more familiar. Since new-item, with united Syntax, allows you to create very very much. And now, in fact, its syntax is easier than knowledge of many separate utilities, including their name.

      The promise was detained - here's a module for managing packet managers, forward.

      Not understood. What is the "Managing Management Module"?

        • Lecron.

          It seems to me that there is a dog and rushed. In providers. When there is no single approach to managing packages. In fact, the user has to know and take into account which of the providers is used. And not only users, but also to mines.

          Fich, as usual, is focused on the organization, and MSI and MSU are maintained in full growth.

          Lecron.

          Maybe I did not understand the whole depth of this feature, so such stupid claims.
          Will the user need additional television if the owner of the repository / package will change the provider? Or will the package creator change its settings? Or all this takes on the package manager?

          GM ... Here's the feature - take, try, disperse - this will help remove some questions. There is a supplier, he has packages in the repository. Removed a specific package? Then you will not be able to download it from this supplier. But already downloaded package remains locally, they can be controlled next.

          Lecron.

          By the way, here's another question. Is there a UPDATE-PACKAGE command, and even better update-allpackage?

          Hello. Tell me how to restore boot or bios and how to do it? Fleamed Windows loader 7 pro. Boot has already changed the settings, but Windows does not want to boot. Earlier, Windows 8.1 was represented in the service stuck 2 pro without my consent. Help solve the problem!

Alexei

often I heard about the chocolate, since I reminded that I finally decided to test it. The result was not particularly impressed.

put the massive set of software already standing on the PC. Only about 70% found in the repository.
The keys are -y -accept-license -f -x - Mana smoked literally a couple of minutes, maybe I did not understand.
Outcome:
Soft that I did not ask: Autoit, Autohotkey. what for?
rolled the old version of Acrobat Reader DC, Cheat Engine;
Could not download Dropbox VirtualBox;
The quiet regime did not work Viber, Wireshark, Light Alloy - I had to put ticks and cheat further;
Skype removed the old one, but did not put a new one.
And some labels did not create, now you need to remember which.

Warnings:
- AdobeReader.
- WindjView.
- Firefox
- notepadplusplus.
- TeamViewer.

here I did not understand what mistakes.

you will have to swing the rest of the software in any scenario to the clean system, or it is not supported from the archive.
Plus rarely, but somewhere where it is necessary to select certain configuration when installing - the composition of the packages and TP. Here it is realizable only by scripts for each product, which does not significantly save time at home. Since all these options can change, and change from version to version - you need to follow and rewrite scripts. It sounds not very.
If it would skillfully scan the registry and add to the database or in GUi software to choose, it would be easier. And so you first need to spend time to compile the list to the installation - for loyalty, each product pierced to specify the correct name of the package.

  • Sergey

    PS C: \\ Users \\ Gerald\u003e Find-Package "* Paint.Net *" -ProviderName Chocolatey Name Version Source Summary ---- ------- ------ ------- Paint .NET 4.0.6 Chocolatey Paint.net Is Image And Photo Manipulation Software Designed to Be Used on Computers Tha ...

    Literally it came across the Habarakabe for the first time on the mention of Chocolatey and immediately in your newsletter. It seemed that here it was! I thought there would be a terrific scripting replacement of the auto installation of free-free software with ninite.com, but alas. The relevance of software is not supported on the paranoid level, and the problems described by the participants above.

    Vitaly

    I believe that the UNIX philosophy is suitable for the console:


    Write programs that would work together.
    Write programs that support text streams, since this is a universal interface.

    • Vitaly, and what, in Windows included a console utility for zip? And this is done to simplify the scripts on PowerShell, you do not need to climb into CMD, integrated certificate, etc.

      • Lecron.

        And why climb into CMD, if both the other shell, and both must independently run executable files and manage their input output?
        Against the inclusion of such a functional, I do not mind, especially if it is done by the mind, as an interface to ZLIB, and not the next skirmish of the code base - in the conductor one, in Shell is another, in CMD third third party.

        Vitaly

        No, not included.
        But in my hosting at the first attempt to use Zip got something like "zip is not installed. Install the APT-Get Install Zip command.

        Climb in cmd? The above was told that PS should run binaries.

        Reference? In Linux command Man% Name_Tilettes% either% Name_Toysters% -?, The first gives a detailed manual, the second as a brief reference by parameters. It works seems everywhere.

        As a result, the command interpreter on the Linux - at the same time a simple and powerful thing, there are many alternatives, since it is not yet anything difficult in it, it simply launches the program, controls the output stream and interprets the simplest syntax.

        strafer.

        Vadim Sterkin.: Vitaly, and what, in Windows included a console utility for zip?

        I shy to ask: not it was easier to add it than to lock the built-in functionality?

  • Herz Mein.

    \u003e why shell-y, with their own means working with archives

    If there is such an opportunity, laid down by V.Net class, then why not use it? There is just another approach other than Bash or CMD, which are command line interpreters. CLI. And PowerShell rather a debugger for scripts, IMHO.

    artem.

    LecronWhat it is? What sees the microsoft? Command processor working as a rule interactive mode that also can Read commands from a file called a script? Or how is the language of writing scripts from which there is a REPL? Agree, the difference is big?

    It is clear that the tasks are different. But I do not see the contradiction between them. Those. It is possible to close both needs with one tool. PowerShell seeks to this. Something is successful, something is not very. But the vision is understandable.

    artem.

    Vadim Sterkin.:
    And they promote as a major long ago - on TechNet for a long time there is nothing new about CMD, only PS.

    Soon there will be, it is necessary to believe. CMD (shell itself) Now relatively actively began to refine. Although before that, ten years did not touch at all.

    artem.

    VitalyWrite programs that make something one and do it well.

    I do not see contradictions. In PowerShell, each commandlet makes something one (for the rarest exceptions). Who will say that "Expand-Archive" can record a DVD or cook coffee - let the first throw a stone in me.

    VitalyWrite programs that would work together.

    Here PowerShell deals all the shells known to me, because Operates objects, not text. Those. "Work together" (transmit data between command years) is much more efficient. It is not necessary to spend time on the parsing of the text and attempt to explain the next team, which is precisely this text.

    VitalyWrite programs that support text streams, since this is a universal interface.

    Threads are also supported. And if you need to call the test - there are no problems with it.

    That is, PowerShell is fully followed by a given philosophy.

    VitalyFor example, why stuff in PS "Creating connections, symbolic and hard links" with your syntax if there is MKLink? What is there "Creating and Unpacking Archives" if there is zip and its analogues?

    Yes, because these commanders are "Analog Zip". In fact, to answer this complaint is very easy. It is only necessary to realize that commanders are not built-in features of the shell, but what is the external commands. And everything immediately falls into place. After all, it is normal that we have teams to perform any actions, right? This is fair both for PowerShell and for any other shell.

    Yes, there is a small number of commandlets that are supplied with the default shell. But ideologically, they do not differ from those commandlets that appear separately when installing the respective components of Windows or are provided with third-party developers.

    • Lecron.

      artem.: This is normal that we have commands to perform any actions, right? This is fair both for PowerShell and for any other shell.

      Shell - how much in this word ... began to be distorted under the influence of MS.
      All the time it believed that the commands did not depend on the launch environment, and the team embedded on Wednesday were only needed to maintain the capabilities of the environment itself, and not third-party objects. Is it really wrong?
      From this point of view, PS begins to remind ACDSEE and NERO.

      Vitaly

      Here PowerShell deals all the shells known to me, because Operates objects, not text. Those. "Work together" (transfer data between cmdlets) It turns out much more effective.

      I doubt that all third-party utilities support these very objects. But the text supports any utility operating on the command line.

      It is only necessary to realize that cmdlets are not built-in features of the shell, but what is the external commands. AND

      Why then do these cmdlets have their own syntax? Well, it doesn't seem to be external teams.

      • artem.

        Vitaly: I doubt that all third-party utilities support these very objects.

        Third-party utilities - no, of course. But third-party commanders are easily. I would say that interest will be easily third-party commandlets work enough with objects.

        If there is no commandlet and you have to run exactly the utility (executable file), then of course you have to feed the text to the input. But the text is easy to get from the object (expanding the desired property, for example). I understand that it sounds awake, but after a set of critical mass of experience, it turns out completely intuitively.

        Vitaly: Why then do these cmdlets have their own syntax? Well, it doesn't seem to be external teams.

        With this I can not disagree. "It doesn't look like" - the correct word :)

        As I said above, you need to get used to PowerShell. And now I will say the nasty in the direction of our evangelists and MVP, but the abuse of alias (dir instead of Get-ChildiTEM, MD instead of the New-ItemTeMtype "Directory", a percentage sign instead of Foreach-Object or question instead of Where-Object and so on Also passing the name of the parameters in the case when the default is running) only confuses the unprepared people. Because of this, including my "addictive" to PowerShell has been delayed for years. It seems to me that if all examples of teams published in blogs and forums contained a full syntax, then newcomers would have experienced much less anal pain.

    In fact, I use 2 options: Returning a backup made immediately after setting up the system or put your own assembly of Windows 7, where I turn on all the desired settings and programs.
    And with Win10, the package manager simply has not yet mastered, although its presence causes strong enthusiasm.
    Previously, played with different package managers under Windows, but for one reason or another were all uncomfortable precisely in the settlement of "time to master" / "time for manual download." It turned out to be easier to make your assembly than script scripts.

    Evgeny Kazantsev

    A wonderful start, I saw how to install a pack of the necessary prog one script, Ninite used, was not particularly impressed, now I use WPI swinging from torrents, plus them is that there is a lot more and a real auto installation, minus that you need to trust the repack author.
    I did not understand one how to update the installed programs are fully automatically, what is the key basic basic feature of any manager package? How to make the same non-type ++ registered by the automatic application by default without climbing in terribly uncomfortable "new, they are modern" settings? How does the dependency system work, and is it there at all? "

    And if you make a script or function? For example, so (without checking for existence and without conversion to full paths, which is necessary):

    Param ($ Create, $ Extract, $ Path, $ Zip) Add-Type -Ssembly System.io.Compression.FileSystem Function Create-Zip ($ Path, $ Zip) (:: CreateFromDirectory ($ Path, $ Zip)) Function Extract-Zip ($ Zip, $ Path) (:: ExtractTodirectory ($ Zip, $ Path)) if ($ Create) (Create-Zip $ Path $ Zip) if ($ extract) (extract-zip $ zip $ Path)

    Call according to:

    . \\ Test -c -p "C: \\ Some \\ Folder" -Z "D: \\ Folder \\ out.zip" # to create. \\ Test -E -p "C: \\ SOME \\ FOLDER" -Z "D: \\ Folder \\ out.zip "# for extracting

    • What's the design? You use.net classes directly in your function. The cmdlet eliminates the NBH to handle classes. This is the difference. Approximately the same as between a programmer and an IT specialist.

      artem.

      Trolleybus from loaf loaf.jpg

      I understand that no one argues with the fact that everything can be done by functions in general :) The benefit is obviously not necessary for this particular action for this action. So, firstly, people will be easier to use this (especially if they do not know how to write functions or cannot afford to import them every time), and secondly there will be more standardization. This is undoubted good. Agree, stupidly, when in five scripts from five different authors it is required to unpack the archives, and everyone solves this task a little in its own way. (For example, one time was popularly popular through an undocumented Windows Explorer COM object).

    lesha.

    I work on Windows and Mac, and if you configure the server, then Linux. OS X perfect reinstalled a couple of times, but everything is simple - chose a date in timemachine 10-15 minutes and the system is ready.
    On Windows, I have most portable programs, I only put on only chrome for otherwise the Adobe software package is not updated, because they swing through the COP version through Cretive Cloud. I do not see the meaning of the burning garden with automation. PowerShell can and good, but I have nothing to automate on Windows, and for Linux and OS X there is a bash that I have been using it for a long time.
    If a friend requests "reinstalling Windows to me, and then something is buggy" I put a system from an external disk with my "brand" way, and let him put himself

  • Hello everyone! Today is a small note on the topic, how to open PowerShell on behalf of the administrator. Let me remind you to PowerShell, it is a powerful programming language and administration from Microsoft, every year it is becoming more and a large number of cmdlets and functionality. In fact, it is replacing the Windows command line. Below, consider the methods allowing you to open and configure.
    .

    PowerShell Opening Methods

    PowerShell develops very well and with the release of Windows 10 has already received the 5 version, but we have the theme is different. So how to open PowerShell? Everything is simple if in Windows XP, then in no way. So it is delivered separately, in all subsequent releases it goes as a built-in component. The most universal way to open PowerShell is to click

    Win + R and enter PowerShell

    Clicking Enter You have the PowerShell console, the problem is only that it will open on behalf of the administrator. And in the end, a lot of team will not be able to do, look below how to do this on behalf of the admin.

    How to run Windows PowerShell on behalf of the administrator in Windows 8.1 and Windows 7

    You can open Windows PowerShell through Start. In Windows 8.1, Windows 2012 R2, go to service - Windows - Windows and you choose the right click on the name of the administrator.

    In Windows 7 and Windows 2008 R2 it looks like starts\u003e Standard\u003e Windows PowerShell

    You can also create a shortcut in the task item and click on it with the right click and select the appropriate item.

    it would be convenient that PowerShell always opened on behalf of the administrator, let's sell it. This is done in all versions of Windows equally. Open the control panel

    Click on it with the right click of the mouse and select the property item. You can immediately see the path to the file where it lies in the system.

    Press the "Advanced" button. You will have additional properties. Where you need to set a daw launch on behalf of the administrator.

    Everything is very simple. I am sure that you will now not stand question how you open Windows PowerShell. It is still useful to change the font in the PowerShell window.

    How to Open PowerShell through the Context Menu of the Start button in Windows 10

    Microsoft, increasingly focuses on the command line towards its strong language (PowerShell), and it is logical, since its possibilities for managing the Windows family operating systems are almost limitless, and even more than in the graphical interface. Starting with Windows 10 1709, in the context menu, PowerShell, replaced with all the familiar CMD. Click right click on the Start button in Windows 10 and from the context menu, select the corresponding item:

    1. Windows PowerShell.
    2. Windows PowerShell (administrator) is just a mode with maximum rights in Windows 10.

    Running Windows PowerShell by searching in Windows 10

    In Windows 10 and older versions, find the PowerShell shell, you can use a regular search, for this there is a special section. Click next to the Start button, a magnifying glass icon. In the search form that opens, enter the word PowerShell. You will have a search for all options, among which you will find the shell. If you right-click it, you can open it on behalf of the administrator.

    Running Windows PowerShell using the Start menu in Windows 10

    In order to open the PowerShell shell from the Start menu, open it and find Windows PowerShell, it will be in the form of a folder, open it and run the appropriate version.

    If you click right click, you will be able to run the shell referred to the name and administrator rights.

    Additional and universal envelope launch methods

    There are still very specific methods for opening a shell with a powerful language from Microsoft. The most top, it's easy to find the executable file and run it directly from the location in the system. Go to your Windows 10 along the way:

    C: \\ Users \\ Username \\ APPDATA \\ ROAMING \\ Microsoft \\ Windows \\ Start Menu \\ Programs \\ Windows PowerShell

    As a result, you will open a folder with labels that are present in the "Start" menu, you can run them.

    You can still start the original, executable file that lies along the way:

    C: \\ Windows \\ System32 \\ WindowsPowerShell \\ v1.0

    And clicking on it with the right click, you can download it on behalf of the administrator, with maximum rights.

    Also, you can start Windows PowerShell and from the command line window, for this simply enter the magic word in it and press ENTER.

    Well, I will recall the method, starting a new task from the "Task Manager" snap. Open the "Task Manager", select the menu item "File - Run New Task"

    In the window that appears, enter PowerShell.

    Well, the latest method known to me is the start of PowerShell, through the Windows 10 conductor, to do this, open the conductor, select the menu item "File - Run Windows PowerShell", there will be both modes.

    The responsible administrator always has two accounts, the first has the minimal rights of an ordinary user, for everyday tasks. The second already has the necessary administrative privileges, from which it performs the configuration of the servers and the entire associated one. In Windows operating systems, there is a functionality that allows you to be in sessions of one user, launch an application on behalf of another who has more advanced rights. So in the session of the usual user, the system administrator launches the PowerShell shell on behalf of the user with other rights and calmly controls what he wants.

    To run PowerShell on behalf of another user you need to press the SHIFT button, then click the right click on the PowerShell icon, select "Startup from another user" from the context menu

    Enter the login and password from the account you need. As a result, the shell will work in the context of another user.

    you can also run the new PowerShell window from the current user window, but with already new rights, for this enter the command:

    sTART POWERSHELL -CREDENTIAL ""

    In the account query request window, specify the login and password, from the account that has the right to you for further your work.

    What is PowerShell ISE

    Surely you noticed that everywhere there is a PowerShell ISE label, and you would like to know what it is. If in a nutshell, then this is a special shell in which you can write scripts and scripts in PowerShell, using all the variety of cmdlets that Microsoft offers you.

    One of the convenient methods for launching the PowerShell shell, with very frequent use, is the destination for it is a hot combination of keys, when the shell is caught. It is done, it is very simple. Open the window properties PowerShell, on the tab " Label"Find" Quick challenge", By default, it has no status.

    Select it and press the SHIFT or CTRL key, or Ctrl + Shift, as a result of which you will find the design for the future combination and also press any key from the letter band, in my example it turned out CTRL + SHFT + C. It is such a combination that I will call Your shell PowerShell. Save settings. Also note that you can easily cancel it or change to another.

    I try to enter a combination of a quick call Ctrl + SHFT + C, as I see everything perfectly works.

    Run shell from ISE

    Until recently, I usually opened the ISE from the usual shell of PowerShell, and not vice versa, but what was my surprise that I was "File" I found the "Run PowerShell.exe" item and there is even a CTRL + SHIFT + P key combination.

    powerShell Font changes very simply go to the properties to the Font tab, where you can set the size from 5 to 72.

    also in properties you can get from the utility window itself, click the icon in the upper left corner and select Properties

    There are few different font settings, along with their change, the console size changes.

    On the color tab, you can set the color of the font in PowerShell and the window itself. By making it for example, black as the command line.

    I also advise if you are an active console to set the size of the buffer not in 50 teams, but at least 100.

    With mysterious letters and persistently flashing cursor? This is a command line. The utility is present in all versions of Windows. With it, it is convenient to manage the system, call programs, find files. But for professional work CMD is not functional enough. Therefore, Microsoft decided to fix all console minuses and released a product called Windows PowerShell. What is it and how to use development, read on.

    What is PowerShell from Windows

    PowerShell is an interactive object-oriented command environment with script language functions. The official release of PowerShell 1.0 from Microsoft took place on November 14, 2006. The developers combined the interface of the usual CLI command line with a platform for managing local and remote networks .NET Framework.

    Note that Windows PowerShell is not a simple operating shell. Microsoft managed to create a powerful, expandable and at the same time a flexible control tool, which is capable of functioning as a selected scenario language.

    On August 18, 2016, Microsoft announced that Windows PowerShell is now an open source product available to each developer. Also, the company added support for UNIX-oriented operating systems, including Linux and OS X distributions.

    How to manage PowerShell

    Cmdlets are used to run tasks, or cmdlets. These are small commands recorded in the form of executable files. In version 2.0 PowerShell for Windows XP and Server 2008 R2, the creators have added modules that allow you to manage a large amount of resources, including Active Directory and Exchange Server.

    Now in the PowerShell automation tool, over 130 modules and commands are embedded. They provide access to files, networks, registry, administration and other system features:

    • setting time and dates;
    • work with folders and separate files;
    • obtaining assistance and additional information;
    • import and data storage;
    • methods for creating scripts;
    • individual scripts and applications;
    • check security system and work with descriptors;
    • system administration;
    • check disk space.

    Considering that Windows PowerShell is an expandable environment, users can create their own teams, write "author" modules using a language .Net.

    Getting started with PowerShell

    In 2016, the last beta version 6.0 PowerShell was released. In Windows 7, 8 and 10, the utility is built-in. If you use another operating system, the application will have to download. To do this, go to the official site of Microfoft.com and in the search window, enter Installing Windows PowerShell. The system will automatically translate to the page with the latest product releases. Select your OS from the list and click Download.

    When the file is fully loaded, open it with a double mouse click. By default, the environment will be installed in ProgramFiles \\ PowerShell \\ and create a shortcut in the Start menu. If you are a happy Windows user, click on the system icon in the lower left corner and enter PowerShell to "find programs and files". Run the application, enter your first cmdlet and start working.

    List of necessary commands and instructions for PowerShell

    The name of each cmdlet is represented in the form "verb-noun" or "Action-Object". We offer a list of the most important CMDLETS PowerShell for Windows 10 and previous versions, starting with XP. They will be useful even to novice users who have just learned how to maintain text documents.

    1. Get-Help. Built in the core cage celler. It is intended to call a certificate and provides useful information about syntax, programs, their appointment, other cmdles. If in the usual command interpreter you wrote IPCONFIG /?, Then in PowerShell you need to dial GET-HELP Get-Process.
    2. Get-Content. Simplifies the procedure for reading files for beginners and system administrators. If earlier it was necessary to open the handle and read all the lines of the document, now just give the file cmdlet. To do this, write in the C: \\\u003e GET-CONTENT C: \\ ... \\ "file name" in the console. "Extension".
    3. Get-service. Access to information about the services installed on the computer.
    4. Get-Member. Gives information about the returned cmdlet object, allows you to see its properties and methods.
    5. Get-Command. Searches for cmdlets, returns all information about them, including data on functions, scripts, applications, and other elements. In version 5.0 PowerShell for Windows 10 in Get-Command, the Version column has been added, and now the commanders displays several versions of the same module at once.
    6. STOP- \\ START-SERVICE. An indispensable assistant for administrators. The cmdlet launches and stops services on deleted and local computers.

    Special Symbols for Scripts

    In addition to cmdlets, the PowerShell utility in Windows 7 and above includes special characters, such as $ _ or (). The greatest perplexity of the icons cause newcomers who did not have the case with Linux-like systems or programming.

    1. Vertical trait "|". This symbol is used for programs with conveyor data transfer. When working with the console, it includes when they want to specify the command to the right of the vertical feature to accept the output from the left command. In PowerShell, the vertical feature is used by almost the same purpose, combining several teams at once. For example, create a new username, add it to a group and reset the default password.
    2. Function sign "()". Allows you to effectively monitor the process of execution of scenarios. As in C-like programming languages, the PowerShell function is formed by entering into several cmdlets in curly brackets and is ready to start the required number of times.
    3. Special symbol $ _. Used to write scripting blocks, filters and procedural expressions. $ _ takes the value of the current object and transmits it to the following. Using the dollar sign, without a lower underscore, you can designate or enter a variable: $ var \u003d "Hello".

    What is PowerShell ISE

    Complete with the PowerShell utility is a graphic application of Windows PowerShell ISE. This is a shell, or an integrated environment for writing scripts. ISE provides developers a huge range of possibilities. With it, you can create, debug and edit scripts, open text and XML files. Color highlighting of the syntax greatly facilitates testing and search for errors in the code.

    ISE is much more convenient than the PowerShell console and can completely replace it. Using the environment, you can copy and insert large code fragments, start not all script, but its separate parts. Unlike PowerShell, the window size in the ISE is easily changing the mouse pointer, as when working with the usual program.

    To try the ISE environment, enter PowerShell ISE in the Start menu. If you are not using Windows, but another OS, download and install a distribution from the official site. After starting the application, a window of three parts will open. The top scripts are written at the bottom - PowerShell teams, and in the middle there is a result.

    Start acquaintance with ISE and in the lower window, enter Get-Process. Press TAB several times. Next to the cmdlet will appear its parameters that will change after each keystroke. This will be your first session with a script environment from Microsoft.

    We all know what the command line is what opportunities it gives, but not everyone knows about a similar interface called. In fact, it is almost the same command line, only with much more possibilities. In this article, we are talking about what PowerShell is, and that this tool can offer us.

    Definition of PowerShell.

    Let's start with what is a shell. The shell is an interface that allows you to use any functions of the operating system. Thus, PowerShell is a shell that Microsoft has developed and is intended for more automated tasks. This tool is based on .NET and command line shells, as well as scenario language.

    Also, there is such a concept as which acts as an integrated scenario environment, in other words, this is a graphical interface with which we can create some scenarios, and you do not need to enter all commands to the command line.

    The first version of the PowerShell tool appeared in 2006 for Windows XP, Server 2003 and Vista. At the moment, the latest version of the 4.0 tool. Released in 2013 with Windows 8.1.

    What functions perform PowerShell?

    As I said above, Microsoft has created this utility so that any tasks with the operating system can be performed much faster. Suppose you want to see that are connected to the computer, so this can be done using PowerShell. You can still create, which will be performed in the background, until you do your affairs. If extra background processes that load systems are selected, they can be turned off using PowerShell. Also, you can create a document in which information about computer networks or other will be stored.

    Thus, using this utility you can easily and quickly perform time-consuming tasks, as well as create any scripts or combine several commands.

    In the event that you are a network administrator, then PowerShell can help you in work, for example, with Active Directory. Also, it is worth noting that the utility contains more than 100 commands. This suggests that it will help you solve most of the tasks.

    Run PowerShell on Windows 7

    In order to start PowerShell on this operating system, it is necessary to enter where the start, introduce "".

    A different tool can be opened if you enter the Start menu, all programs, standard and folder Windows PowerShell.

    Run PowerShell on Windows 8.1

    To open PowerShell in Windows 8.1, you must enter the keyword "" to open the search, click Win + Q..

    Another opening method - through the window " Perform" Press Win + R.The window opens in which you enter.

    Use in everyday life

    This tool uses many IT specialists and administrators and not in vain, as it gives great opportunities and reduces the time to perform any tasks.

    If the user has a large network in its use, which consists of several hundred servers, it will be necessary to implement a security system that will work when using a specific service. The problem is that you need to check if this service is installed on all servers. Of course, it can be connected manually to each server, but the manual does not like it very much, since a lot of time will take this task.

    To reduce work time up to a few minutes, you can use PowerShell, with which we will collect all the necessary information using one scenario and save it to a separate document.

    Also, not few books are written about this tool, after all, this tool gives ample opportunities that are unlikely to be described in this article fully. Thus, if you are interested in this topic, you can start it to study it in more detail.