And studying the menu Windows start 7 or home screen Windows 8 1, novice users often discover applications whose purpose they do not understand. Just one such application is PowerShell. What is this PowerShell and is it of any use? Well, since someone came up with it and integrated it into Windows, it means there is some sense after all. By the way, this one who invented PowerShell is Microsoft company.

So, . This application is intended primarily for system administrators, but ordinary users, especially beginners, will get almost no benefit from it. PowerShell is a modern standardized shell command line, providing greater flexibility in managing a computer based operating system Windows. Essentially, PowerShell is the same command line, but only much more functional.

What can this administration tool do? Many things. With its help, system administrators and advanced users can manage processes, services, file storages, accounts and even servers. The shell also allows you to run external commands, work with objects .NET, COM And XML, perform various tricks, etc., create and perform your own scenarios. By the way, for writing scripts in Windows there is a special graphical console I.S.E., which is a kind of addition to the main PowerShell shell.

Just like the console CMD, PowerShell has its own set of commands called cmdlets. The utility recognizes many of the CMD commands, but in general the language syntax, definitions of cmdlets and their parameters differ from what users are used to seeing in a regular command line. In addition, familiar commands like dir , CD , copy etc., which are perfectly understood by PowerShell, are actually aliases. For example, the command Dir , used for viewing file system matches the native cmdlet Get-ChildItem. Pseudonyms, or as they say, aliases, are purely for convenience.

Understanding PowerShell for a novice user, especially if he is unfamiliar with at least the basics of a regular command line, will not be easy. But there are not so many manuals and reference books that are clear enough and easy to understand. There is a good guide written by Frank Koch, which we recommend reading if you decide to start learning the PowerShell scripting language. Well, and of course, the shell’s own help system.

It is powerful and comprehensive, with many specific examples. It's quite simple to use. Basic information about help system output by cmdlet Get-Help. Cmdlet Get-Command displays a list of all available commands.

With mysterious writing and a persistently blinking cursor? This is the command line. The utility is present in all versions of Windows. With its help, it is convenient to manage the system, call programs, and find files. But cmd is not functional enough for professional work. Therefore, Microsoft decided to correct all the disadvantages of the console and released the product under named Windows PowerShell. What is it and how to use the development, read on.

What is PowerShell on Windows

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

Note that Windows PowerShell is not a simple operating shell. Microsoft has created a powerful, extensible, yet flexible management automation tool that can function as a dedicated scripting language.

On August 18, 2016, Microsoft announced that Windows PowerShell is now an open source product. source code, available to every developer. The company also added support for Unix-based operating systems, including Linux distributions and OS X.

How to Manage PowerShell

Cmdlets, or cmdlets, are used to perform tasks. These are small commands written as executable files. In version 2.0 of PowerShell for Windows XP and Server 2008 R2, the creators added modules that allow you to manage more resources, including Active Directory and Exchange Server.

There are currently over 130 modules and commands built into the PowerShell automation tool. They provide access to files, networks, registry, administration and other system capabilities:

  • setting time and date;
  • working with folders and individual files;
  • getting help and additional information;
  • data import and storage;
  • scripting techniques;
  • separate scripts and applications;
  • checking system security and working with descriptors;
  • system administration;
  • checking disk space.

Considering that Windows PowerShell is an extensible environment, users can create their own commands and write “author” modules using the .Net language.

Getting started with PowerShell

The latest beta version 6.0 of PowerShell was released in 2016. In Windows 7, 8 and 10, the utility is built-in. If you are using a different operating system, you will have to download the application. To do this, go to the official website microfoft.com and enter Installing Windows PowerShell in the search box. The system will automatically take you to a page with the latest product releases. Select your OS from the list and click Download.

When the file is completely downloaded, open it double click mice. By default, the environment will install to ProgramFiles\PowerShell\ and create a shortcut in the Start menu. If you are happy user Windows, click on the system icon in the lower left corner and type PowerShell in “Search programs and files.” Launch the application, enter your first cmdlet and get started.

List of required commands and instructions for PowerShell

