PowerShell – Windows Blog by Brink

PowerShell

Change PowerShell Script Execution Policy in Windows 11

PowerShell’s execution policy is a safety feature that controls the conditions under which PowerShell loads configuration files and runs scripts. This feature helps prevent the execution of malicious scripts.

On a Windows computer you can set an execution policy for the local computer, for the current user, or for a particular session. You can also use a Group Policy setting to set execution policies for computers and users.

Execution policies for the local computer and current user are stored in the registry. You don’t need to set execution policies in your PowerShell profile. The execution policy for a particular session is stored only in memory and is lost when the session is closed.

The execution policy isn’t a security system that restricts user actions. For example, users can easily bypass a policy by typing the script contents at the command line when they cannot run a script. Instead, the execution policy helps users to set basic rules and prevents them from violating them unintentionally.

You can set an execution policy that is effective only in a particular scope.

The valid values for Scope are MachinePolicy, UserPolicy, Process, CurrentUser, and LocalMachine. LocalMachine is the default when setting an execution policy.

The Scope values are listed in precedence order. The policy that takes precedence is effective in the current session, even if a more restrictive policy was set at a lower level of precedence.

If you set the execution policy for the scopes LocalMachine or the CurrentUser, the change is saved in the registry and remains effective until you change it again.

If you set the execution policy for the Process scope, it’s not saved in the registry. The execution policy is retained until the current process and any child processes are closed.

This tutorial will show you different ways on how to set the PowerShell script execution policy for the current user, local machine, or current process in Windows 11.

Read more…

Add Run as administrator to Context Menu of PS1 Files in Windows 11

Windows runs desktops apps and application files (ex: .bat, .cmd, .exe, and .msc file types) in user mode by default without elevated administrator rights unless it prompts you with UAC to run elevated (highest privileges).

When you use Run as administrator on a desktop app or application file, you are allowing it to run with full administrator access to everything on the computer. This means you are giving it special permissions to access restricted parts of the computer that would otherwise be off-limits. This could be a potential security risk if not a trusted app or application file, but sometimes “Run as administrator” is necessary for a trusted app or application file to run properly if it requires elevated rights for full access.

A .ps1 file is a script, or “cmdlet,” used by Windows PowerShell.

This tutorial will show you how to add or remove the Run as administrator context menu item for .ps1 files for all users in Windows 10 and Windows 11.

Read more…

Check PowerShell Version in Windows 11

Windows PowerShell is a task-based command-line shell and scripting language designed especially for system administration. Built on the .NET Framework, Windows PowerShell helps IT professionals and power users control and automate the administration of the Windows operating system and applications that run on Windows.

This tutorial will show you how to check the current version of PowerShell in Windows 10 and Windows 11.

Read more…

How to Add “Edit or Run with” PS1 File Context Menu in Windows 10

A PS1 file is a script, or cmdlet, used by Windows PowerShell.

This tutorial will show you how to add or remove a custom Edit or Run with cascading context menu for PowerShell .ps1 files for all users in Windows 10.

The Edit or Run with cascading context menu includes the following items for PS1 files :

  • Run with PowerShell
  • Run with PowerShell as administrator
  • Run with PowerShell 7
  • Run with PowerShell 7 as administrator
  • Edit with PowerShell ISE
  • Edit with PowerShell ISE as administrator
  • Edit with PowerShell ISE (x86)
  • Edit with PowerShell ISE (x86) as administrator
  • Edit with Notepad
  • Edit with Notepad as administrator

Read more…

How to Change Default Terminal Application in Windows 10

Starting with Windows 10 build 21390, you can now select Windows Console Host (default) or Windows Terminal Preview v1.9.1445.0 or higher as the default terminal application (emulator).

This means that any command line application (ex: PowerShell, command prompt, etc…) will launch inside your selected terminal emulator by default.

If you select Windows Terminal Preview, then when you open any command line application (ex: PowerShell, command prompt, WSL, etc…), it will open inside Windows Terminal Preview by default.

If you select Windows Console Host, then when you open any command line application (ex: PowerShell, command prompt, etc…), it will open in its own PowerShell, command prompt, etc… window.

This tutorial will show you how to change the default terminal application to Windows Console Host or Windows Terminal Preview for your account in Windows 10.

Read more…

How to Add or Remove PowerShell 7 Open Here Context Menu in Windows 10

PowerShell 7 is the latest major update to PowerShell, a cross-platform (Windows, Linux, and macOS) automation tool and configuration framework optimized for dealing with structured data (e.g. JSON, CSV, XML, etc.), REST APIs, and object models. PowerShell includes a command-line shell, object-oriented scripting language, and a set of tools for executing scripts/cmdlets and managing modules.

This tutorial will show you how to add or remove the PowerShell 7 ‘Open here’ and ‘Open here as administrator’ context menu in File Explorer for all users in Windows 10.

