fbpx

How To Execute PowerShell Scripts With Pulseway? With 1 Best Example

Built on Windows, PowerShell is a command-line shell and scripting language. By running scripts asynchronously, Pulseway can help you streamline your productivity if you frequently use PowerShell. 

How To Execute PowerShell Scripts With Pulseway? With 1 Best Example

Users can utilize the “pulseway scripts” utility to use Pulseway to run PowerShell scripts. The program can be used to automate system functions like delivering notifications and editing files. keep reading to learn how to write a script using PowerShell to integrate with pulseway.

Execute PowerShell Scripts With Pulseway In Windows PC Monitor

To execute PowerShell scripts with Pulseway, you can follow these steps:

  1. Ensure that Pulseway is installed and configured on the target system where you want to run the PowerShell scripts.
  2. Open a text editor or an Integrated Development Environment (IDE) to create your PowerShell scripts. Write your desired PowerShell commands in the script file.
  3. Save the PowerShell script file with a .ps1 extension. For example, you can name it “myscript.ps1”.
  4. Open the Pulseway Manager application on your computer.
  5. In the Pulseway Manager, navigate to the system where you want to execute the PowerShell script.
  6. Once you have selected the desired system, click on the “PowerShell” tab or navigate to the “PowerShell” section.
  7. In the PowerShell section, click on the “Execute” button or a similar option that allows you to run a PowerShell command.
  8. A new window or dialog box will open, providing you with an interface to enter the PowerShell command. Enter the following command:
.\myscript.ps1

Make sure to replace “myscript.ps1” with the actual name and path of your PowerShell script file if it’s located in a different directory.

  1. Click on the “Execute” or “Run” button to execute the PowerShell script using Pulseway.
  2. Pulseway will run the PowerShell script on the selected system, and you will be able to monitor the execution progress and any output or errors generated by the script.

That’s it! Your PowerShell script will be executed using Pulseway. You can use this method to automate tasks, perform system management, or execute any other PowerShell commands on remote systems through Pulseway.

Example To Execute PowerShell Scripts With Pulseway

Every night, I have to restart the print spooler service on all of our servers. To automatically test them against various systems, I’ll utilize Pulseway.

So go to Automation in Pulseway and then begin in Scripts.

You should make your own category to store your scripts in since there is one built-in by default.

My new category will be called Custom, and I’ll make it. I can click inside the newly created category and select Create Script. Assign a name to your script. Restart Print Spooler Service is going to be my first command.

I will then select my script type after switching the Windows tab to Enabled. I want to utilize PowerShell, which is the default setting for this. However, you can change the script type if you require a batch file or VBScript.

I’ll let PowerShell handle that, then type my script. The script I’m using in this case stops the service, waits a brief amount of time, and then restarts it.

Start-Sleep -Seconds 5
Stop-Service -Name 'spooler'
Start-Sleep -Seconds 3
Start-Service -Name 'spooler'
Start-Sleep -Seconds 5
Stop-Service -Name 'spooler'
Start-Sleep -Seconds 3
Start-Service -Name 'spooler'

Make sure I’m on PowerShell and head over to the Windows tab to add my script.

Start-Sleep -Seconds 5

$PsProcs = Get-CimInstance Win32_Process -Filter "name = 'powershell_ise.exe'"

foreach ($Proc in $PsProcs) {

$Owner = Invoke-CimMethod -InputObject $Proc -MethodName GetOwner

    if ($Owner.User -notlike 'admin*') {
    Stop-Process -Id $Proc.ProcessId -Force

    }

}
powershell script

This script will gather all of the PowerShell ISE processes, browse them, and use the GetOwner method to check for the owner. If the owner doesn’t begin with the term “admin,” the process will be stopped. To confirm, click Save Script.