Each cmdlet name is in verb-noun or action-object form. We offer a list of the most important PowerShell cmdlets for Windows 10 and previous versions, starting with XP. They will be useful even for novice users who only yesterday learned to save text documents.

  1. Get-Help. A cmdlet built into the shell core. Designed to call up help and provides useful information about syntax, programs, their purpose, and other cmdlets. If you wrote ipconfig /? in a regular command interpreter, then in PowerShell you need to type Get-Help Get-Process.
  2. Get-Content. Simplifies the process of reading files for beginners and system administrators. If previously it was necessary to open the descriptor and read all the lines of the document one by one, now it is enough to pass the file to the cmdlet. To do this, enter C:\> Get-Content C:\...\"file name.""extension" in the console.
  3. Get-Service. Access to information about services installed on the computer.
  4. Get-Member. Displays information about the object returned by the cmdlet and allows you to see its properties and methods.
  5. Get-Command. Searches for cmdlets and returns all information about them, including data about functions, scripts, applications, and other elements. Version 5.0 of PowerShell for Windows 10 added a Version column to Get-Command, so CommandDet now displays multiple versions of the same module.
  6. Stop-\Start-Service. An indispensable assistant for administrators. The cmdlet starts and stops services on remote and local computers.

Special characters for scripts

In addition to cmdlets, PowerShell in Windows 7 and later includes special characters such as $_ or (). The icons cause the greatest confusion among beginners who have not dealt with Linux-like systems or programming.

  1. The vertical bar "|". This symbol is used for pipelining programs. When working with the console, it is turned on when one wants to instruct the command to the right of the vertical bar to accept output from the command to the left. In PowerShell, the vertical bar is used for almost the same purpose, combining several commands 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 control the process of script execution. As in C-like programming languages, a function in PowerShell is formed by enclosing several cmdlets in curly braces and is ready to be run as many times as necessary.
  3. Special character $_. Used to write script blocks, filters and procedural expressions. $_ takes the value of the current object and passes it to the next one. You can use a dollar sign without an underscore to represent or enter a variable: $var = "Hello".

What is PowerShell ISE

The PowerShell utility comes with a graphical Windows PowerShell ISE application. It is a shell, or integrated environment, for writing scripts. ISE provides developers with a huge range of options. With its help you can create, debug and edit scripts, open text and XML files. Colored syntax highlighting greatly facilitates testing and finding 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 paste large fragments of code, and run not the entire script, but its individual parts. Unlike PowerShell, the window size in ISE can be easily changed with the mouse pointer, as when working with a regular program.

To try ISE, type PowerShell ISE in the Start menu. If you are using another OS other than Windows, download and install the distribution from the official website. After launching the application, a three-part window will open. Scripts are written at the top, below - PowerShell commands, and in the middle you can see the result.

Get started with ISE and enter Get-Process in the bottom window. Press Tab several times. Next to the cmdlet, its parameters will appear and will change after each keystroke. This will be your first session of working with Microsoft's scripting environment.

Many users know about the Command Prompt, but very few have heard about Windows PowerShell. In a sense, PowerShell is a tool that aims to replace the command line and provide more powerful capabilities for managing the Windows operating system. In this article, we will try to explain clearly what this tool is, why it is so powerful and who tends to use it most often.

What is PowerShell?

For better understanding, we must first understand what a shell is. In computer science, a shell is a user interface that provides access to various services operating system. The shell may be command line based or may include a graphical user interface (GUI).

Windows PowerShell is a shell developed by Microsoft for task automation and configuration management purposes. This powerful shell is based on the .NET framework and includes a command line shell and a scripting language.

There may also be a Windows PowerShell ISE on top of the standard command line shell. ISE acts as an integrated scripting environment - a graphical user interface that allows you to create various scripts without having to enter all the commands on the command line.

The first version of PowerShell was released in November 2006 for Windows XP. Windows Server 2003 and Windows Vista. The latest is version 4.0, which was released in October 2013. It comes by default with Windows 8.1 and Windows Server 2012 R2.

What can you do with PowerShell?

Microsoft developed Windows PowerShell as a tool that helps automate and quickly solve many tedious administrative tasks. For example, you can use PowerShell to see all USB devices installed on one or more computers on a network, or you can set up a time-consuming task to run in background while you do other work. You can also identify and terminate processes that are not responding, or filter specific information about computers on your network and export it to HTML format.

PowerShell's capabilities allow you to simplify and automate time-consuming and repetitive tasks by creating scripts and combining multiple commands together.

If you are a network administrator, you will find PowerShell very useful when working with Active Directory. Considering that the tool contains hundreds of customizable commands called cmdlets, the likelihood that PowerShell can help you become more productive is very high.

How to run PowerShell on Windows 8.1?

If you don't have a PowerShell tile on your Start screen or a shortcut on your desktop, then you can open it using search - this is one of the most simple ways. Press +Q, type "powershell" and then press Enter.