Read more…

Enable Mapped Drives to be Available in Elevated Command Prompt and PowerShell in Windows

By default, mapped drives are not available from an elevated command prompt or elevated PowerShell when UAC is configured to “Prompt for credentials” in Windows.

See also: KB3035277 Mapped drives are not available from an elevated prompt when UAC is configured to “Prompt for credentials” in Windows | Windows Support

This tutorial will show you how to enable or disable mapped drives availability from an elevated command prompt and elevated PowerShell in Windows 7, Windows 8, and Windows 10.

Read more…

How to Install PowerShell 7.0 in Windows 7, Windows 8, and Windows 10

Microsoft has announced the Generally Available (GA) release of PowerShell 7.0 on March 4, 2020.

PowerShell 7 is the latest major update to PowerShell, a cross-platform (Windows, Linux, and macOS) automation tool and configuration framework optimized for dealing with structured data (e.g. JSON, CSV, XML, etc.), REST APIs, and object models. PowerShell includes a command-line shell, object-oriented scripting language, and a set of tools for executing scripts/cmdlets and managing modules.

This tutorial will show you how to download and install PowerShell 7.0 in Windows 7, Windows 8.1, and Windows 10.

Read more…

How to Install or Uninstall Windows PowerShell ISE in Windows 10

The Windows PowerShell Integrated Scripting Environment (ISE) is a host application for Windows PowerShell. In the ISE, you can run commands and write, test, and debug scripts in a single Windows-based graphic user interface. The ISE provides multiline editing, tab completion, syntax coloring, selective execution, context-sensitive help, and support for right-to-left languages. Menu items and keyboard shortcuts are mapped to many of the same tasks that you would do in the Windows PowerShell console. For example, when you debug a script in the ISE, you can right-click on a line of code in the edit pane to set a breakpoint.

Starting with Windows 10 build 19037.1, Windows PowerShell ISE is now a Feature on Demand (installed by default), and you will see it in the list in Optional Features Settings.

This tutorial will show you how to install or uninstall the Windows PowerShell ISE (Integrated Scripting Environment) app for all users in Windows 10.

Read more…

How to Install PowerShell Core on Windows

Over the years, there have been many releases of PowerShell. Initially, Windows PowerShell was built on the .NET Framework and only worked on Windows systems.

With the current release, PowerShell Core uses .NET Core 2.x as its runtime. PowerShell Core is a cross-platform (Windows, Linux, and macOS) automation and configuration tool/framework that works well with your existing tools and is optimized for dealing with structured data (e.g. JSON, CSV, XML, etc.), REST APIs, and object models. It includes a command-line shell, an associated scripting language and a framework for processing cmdlets. PowerShell Core is an Open Source project on GitHub.

PowerShell Core is a separate version of PowerShell that does not replace or upgrade the Windows PowerShell included in Windows by default. PowerShell Core can run side-by-side with Windows PowerShell.

This tutorial will show you how to install the latest release of PowerShell Core in Windows 7, Windows 8, and Windows 10.

Read more…

How to Check PowerShell Version in Windows

Windows PowerShell is a task-based command-line shell and scripting language designed especially for system administration. Built on the .NET Framework, Windows PowerShell helps IT professionals and power users control and automate the administration of the Windows operating system and applications that run on Windows.

This tutorial will show you how to check the current version of PowerShell in Windows 7, Windows 8, and Windows 10.

Read more…

How to Enable or Disable Scroll Forward in Console Window in Windows 10

A console (or “terminal) is an application that provides I/O to character-mode applications.

For example: command prompt, PowerShell, or Linux

Starting with Windows 10 build 18298, when you open the properties page of any Console window, you will notice an additional Terminal tab containing several new settings for some experimental features.

When Scroll Forward is enabled (default state), the Console can to scroll anywhere within the Console’s buffer, even below the most recent row of text displayed.

When Scroll Forward is disabled, the Console will not allow scrolling below the last line output, similar to how most *NIX terminals work.

This tutorial will show you how to enable or disable scroll forward in a console window (ex: command prompt, PowerShell, Linux) for your account in Windows 10.

Read more…

How to Change Cursor Shape of Console Window in Windows 10

