How to convert a PowerShell script to EXE on Windows 10

Scripts are great for when you have a very specific need that an app can’t meet. If you know how to write a script, or you’ve found the perfect one, it’s likely going to ease an everyday task for you. A script is great but it comes with some restrictions. Sometimes, it’s better if you have an EXE file to work with and you’d be surprised to know just how easy it is to convert a PowerShell script to an EXE file.

Convert PowerShell script to EXE

PS2EXE-GUI is a tool that gives you a GUI for converting a PowerShell script to an EXE file. All you really need is the script and an icon for the EXE to use. Getting an icon is super easy so pick something that suits your script, and then download and run PS2EXE-GUI.

In the Source field, select the script that you want to convert to an EXE. In the Target File field, enter a name for the output file and make sure it has an EXE file extension. In the Icon field, select the icon file that you created for your executable.

The other fields are pretty self-explanatory so go ahead and fill them out. There are no other settings that you need to change. Click ‘Compile’.

A PowerShell window will open and show the compilation process. It shouldn’t take too long but when it completes, you will see a message ‘Press Enter to leave:’. Tap the Enter key twice to close the PowerShell window. Visit the folder that had the script you converted and the converted EXE should be there.

The app will not create an installable program. When you run the EXE file, it will simply run the script as though it were run from the PS1 file. If the script was written to perform a certain function and then quit itself, the EXE will act the same. It will still act like the original script, it’s just in a different packaging.

With a PowerShell script in the EXE file format, it makes it much easier to run the script as part of an automation process. Not all automation tools may play nice with a script but EXEs are usually better supported. If you’re looking to distribute a script and don’t want inexperienced users tampering with it, distributing it as an EXE is probably a better idea.

Have a batch script that you want to convert to an EXE? It’s just as easy though results may vary depending on the script.

Read How to convert a PowerShell script to EXE on Windows 10 by Fatima Wahab on AddictiveTips – Tech tips to make you smarter

How to fix “running scripts is disabled on this system” in PowerShell on Windows 10

If you know how to write simple PowerShell or Batch scripts, you can automate quite a few things on Windows 10. In fact, even if you have to spend a little time writing the perfect script for something, the time saved once it’s good to go will be worth the time you spent writing it. That said, scripts can be dangerous which is when you try to run scripts in PowerShell, you get a rather long error message that essentially tells you “running scripts is disabled on this system”.

This is a security measure in PowerShell to prevent malicious scripts from running and potentially harming the system. Of course, a script that you’ve written yourself isn’t going to be malicious and should be able to run. To fix this problem, you need to change the execution policy in PowerShell. Here’s how.

Fix running scripts is disabled on this system

Open PowerShell with admin rights, and run the following command.

Get-ExecutionPolicy -List

This will show you the execution policy that has been set for your user, and for your machine. It’s likely that both, or at the very least the CurrentUser policy is set to Restricted.

To fix the “running scripts is disabled on this system” error, you need to change the policy for the CurrentUser. To do that, run the following command.

Set-ExecutionPolicy RemoteSigned -Scope CurrentUser

Confirm that you want to make the change, and you will be able to run the script.

This should allow you to run most scripts however, if you’re still getting the same error, then you probably need to change the execution policy for the machine. You can modify the previous command to do so but you will need admin rights to do this.

Run this command.

Set-ExecutionPolicy RemoteSigned -Scope LocalMachine

Confirm that you want to make the change, and then try running the script.

This should do the trick if you’ve written the script yourself however, if you downloaded it online, and it isn’t signed, then you need to change the execution policy to Unrestricted. To do that, replace “RemoteSigned” in all of the above commands with “Unrestricted”. Be very careful which scripts you run if you’re downloading them. They can be dangerous.

Set-ExecutionPolicy

This is a fairly simple command for setting the execution policy on PowerShell. This command can have four different parameters, or states: Restricted, AllSigned, RemoteSigned, and Unrestricted.

The -Scope switch defines what the policy change is applied to. When you enter “CurrentUser”, it is applied to the current user only, and when you enter “LocalMachine”, it’s applied to the entire system

Read How to fix “running scripts is disabled on this system” in PowerShell on Windows 10 by Fatima Wahab on AddictiveTips – Tech tips to make you smarter

How to use the Cascadia Code font in Command Prompt on Windows 10

Fonts are made for different purposes; some look good on a restaurant menu, some look good on a website, some look good a business card, and comic sans looks bad everywhere. Some fonts are just easier to read than others and console apps are unlikely to use the same fonts that a word processor might. Command Prompt offers a modest selection of fonts that users can switch to. Microsoft has just released a brand new font for its new Terminal app called Cascadia Code. If you like it, you can install the Cascadia font in Command Prompt, and even PowerShell. Here’s how.