You can also open PowerShell from the Apps section of your Start screen: Go to the Start screen and move your cursor to the bottom left corner, just below the last tile in the first column. Click on the icon with the arrow pointing down. Then click on the PowerShell icon in the "Utilities" section.

To open PowerShell using the Run dialog, press +R, type "powershell" and press Enter.

How to run PowerShell on Windows 7?

On Windows 7 you can find the tool at keyword"powershell" in the start menu.

You can also open PowerShell through the Start menu in the Accessories section.

Obviously, the above command in the Run window works in Windows 7 as well.

Who usually uses PowerShell?

Without any doubt, PowerShell is the choice of many IT administrators. And for good reason, because the tool greatly simplifies management operations and reduces the amount of work in large corporate networks.

Let's say you're in control large network, containing over five hundred servers, and you need to implement a new security solution that depends on some service that needs to run on those servers. Of course, you can connect to each server and see if the required service is installed and running on them. However, in this case, your management is unlikely to be satisfied, because you will need too much time to complete the task.

WITH using PowerShell you can do this job within a few minutes as the entire operation can be done with a single script that will collect information about the services running on the specified servers and save it as a text file e.g.

PowerShell allows you to do much more than can be covered in one article, so if you are truly interested, we highly recommend that you purchase and read one of the many books that cover the power of this tool.

Have a great day!

Experienced operating room users Windows systems 10 may have heard about the command utility PowerShell strings. Those with experience working with Windows 7 and 8.1 may also be familiar with it. After many years of using the command app Windows strings and .bat files, it's time to get acquainted with a more functional tool.

PowerShell is a valuable addition to the list of Windows tools, and its scope may be intimidating for some users. What is it - a scripting language or command shell? Don't worry: despite the extensive capabilities, anyone can master PowerShell.

Step 1: Installation

First, we need the PowerShell utility itself. If you're running Windows 10, you already have PowerShell 5 installed. Windows Update The 10 Anniversary Update uses version 5.1, but the difference is not noticeable. Windows 8 and 8.1 use PowerShell 4, which is also quite sufficient. Installing PowerShell on Windows 7 will not cause problems, but you will still have to take a couple of extra steps. 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-fledged GUI, known as Integrated Scripting Environment (ISE). For beginners, it's best to use the PowerShell console, a simple text-based Windows command line-style interface, or even DOS 3.2.

To run PowerShell as an administrator in Windows 10, click the Start button and scroll down to Windows PowerShell. On 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 a regular user, PowerShell can be launched in the same way, using the left mouse button instead of the right one.

At any Windows versions you can apply a search. For ease of future use, you can pin PowerShell to the taskbar.

Step 2: Old Windows Commands

Syntax Windows commands in PowerShell it works as usual. For example, CD changes folders, dir shows a list of all files and folders inside the current folder.

Depending on how you launch the PowerShell console, you might start in c:\Windows\system32 or in c :\Users\ . The example in the screenshot uses the command CD..(with a space) to move 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: Install Help Files

Teams like CD And dir are not active PowerShell commands. These are so-called aliases - replacements for real PowerShell commands. Aliases are useful for those who have extensive experience with the command line. However, they don't 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 the PowerShell command Get-ChildItem. If you type get-childitem V PS C:\>, you will see the same thing as when using the command dir.

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

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

get-help get-childitem -examples

provides seven detailed usage examples get-childitem. Team

get-help get-childitem -detailed

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

Step 4: Get help with settings

In the screenshot you may have noticed two lists under SYNTAX For get-childitem. Having two different syntaxes means there are two ways to run the 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 regarding cmdlet parameters get-childitem or any other use parameter -full:

get-help get-childitem -full

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

Reviewing the parameter descriptions, you will notice that get-childitem makes it possible to get an object child(such as a subfolder name or file name) in a 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 parameter -recurse). Whereas

get-childitem “HKLM:\Software”

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

If you've ever tried to get into the registry using the Windows command line or .bat files, you'll appreciate the functionality of this access option.

Step 5: Learning Names

There's a reason why the cmdlets shown so far look similar: get-childitem, update-help, get-help use a single verb-noun pattern. All PowerShell cmdlets use this convention; they use a verb before a single noun. This will appeal to those who once suffered from inconsistent command names in the VB and VBA languages.

Take a look at the most common cmdlets:

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

get-content: Gets the contents of the file

get-item: Retrieves files and folders

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

remove-item: Deletes files and folders

: Gets processes running on a local or remote computer