A [URL=”https://docs.microsoft.com/en-us/windows/console/consoles”][B]console[/B][/URL] (or “terminal) is an application that provides I/O to character-mode applications.

For example: [URL=”https://www.tenforums.com/tutorials/3288-open-command-prompt-windows-10-a.html”][B]command prompt[/B][/URL], [URL=”https://www.tenforums.com/tutorials/25581-open-windows-powershell-windows-10-a.html”][B]PowerShell[/B][/URL], or [URL=”https://www.tenforums.com/tutorials/46769-enable-disable-windows-subsystem-linux-windows-10-a.html”][B]Linux[/B][/URL]

Starting with [URL=”https://www.tenforums.com/windows-10-news/123242-new-windows-10-insider-preview-fast-skip-build-18298-19h1-dec-10-a.html”][B]Windows 10 build 18298[/B][/URL], when you open the properties page of any Console window, you will notice an additional [B]Terminal[/B] tab containing several new settings for some experimental features.

This tutorial will show you how to change the cursor shape of a console window (ex: command prompt, PowerShell, Linux) for your account in [B]Windows 10[/B].

Read more…

How to Add Edit with PowerShell ISE x86 as administrator in Windows 10

The Windows PowerShell Integrated Scripting Environment (ISE) is one of two hosts for the Windows PowerShell engine and language. With it you can write, run, and test scripts in ways that are not available in the Windows PowerShell Console. The ISE adds syntax-coloring, tab completion, IntelliSense, visual debugging, and context sensitive Help.

The ISE lets you run commands in a console pane, but it also supports panes that you can use to simultaneously view the source code of your script and other tools that can plug into the ISE. You can even open up multiple script windows at the same time, which is especially helpful when you are debugging a script that uses functions defined in other scripts or modules.

If you have 64-bit Windows 10 installed, there may be times you want to edit a PS1 file with the 32-bit Windows PowerShell ISE (x86) instead of the 64-bit Windows PowerShell ISE.

This tutorial will show you how to add or remove a Edit with PowerShell ISE (x86) as administrator context menu for PS1 files for all users in Windows 10.

Read more…

How to Add Edit with PowerShell ISE as administrator context menu in Windows 10

The Windows PowerShell Integrated Scripting Environment (ISE) is one of two hosts for the Windows PowerShell engine and language. With it you can write, run, and test scripts in ways that are not available in the Windows PowerShell Console. The ISE adds syntax-coloring, tab completion, IntelliSense, visual debugging, and context sensitive Help.

The ISE lets you run commands in a console pane, but it also supports panes that you can use to simultaneously view the source code of your script and other tools that can plug into the ISE. You can even open up multiple script windows at the same time, which is especially helpful when you are debugging a script that uses functions defined in other scripts or modules.

This tutorial will show you how to add or remove a Edit with PowerShell ISE as administrator context menu for PS1 files for all users in Windows 10.

Read more…

How to Enable or Disable Windows PowerShell 2.0 in Windows 10

Windows PowerShell is a task-based command-line shell and scripting language designed especially for system administration. Built on the .NET Framework, Windows PowerShell helps IT professionals and power users control and automate the administration of the Windows operating system and applications that run on Windows.

Windows 10 includes Windows PowerShell 5.0 by default that has some great new features that enhance security including enhanced transcription logging and AMSI protection.

However, the Windows PowerShell 2.0 engine is still enabled and is now recognized as a security risk that can be used to run malicious scripts.

While Windows PowerShell 2.0 has been deprecated starting with Windows 10 Fall Creators Update, it may still be enabled on your system.

This tutorial will show you how to enable or disable Windows PowerShell 2.0 for all users in Windows 10.

Read more…

How to Add Windows PowerShell Script to New Context Menu in Windows 10

A .ps1 script file is a text file that contains one or more Windows PowerShell commands or expressions. A .ps1 file will open with Notepad by default. To run a .ps1 file with PowerShell, you would right click or press and hold on the .ps1 file and click tap on “Run with PowerShell”.

The New context menu allows users to quickly create new files, folders, and shortcuts. You can right click or press and hold on your desktop or in any folder window, and click/tap on New to open the New context menu.

By default, Windows PowerShell Script is not in the New click context menu. Adding “Windows PowerShell Script” to the New context menu will make it easy for users to be able to quickly create a new .ps1 file on demand ready to be edited afterwards.

This tutorial will show you how to add or remove Windows PowerShell Script to the New context menu for all users in Windows 10.

Read more…

How to Add ‘Open PowerShell window here as administrator’ context menu in Windows 10

Windows 10 comes with Windows PowerShell 5.0 included.

Windows PowerShell is a task-based command-line shell and scripting language designed especially for system administration. Built on the .NET Framework, Windows PowerShell helps IT professionals and power users control and automate the administration of the Windows operating system and applications that run on Windows.

This tutorial will show you how to add or remove a Open PowerShell window here as administrator context menu for all users in Windows 10.

Read more…

How to Add ‘Open PowerShell window here’ context menu in Windows 10

Windows 10 comes with Windows PowerShell 5.0 included.

Windows PowerShell is a task-based command-line shell and scripting language designed especially for system administration. Built on the .NET Framework, Windows PowerShell helps IT professionals and power users control and automate the administration of the Windows operating system and applications that run on Windows.

This tutorial will show you how to add or remove a Open PowerShell window here context menu for all users in Windows 10.

Read more…