Install Cascadia Code

Cascadia Code is an open source TTF font. Go to its Github page and download it from the Releases tab. Once downloaded, you’re going to have to install it system wide in order to use it in Command Prompt or PowerShell.

To install the font, double-click the file and in the window that opens, click Install. Installation takes only a few seconds though you might have to authenticate with the admin account.

Cascadia Code font in Command Prompt

Now that the font has been installed, you can set Command Prompt to use it. Open Command Prompt and right-click the title bar. From the context menu, select ‘Properties’. Go to the Font tab, and look through the list of fonts under ‘Font’. Select Cascadia Code, and click OK. When you return to Command Prompt, it will be using the new font. Whenever you open it again, it will retain this setting.

You can do this for the current user, or for the admin user. It all depends on how you open Command Prompt.

Cascadia Code in PowerShell

To use Cascadia Code in PowerShell, you have to follow similar steps. Open PowerShell and right-click the title bar. From the context menu, select Properties.

Go to the Font tab, and look for Cascadia Code under the list of fonts in the Font section. Select it, and click OK. PowerShell will use Cascadia Code from this point forward.

You can change the font any time you want if you don’t like how it looks. Since Cascadia Code has been installed system wide, you will be able to use it in other apps that allow you to select a font. For word processors and/or design apps like Illustrator, Paint.net. and Photoshop, the font will be available for selection within the text tools.

This font was developed for the Terminal app so its focus is console users. You’re free to use it elsewhere but if it doesn’t look good in other projects, know that it isn’t exactly made for them.

Read How to use the Cascadia Code font in Command Prompt on Windows 10 by Fatima Wahab on AddictiveTips – Tech tips to make you smarter

How to get Microsoft Powershell on Linux

PowerShell is Microsoft’s answer to the Unix command-line. It’s powerful and primarily targeted at developers looking for a rock solid command-line and scripting framework.

The PowerShell tool and framework isn’t exclusive to Windows users. To the surprise of many, Microsoft has made it possible to use their PowerShell platform on other operating systems, including Linux.

While a majority of Linux users focus on the Unix command-line that all distributions have to offer, it’s nice to see Microsoft putting Windows-related tools, such as PowerShell on the platform, so that Linux users who need to use Powershell don’t need to use Microsoft’s operating system. Here’s how to get Powershell on Linux.

Install PowerShell on Linux

On Linux, Microsoft has given Linux users many different ways to enjoy PowerShell. As of now, there’s a DEB package for Ubuntu and Debian, an RPM for Fedora, SUSE, CentOS (and other RedHat OSes,) an unofficial AUR package and even a Snap available for installation.

To get PowerShell working on your Linux PC, open up a terminal window by pressing Ctrl + Alt + T or Ctrl + Shift + T on the keyboard. Then, follow along with the instructions that match the Linux distribution you are currently using.

Ubuntu

It’s true that since Ubuntu comes with Snap by default, users should probably install the Snap release instead of fussing with the PowerShell DEB release. However, not every Ubuntu user likes to use Snaps, so it’s nice to see there’s an alternative way to install the software.

To get your hands on the PowerShell Debian package for your Ubuntu PC, use the wget downloader tool.

18.04 LTS

wget https://github.com/PowerShell/PowerShell/releases/download/v6.2.0/powershell_6.2.0-1.ubuntu.18.04_amd64.deb

16.04 LTS

wget https://github.com/PowerShell/PowerShell/releases/download/v6.2.0/powershell_6.2.0-1.ubuntu.16.04_amd64.deb

With the package file is done downloading, it’s time to install it to Ubuntu. To do this, use the dpkg command.

sudo dpkg -i powershell_*_amd64.deb

Following the installation of the PowerShell DEB package on Ubuntu, you may see errors that appear in the command-line prompt. Don’t worry; these errors are likely just dependency issues. To fix them, use the apt install command below.

sudo apt install -f

Assuming apt install runs successfully, you’ll be able to access PowerShell on Ubuntu!

Debian

Microsoft does support Debian users with a PowerShell DEB package, however officially, they’ve only released one for Debian 9 Stable. It’s okay, as most users aren’t on 10 yet, but if you do use 10, skip these instructions in favor of the Snap method instead.

To get PowerShell working on Debian 9, launch a terminal window. From there, run the following wget download command to grab the latest DEB release of the app.

wget https://github.com/PowerShell/PowerShell/releases/download/v6.2.0/powershell_6.2.0-1.debian.9_amd64.deb

When the DEB package is done downloading to your Debian PC, it’s time to start the installation. To do this, run dpkg.

sudo dpkg -i powershell_*_amd64.deb

After running the dpkg command, Debian may experience dependency issues. To fix this, you can run apt-get install.

sudo apt-get install -f