get-service: Gets services running on a local or remote computer

invoke-webrequest: Retrieves content from a web page on the Internet

To view how a specific 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 V c:\temp, use

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

By typing this command, you'll see several interesting features of the PowerShell environment. For example, if you type copy-i and press the Tab button, PowerShell will fill in Copy-Item. If you type a cmdlet incorrectly and PowerShell cannot recognize it, a full description of what was done wrong is given.

Try this cmdlet:

invoke-webrequest askwoody.com

You'll get a short list of the web page's titles, images, links, and other content. Please note in get-help to the list invoke-webrequest, which “returns a collection of forms, links, images and other important HTML elements" - exactly what should be shown on the screen.

Some cmdlets help you manage PowerShell itself:

get-command: list of all available cmdlets

get-verb: list of all available verbs

clear-host: Clear the host program screen

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

get-command *-service

All verbs available with the 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 (> symbol) and pipes (| symbol) take the result of an action and attach it to another location. For example, you can redirect the result of the command dir V 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 on the second team find searches for a string packets, taken from the address askwoody.com by the team ping and concatenates all matching lines into a file called temp2.txt.

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

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

Using redirection and pipes greatly expands the capabilities of the Windows command line: instead of endlessly scrolling down the screen to search for a text string, you can filter the Windows commands you need.

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 comes when lining up the objects. The objects supplied by one cmdlet must match the type of objects accepted by the receiving cmdlet. The text is very simple type objects, so if you're working with text, aligning objects is a simple task. The remaining objects are not so basic.

How to understand this? Use cmdlet get-member. If you want to know what type of object a cmdlet is processing, run it through get-member. For example, if you are trying to understand the processes running on a computer and have narrowed your options down to cmdlets , here's how to find out 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 below screenshot also shows the properties entitled get-process Handles, Name, NPM, PM, SI, VM And W.S..

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. To find the cmdlet you need, use PowerShell again:

get-command -Parametertype System.Diagnostics.Process

This cmdlet provides 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 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 a computer with the name "svchost", that is, you want to match the property Name process svchost. Use the command:

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

Cmdlet looks 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 look, for example, at frequently requested PowerShell commands.

These commands only work on Windows 10 and only when you run PowerShell as an administrator. They are designed to reinstall pre-installed Windows applications 10 and may be useful to those who first deleted these programs and then decided to return them. The commands look like this:

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

If you run this command, ignore the red warnings and when the command completes, restart your computer; everything before installed programs in Windows 10 will appear in their places.

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

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

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

  • Switch -Register used for registration existing installations application packages, you can set parameters DisableDevelopmentMode And Register
  • Switch -DisableDevelopmentMode tells Windows to re-register an existing application package that has been disabled, 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 visual elements associated with the application.

After the reboot, all added application packages are downloaded and installed from the Windows Store.

PowerShell 5.0 comes with Windows 10, but for previous OSes a new version was released as part of Windows Management Framework 5.0 only at the end of February, and on the second try. Today I'll talk about some of the new features, but I'll start with why you might need PowerShell.

Why do you need PowerShell

There is no point in learning PowerShell just like that, and this is true for any language - scripting, software, and even human. Like many Microsoft solutions, PowerShell is designed with business in mind to automate the tasks of managing PCs and servers in organizations.

The scripting language is based on the powerful .NET software platform, so PowerShell's capabilities extend well beyond administration.

Once I needed to remove one column from a set Excel books 2013. Handmade I hated it, but googling didn’t give me any results ready-made solution. I created a topic on the forum (yes, I also sometimes ask questions on OSZone :). Any language was suitable for me, but the solution unexpectedly turned out to be PowerShell. As it turned out, you can load Excel as a COM object and manipulate it further.

Subsequently, I more than once used a modification of that script to automatic update dozens of Excel workbooks pulling data from other files. This saved me a lot of time and effort.

I think the idea is clear, and we can now move on to the new features of PowerShell 5.0.

8 useful features

Syntax highlighting

The new console is much easier to navigate!

The red color and line numbering, however, are from another opera.

Search through history in two directions

Keyboard shortcuts: Ctrl + R and Ctrl + S
Cmdlets: Get-PSReadlineKeyHandler And Set-PSReadlineKeyHandler

Like CMD, PowerShell has a session history with arrow navigation, a Get-History displays a log similar to F7. Full list Keyboard shortcuts associated with the log can be displayed like this:

Get-PSReadlineKeyHandler | ? ($_.function -like "*hist*")

There are two new history search features in the results, which are shown in the image below. It works very simply.


Unlike Get-History, which contains the history of the current session, this history is maintained globally and is saved when the window is closed.

Thanks for the tip to Anton Drovosekov and Konstantin Sidyakin from our VK group.

Creating connections, symbolic and hard links

Cmdlets: New-Item, Remove-Item, Get-ChildItem

I have a lot of stories on my blog, so I couldn’t ignore the possibility of creating them in PowerShell.

#Symbolic link to the file New-Item -ItemType SymbolicLink -Path C:\test\MySymLinkFile.txt -Target C:\test\1.txt #Symbolic link to the folder New-Item -ItemType SymbolicLink -Path C:\test\MySymLinkFolder -Target C:\Windows\ #Hard link to file New-Item -ItemType HardLink -Path C:\Test\MyHardLinkFile.txt -Target C:\test\1.txt #Connection New-Item -ItemType Junction -Path C: \Temp\MyJunctionDir -Target C:\Windows

To be fair, the command syntax is mklink It’s easier to remember, so it might be faster like this:

Iex "mklink /d C:\test\MySymLinkFolder C:\Windows"

Creating a temporary file

Cmdlet: New-TemporaryFile

In scripts, you often need to create a temporary file in order to drop some information there. A new cmdlet is created just for this.

#Create a temporary file New-TemporaryFile #Create a temporary file and get its full path $tmpfile = (New-TemporaryFile).FullName $tmpfile

I rarely do a clean install of the main system, but it happens regularly on VMs. And OneGet is very convenient for quickly auto-installing a key set of programs.

Note. You can use this module without installing WMF 5.0. A preview version of the module for PS 4.0 and 3.0 is available separately - March 2016, and search for more recent ones in the download center for PackageManagement PowerShell Modules Preview.

Installing programs

This example installs four programs and a full set of utilities from the Chocolatey repository. The first three commands are executed once, and the policy change must be confirmed. The fourth command quietly installs the listed programs, and the fifth simply saves time.

#Allow installation of signed packages from the Internet Set-ExecutionPolicy RemoteSigned #Install the Chocolatey provider Get-PackageProvider –Name Chocolatey -ForceBootstrap #Make Chocolatey trusted Set-PackageSource -Name Chocolatey -Trusted #Install programs Install-Package NotepadPlusPlus, vlc, firefox, filezilla, sysinternals -Verbose -Force -ProviderName chocolatey #Add path to executable files (sysinternals) to PATH setx PATH "$env:path;C:\Chocolatey\bin" -m

The supplier downloads a package to C:\Chocolatey\lib, which is based on the chocolateyInstall.ps1 script. It downloads the program installer from the official website into the %temp%\Chocolatey folder and runs it in silent installation mode. The simplest example– Notepad++.

Install-ChocolateyPackage "notepadplusplus" "exe" "/S" "https://notepad-plus-plus.org/repository/6.x/6.9/npp.6.9.Installer.exe"

Search programs

There are many programs in the repositories, all the most popular ones are definitely there.

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

Uninstalling programs

With deleting applications, not everything is so smooth, however.

Uninstall-Package -name filezilla

Ideally, removing a package should result in silent removal of the program, but the implementation depends on the author of the package and the capabilities of the installer. In practice, some packages do not contain uninstallation scripts, others come up with crutches in the form of AutoHotkey scripts, and others simply launch the uninstallation interactively, asking you to complete the process manually. However, if the installer is MSI, the removal works smoothly.

Related links to OneGet and silent installation:

  • Step-by-step guide to installing programs from PowerShell (Dmitry Bulanov)
  • Types of installers and silent installation keys (my 2005 article is quite relevant :)
  • Windows auto-installation site and program auto-installation forum

Discussion and poll

For experienced scripters and system administrators, PowerShell 5.0 has other interesting features (for example, classes similar to object-oriented programming languages). You can find the full list on this TechNet page (the link leads to the English version specifically, since the Russian one does not yet contain information about 5.0).

You can mark fragments of text that interest you, which will be available via a unique link in address bar browser.

about the author

Syntax highlighting in PowerShell 5.0 is the default PSReadLine module. IN previous versions you can install it additionally and add it to the load in the profile script (the $profile variable) or load it yourself when necessary

Import-module psreadline

Can you tell me more about silent installation from scripts? Not long ago I started using chocolatey, I really like it, especially updating all programs with one command. Haven't figured it out yet quiet installation, I set everything in manual mode, command-confirm-installation.