Once your dependency issues are corrected (if there were any), PowerShell will be ready to use!

Arch Linux

Microsoft’s PowerShell is on the Arch Linux AUR, so if you’re looking to install it on your Arch PC, you’re in luck. To start the installation, open up a terminal and use the Pacman package to download Git and Base-devel to the system.

sudo pacman -S git base-devel

Following Git and Base-devel, clone the latest Trizen AUR snapshot, to make installing PowerShell easy.

git clone https://aur.archlinux.org/trizen.git

Install Trizen to the system using makepkg.

cd trizen
makepkg -sri

Finally, install the latest release of Microsoft PowerShell on Arch Linux.

trizen -S powershell

Fedora

Microsoft has released an RPM package for both RedHat Enterprise Linux 7, and Fedora which can be used to install PowerShell. To get your hands on this RPM package file, use wget to download it. Then, install with Dnf.

wget https://github.com/PowerShell/PowerShell/releases/download/v6.2.0/powershell-6.2.0-1.rhel.7.x86_64.rpm

sudo dnf install powershell-6.2.0-1.rhel.7.x86_64.rpm

OpenSUSE

There’s an RPM package of PowerShell ready to install on OpenSUSE Leap 42.3, so those on SUSE are in luck. However, if you’re using 15.0 or Tumbleweed, consider the Snap instructions instead.

To install PowerShell on SUSE 42.3, start by using the wget tool to download the latest RPM file.

wget https://github.com/PowerShell/PowerShell/releases/download/v6.2.0/powershell-6.2.0-1.rhel.7.x86_64.rpm

Once the download is complete, use Zypper to install the package.

sudo zypper install powershell-6.2.0-1.rhel.7.x86_64.rpm

Snap

Aside from generating several packages for various Linux distributions, Microsoft has also chosen to upload PowerShell to the Snap package store. So, if you’re running a Linux distribution that supports Snaps, you’re in luck!

To install the Snap release of PowerShell, follow this guide to learn how to set up Snapd on your system. Then, install the latest release of Microsoft PowerShell with the snap install command below.

sudo snap install powershell --classic

Access PowerShell

To access Microsoft PowerShell on Linux, fire up your favorite Linux terminal application. Once the app is open, run the command below.

pwsh

For help with PowerShell, run:

pwsh help

Read How to get Microsoft Powershell on Linux by Derrik Diener on AddictiveTips – Tech tips to make you smarter

How to run PowerShell scripts with keyboard shortcuts on Windows 10

PowerShell scripts take a little setting up if you want them to run automatically at a given time. It takes more than using just a scheduled task as the script won’t run in PowerShell as an action. If you’re not looking to automatically run these scripts and instead are looking to run PowerShell scripts with keyboard shortcuts, you can do just that. There are some limitations to this process but nothing that makes the process tedious to use.

PowerShell scripts with keyboard shortcuts

The first thing you need is the PowerShell script. Go ahead and create it. Move it somewhere you know you won’t delete it by accident. Once you’ve done that, go to your desktop and right-click on an empty area. From the context menu, select New>Shortcut.

In the location field, enter the following and make sure you replace “path-to-script” with the complete path to the PowerShell script you want to run with a keyboard shortcut.

%SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe -ExecutionPolicy Bypass -File "path-to-script"

Example

%SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe -ExecutionPolicy Bypass -File "C:\Users\fatiw\Desktop\toastNotification.ps1"

Click Next, and enter a name for the shortcut. If you want, you can also change the icon that the shortcut uses. By default, it will use the PowerShell icon.

After you’ve created the shortcut, right-click it and select Properties from the context menu. Go to the Shortcut tab, click inside the ‘Shortcut key’ field, and record the keyboard shortcut that you want to use to run the app.

You only need to enter a letter or number. The Ctrl+Alt keys are added by default and will be part of all keyboard shortcuts for running apps/shortcuts to apps.

That should do the trick. You can now run the script with the shortcut that you recorded.

Limitations

I mentioned earlier that this method has limitations, though they’re not very restricting. The limitation is that the shortcut, the one you created, must be placed on the desktop or added to the Start Menu. If you move the shortcut anywhere else, e.g., to a different drive on your PC, or nest it inside a folder, the keyboard shortcut will not be able to run the script.

Keeping the script on your desktop is really the most reliable way to run scripts with a keyboard shortcut. It seems that using the Pin to Start option in the shortcut’s menu doesn’t really do the trick and neither does adding it to the Start Menu folder. It may have to do with the script I tested this out on so go ahead and try it out for yourself. If adding the shortcut to the Start Menu won’t work, you’re going to have to place it on your desktop.

Read How to run PowerShell scripts with keyboard shortcuts on Windows 10 by Fatima Wahab on AddictiveTips – Tech tips to make you smarter