6yHTapb

the only thing for which I needed PowerShell in win 10 so far was to work around a bug with broken button"properties" in VPN settings connections. Set-VpnConnection -Name "Name" -SplitTunneling $true.
By the way, Vadim. Is there any information on this? We are talking about the button in the properties VPN connections- network - IP version 4 - “properties”. There you can usually uncheck the “use a gateway on a remote network” checkbox. The button itself is active, but when pressed nothing happens. This is where PowerShell came in handy.

Sergey Roshchin

Thank you so much for Chocolatey
on windows 7, as I understand it, it doesn’t work?

Lecron

By voting... I use almost all options. Some of the programs in portable form. Part - installed manually from the disk, for those who can update themselves or serious modifications have long been completed. Of these, some are scripted. Some are new. Some of it is already preinstalled in the image.
Again, clients and tasks vary.

About PowerShell... I think Microsoft missed the mark with the name. At first glance, it is not clear what happened. Command shell/processor or scripting programming language. The word Shell suggests the first, but then it’s high time, since it’s so cool, to make it the default or at least promote it as the main one. But real use cases point more towards the second, replacing WSH.

  • Lecron: but then it’s high time, since it’s so cool, to make it the default or at least promote it as the main one.

    In Win+X, you can replace CMD with PS (taskbar properties - navigation). And they have been promoting it as the main one for a long time - there has been nothing new on TechNet about CMD for a long time, only PS.

    Of course, the target audience is IT specialists, but the same can be said about CMD and WSH. But I don’t see any harm to the target audience of my blog. I find use for PS at home and at work, and it doesn't involve administration.

    • Lecron

      I'm not talking about harm. And about misunderstandings and corresponding mistakes.
      What it is? How does Microsoft see it? The command processor, which usually works in interactive mode, which also Maybe

      Working interactively in one syntax and semantics, and writing sequences of actions in others is ridiculous. This is the main problem. So deep that even you don’t notice it, although you mentioned it indirectly in the article. The mklink syntax is not simpler, but more familiar. Since New-Item, with united syntax, allows you to create very, very many things. And now, in fact, its syntax is simpler than knowing many individual utilities, including their names.

      The promise was kept - here's a module for managing package managers, go ahead.

      Didn't understand. What is a “manager management module”?

        • Lecron

          It seems to me that this is where the dog rummaged. In providers. When there is no uniform approach to package management. In fact, the user has to know and take into account which provider is being used. And not only for users, but also for maintainers.

          The feature, as usual, is aimed at organizations, and MSI and MSU are fully supported.

          Lecron

          Perhaps I did not understand the full depth of this feature, which is why such stupid claims.
          Will the user need additional steps if the owner of the repository/package changes providers? Or will the package creator change its settings? Or does the package manager take care of all this?

          Hm... here's a feature - take it, try it, figure it out - it will help solve some questions. There is a supplier, he has packages in the repository. Did you remove a specific package? Then you will not be able to download it from this provider. But the package that has already been downloaded remains locally and can be further managed.

          Lecron

          By the way, here's another question. Is there an Update-Package command, or better yet, Update-AllPackage?

          Hello. Tell me, is it possible to restore the boot or bios and how to do it? Windows 7 Pro bootloader crashed. I have already changed the settings in boot but Windows does not want to boot. Previously, Windows 8.1 was presented in the service; they installed Windows 7 Pro without my consent. Help solve the problem!

Alexei

I’ve often heard about chocolate, and since I was reminded, I finally decided to try it. the result was not particularly impressive.

I massively installed a set of software already installed on the PC. only about 70% was found in the repository.
keys -y -accept-license -f -x - I smoked mana for just a couple of minutes, maybe I didn’t understand something.
result:
software that I didn’t ask for: autoIT, autohotkey. For what?
rolled on old version Acrobat Reader DC, cheat engine;
could not download dropbox virtualbox;
quiet mode did not work viber, wireshark, light alloy - I had to check the boxes and press further;
Skype removed the old one, but did not install the new one.
and some of the shortcuts were not created, now you need to remember which ones.

Warnings:
- adobereader
- windjview
- firefox
-notepadplusplus
—teamviewer

I don't understand what the errors are here.

on a clean system, in any case, you will have to download the rest of the software by hand, or install a no longer supported one from the archive.
plus it’s rare, but in some places during installation you need to select certain configurations - the composition of packages, etc. here this can only be implemented using scripts for each product, which does not save much time at home. since all these options can change, and do change from version to version, you need to monitor and rewrite the scripts. doesn't sound very good.
if it could scan the registry and add it to the database or to the GUI software for selection, it would be easier. Otherwise, you first need to spend time compiling a list for installation - to be sure, I checked each product to indicate the correct package name.

  • Sergey

    PS C:\Users\Gerald> 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...

    Just today I came across the mention of Chocolatey on Habrahabr for the first time and right there in your newsletter. It seemed that this was it! I thought there would be an amazing scripted replacement for the auto-installation of free software from ninite.com, but alas. The relevance of the software is not supported at a paranoid level, and the problems are those described by the participants above.

    Vitaly

    I think the UNIX philosophy is better suited for the console:


    Write programs that work together.
    Write programs that support text streams because it is a universal interface.

    • Vitaly, does Windows include a console utility for ZIP? This is done to simplify PowerShell scripts; there is no need to go into CMD, integrated help, etc.

      • Lecron

        Why bother with cmd if both shells and both must independently launch executable files and manage their input/output?
        I don’t object to the inclusion of such functionality, especially if it’s done wisely, as an interface to zlib, and not just another swelling of the code base - one thing in the explorer, another in the shell, a third party in cmd.

        Vitaly

        No, it's not included.
        But on my hosting, when I first tried to use zip, I received something like “zip is not installed. Install with apt-get install zip."

        Go to cmd? It was said above that PS should run binaries.

        Reference? IN Linux team man %utility_name% or %utility_name% -?, the first gives a detailed manual, the second as a brief reference on the parameters. It seems to work everywhere.

        As a result, the command interpreter on Linux is both a simple and powerful thing, there are many alternatives, since there is nothing complicated in it, it simply runs programs, controls the output stream and interprets the simplest syntax.

        strafer

        Vadim Sterkin: Vitaly, does Windows include a console utility for ZIP?

        I’m embarrassed to ask: wouldn’t it have been easier to add it than to add the built-in functionality?

  • Herz Mein

    > why should the shell work with archives using its own means?

    If there is such a possibility inherent in .Net classes, then why not use it? It's just a different approach than bash or cmd, which are command line interpreters. CLI. And PowerShell is more of a debugger for scripts, IMHO.

    artem

    Lecron What it is? How does Microsoft see it? The command processor, which usually works in interactive mode, which also Maybe read commands from a file called a script? Or as a scripting language that has its own REPL? Do you agree that there is a big difference?

    It is clear that the tasks are different. But I don't see any contradiction between them. Those. It is quite possible to cover both needs with one tool. This is what PowerShell strives for. Some things turn out well, some not so much. But the vision is clear.

    artem

    Vadim Sterkin:
    And they have been promoting it as the main one for a long time - there has been nothing new on TechNet about CMD for a long time, only PS.

    It will be soon, I suppose. CMD (the shell itself) has now begun to be relatively actively refined. Although before this they didn’t touch it at all for ten years.

    artem

    Vitaly Write programs that do one thing and do it well.

    I don't see any contradictions. In PowerShell, each cmdlet does one thing (with very few exceptions). Whoever says that Expand-Archive can burn DVDs or make coffee - let him be the first to throw a stone at me.

    Vitaly Write programs that work together.

    Here PowerShell does all the shells I know, because... operates with objects, not text. Those. “working together” (passing data between cmdlets) is much more efficient. There is no need to waste time parsing text and trying to explain to the next team what exactly this text is.

    Vitaly Write programs that support text streams because it is a universal interface.

    Streams are also supported. And if you just need to transfer a test, there are no problems with that.

    That is, PowerShell fully follows the above philosophy.

    Vitaly For example, why put “Creating connections, symbolic and hard links” in PS with your own syntax if there is mklink? Why is there “Creating and unpacking archives” if there is zip and its analogues?

    Yes, because the specified commandlets are “analogous to zip”. In fact, the answer to this claim is very easy. You just need to realize that cmdlets are not built-in shell capabilities, but rather external commands. And everything immediately falls into place. It’s normal that we have commands to perform some actions, right? This is true for PowerShell as well as any other shell.

    Yes, there are a small number of cmdlets that come with the default shell. But ideologically they are no different from those cmdlets that appear separately when installing the corresponding Windows components or are even provided by third-party developers.

    • Lecron

      artem: It’s normal that we have commands to perform some actions, right? This is true for PowerShell as well as any other shell.

      Shell - so much of this word... began to be distorted under the influence of MS.
      All the time I believed that commands do not depend on the launch environment, and the commands built into the environment are needed only to service the capabilities of the environment itself, and not third-party objects. Was he really wrong?
      From this point of view, PS begins to resemble ACDSee and Nero.

      Vitaly

      Here PowerShell does all the shells I know, because... operates with objects, not text. Those. “working together” (passing data between cmdlets) is much more efficient.

      I doubt that all third-party utilities support these same objects. But the text is supported by any utility that works on the command line.

      You just need to realize that cmdlets are not built-in shell capabilities, but rather external commands. AND

      Why then do these cmdlets have their own syntax? Well, it doesn’t look like these are external commands.

      • artem

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

        Third-party utilities - no, of course. But third-party cmdlets are easy. I would say that about eighty percent of third-party cmdlets work quite well with objects.

        If there is no cmdlet and you have to run the utility (executable file), then of course you have to feed it text as input. But it’s easy to get text from an object (by expanding the desired property, for example). I understand that this sounds abstruse, but after gaining a critical mass of experience, it turns out to be completely intuitive.

        Vitaly: Why then do these cmdlets have their own syntax? Well, it doesn’t look like these are external commands.

        I couldn't agree more with this. “It doesn’t look like” is the right word :)

        As I said above, PowerShell takes some getting used to. And now I’ll say something nasty about our evangelists and MVP, but the abuse of aliases (dir instead of Get-ChildItem, md instead of New-Item -ItemType “Directory”, percent sign instead of Foreach-Object or question instead of Where-Object and so on, and also omitting the names of parameters in the case when the default works) only confuses unprepared people. Because of this, among other things, it took me years to get used to PowerShell. It seems to me that if all the example commands posted on blogs and forums contained the complete syntax, then newbies would experience much less anal pain.

    In fact, I use 2 options: deploying a backup made immediately after setting up the system, or setting own assembly Windows 7, where I include all the necessary settings and programs.
    And with Win10, I just haven’t mastered the package manager yet, although its presence arouses great enthusiasm.
    I used to play with different package managers for Windows, but for one reason or another they were all inconvenient in terms of “time to master”/”time to complete” manual download" It turned out to be easier to make your own assembly than to create scripts.

    Evgeny Kazantsev

    A wonderful undertaking, I saw how to install a pack of necessary programs with one script, I used ninite, I wasn’t particularly impressed, now I use WPI downloaded from torrents, the advantage of them is that there is a lot more and real auto-installation, minus that you need to trust the author of the repack.
    One thing I don’t understand is how to UPDATE installed programs completely automatically, which is a key basic feature of any package manager? How can I make the same Notepad++ automatically register as the default application without going into the terribly inconvenient “new, they’re modern” settings? How does the dependency system work, and is it even there?

    What if you design it as a script or function? For example, like this (without checking for existence and without converting to full paths, which is necessary):

    Param ( $create, $extract, $path, $zip) add-type -assembly 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 accordingly:

    .\test -c -p "C:\Some\Folder" -z "D:\Folder\out.zip" # To create.\test -e -p "C:\Some\Folder" -z "D: \Folder\out.zip" # To extract

    • What does the design have to do with it? You are using .NET classes directly in your function. The cmdlet eliminates the need to access classes. This is the difference. About the same as between a programmer and an IT specialist.

      artem

      Trolleybus made from a loaf of bread.jpg

      As I understand it, no one argues with the fact that functions can do anything at all :) The benefit, obviously, is that now there is no need to write a separate function specifically for this action. This means, firstly, it will be easier for people to use it (especially if they don’t know how to write functions or cannot afford to import them every time), and secondly, there will be more standardization. This is an undoubted blessing. Agree, it’s stupid when five scripts require five different authors to unpack archives, and each one solves this problem a little differently. (For example, at one time the option through the undocumented Windows Explorer COM object was popular).

    lesha

    I work on Windows and Mac, and if I set up a server, then Linux. I reinstalled OS X completely a couple of times, but everything is simple - I selected the date in TimeMachine 10-15 minutes and the system is ready.
    On Windows, most of my programs are portable, I only install Chrome because otherwise the package is not updated Adobe programs, because from the SS version they are downloaded via Cretive Cloud. I don’t see the point in building a garden with automation. PowerShell may be good, but I have nothing to automate on Windows, and for Linux and OS X there is bash, which I have been using for a long time.
    If a friend asks “reinstall Windows for me, otherwise something is buggy,” I install the system with external drive in his own “proprietary” way, and let him do the rest himself