Jump to content
Pulseway 9.14 🔥

PowerShell

Share your PowerShell scripts

  1. Started by dtoxic,

    Here is a script for Powershell to set the pc to autologon one time [configurable] after restart, with a 15 sec delay Someone may find it handy Copy paste into Powershell ISE or txt and then rename to *.ps1 Tested on Windows 7 X64 $RegPath = "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" $DefaultUsername = "Insert Username Here" $DefaultPassword = "Insert Password Here" Set-ItemProperty $RegPath "AutoAdminLogon" -Value "1" -type String Set-ItemProperty $RegPath "DefaultUsername" -Value "$DefaultUsername" -type String Set-ItemProperty $RegPath "DefaultPassword" -Value "$DefaultPassword" -type String Set-ItemProperty $RegPath "Auto…

  2. I created a script to install an MSI installer. However is I point to a Mapped Drive such as Z:\Working Directory\Installer.MSI it does not execute. If I execute the script from the C:\Temp\Installer.MSI it installs successfully. I've even tried using a UNC Path \\SERVERNAMER\Working Directory\Installer.MSI and it does not execute. Why is this? Does Pulseway not have permission to see the network share? Is there an area when creating the task that I need to enter network credentials. I don't see this. Please advise what I am doing wrong or overlooking Greg

  3. So, I have this: Set-ItemProperty -Path "HKLM:\Software\MMSOFT Design\PC Monitor\" -Name ComputerName -Value "$env:UserName" Which works great from the local machine via PowerShell, However, when I try to run this as a script/task, the name just shows up as "HOSTNAME$" Any ideas why?

  4. Started by David-,

    Would like to execute powershell and batch scripts as admin. Is this possible? For example, I would like to run sfc. Is my only option scheduling tasks?

    • 4 replies
    • 6.8k views
  5. Started by SilverAnt,

    I'm not sure this is the correct section to post in, but I am having issues with a sample script I wrote. In testing out the automation features of Pulseway, I wrote a script to start the PC Monitor service (because I am having issues with it not starting all of the time). Here is the script: Get-Service "PC Monitor" | Where {$_.status –eq 'Stopped'} | Start-Service Here is the error I get in return : At C:\Program Files\Pulseway\automation_a5487285_b624_4996_8bc3_3440ed567e5a.ps1:1 char:47 + ... ice "PC Monitor" | Where {$_.status Æ’?"eq 'Stopped'} | Start-Service + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The s…

  6. Started by ethorup,

    Small Correction: The scheduled task can be run on demand, but by default it restarts the pulseway service once a day at 11am, which in theory, should force it to check for updates. So one of the problems I ran into with pulseway is, sometimes I would want to restart the service. Doesn't really matter why, could be to get it to check for new updates to the pulseway agent and get them on the latest version. The problem was that if I just setup a script to restart the service, say like this ReStart-Service "Pulseway" what would happen is that it would send the command in whatever user environment pulseway runs in, it would execute it, the service would stop, and the…

  7. Not my work, I took code form two locations and put them together to fit my needs, change the path to the path to your folder, change the filter to the file type to filter by, add as a script, run it, and then open your Last Executions to see the contents of the file. I was needing to check status of a log file on a server every so often, the log file name would change daily and be time stamped, this solved it for me. $dir = "C:\data\Sync_Reports" $filter="*.txt" $latest = Get-ChildItem -Path $dir -Filter $filter | Sort-Object LastAccessTime -Descending | Select-Object -First 1 $latest.name Get-Content $dir"\"$latest

  8. This post assumes you are already managing bitlocker in some capacity (feel free to read through my guide on how I am managing bitlocker with Pulseway custom fields here.). The use cases for this script are a bit niche. This script will remove the tpm as a valid key protector for the c:\ drive of a workstation. Two common use cases for when you may wish to do this: 1. In the event a laptop is stolen. - We have it setup where we can add stolen devices to a scope.. Devices that come online in this scope will kick off a workflow which includes the blow script. While in theory you shouldn't need to do this if the attacker doesn't know the password to the devic…

    • 0 replies
    • 6k views
  9. This will download and install or upgrade veeam and install a license if you have one, finally it will import a config file if one is available. I use Dropbox and a shared link. When using Dropbox be sure and change the zero at the end to 1 to download. You if course would have to update the dl links. Any questions let me know. VeeamInstall.ps1 ## $workdir = "c:\installer\" $LicenseFile = "$workdir\Veeamlicense.lic" $ConfigFile = "$workdir\config.xml" [Object[]]$List = @( New-Object -TypeName PSObject -Property @{"File" = "$workdir\Veeam2.exe"; "URL" = "https://www.dropbox.com/s/Veeamexedl=1"} New-Object -TypeN…

  10. Started by Keith,

    I am trying to create a PowerShell script that will run DBCC checks on a SQL server and then report status back to Pulseway. I have a working script that I can run from the command line but the script will not run correctly when sent as a Pulseway script. Here are the details. The script fails because it is unable to authenticate to the SQL server. The SQL Server is running on the same machine as I am running the script on. Thus wil are not dealing with cross machine accounts. I have put debug code into the script and the account reported back by PowerShell is MACHINENAME$. The machine is in a domain and thus the script appears to be reporting back the machine …

    • 1 reply
    • 5.7k views
  11. Started by Josh-405,

    After noticing the addition of Custom Fields to the Scripts section, I was testing it out and wanted to store a value in a Custom Field for each system. I have setup a powershell script that should save a variable value to the Custom Field and ran it against my computer. The script ran successfully, but I am not able to find the Custom Field to see if value was saved properly. Where can the Custom Field be found?

  12. Started by AJK,

    I'm trying to run just a simple wusa /uninstall /kb:5000802 script in a task but the task just hangs forever and never makes progress on the machines. I don't have too much experience running any type of scripting through an RMM so any help would be greatly appreciated.

  13. This script will update Hyper V integration services. Be sure and change your server names to match. Server0 is host and server1 is the Hyper V. Run on Host. Get-VM -Name SERVER1 –ComputerName server0 Set-VMDvdDrive -ComputerName server0 -VMName SERVER1 -Path 'C:\Windows\System32\vmguest.iso' $DVDriveLetter = (Get-VMDvdDrive -ComputerName server0 -VMName SERVER1).Id | Split-Path –Leaf Invoke-Command –ComputerName SERVER1 -ScriptBlock { if ($ENV:PROCESSOR_ARCHITECTURE -eq 'AMD64') { $folder = 'amd64' } else { $folder = 'x86' } Start-Process -FilePath "$($using:DVDriveLetter):\support\$folde…

    • 0 replies
    • 5.5k views
  14. Started by eDecisions,

    I want to start a project, ADD-Printer via power shell, anyone want to help? Or you doing it alrady?

  15. Started by Sean Faria,

    Hi, I am trying to install GCPW (Google Credential Provider for Windows). I am running into issue where with it: <# This script downloads Google Credential Provider for Windows from https://tools.google.com/dlpage/gcpw/, then installs and configures it. Windows administrator access is required to use the script. #> <# Set the following key to the domains you want to allow users to sign in from. For example: $domainsAllowedToLogin = "acme1.com,acme2.com" #> $domainsAllowedToLogin = "" Add-Type -AssemblyName System.Drawing Add-Type -AssemblyName PresentationFramework <# Check if one or more domains are set #> if ($domainsAllowedToLogin.Equal…

    • 1 reply
    • 5.3k views
  16. Started by pat,

    Hi, I am trying to automate the run of disk clean-up tool (cleanmgr) on my managed computers. I have created a script that prepares the "sageset" on computers and that seems to be working OK. The problem I am running into is that when I remotely launch the script/1-liner that executes the cleanmgr to effectively run the created sageset, it just hangs while using a certain percentage of CPU. Do you have any idea what I'm doing wrong? prepare.sageset.ps1: this prepares the "sageset" in registry. I'm using sageset 0x0100. run.cleanup.ps1: this starts the "sagerun". It works just fine when executed manually from powershell but I'm running into the above-descrip…

  17. ## Downloads latest PDQ from Company Dropbox and silently installs or updates if already installed # Path for the workdir $workdir = "c:\installer\" # Check if work directory exists if not create it If (Test-Path -Path $workdir -PathType Container) { Write-Host "$workdir already exists" -ForegroundColor Red} ELSE { New-Item -Path $workdir -ItemType directory } # Download the installer $url = "https://www.dropbox.com/PDQ13.exe?dl=1" # Put your Url with the file here..I use dropbox, you can use whatever file hosting service. $destination = "$workdir\pdq13.exe" # Check if Invoke-Webrequest exists otherwise execute WebClient if (Get-…

    • 0 replies
    • 5.2k views
  18. This has been bugging the h ell out of me, I need to map a drive, or run a program that can only be run by the logged in user, and if I map the drive from session 0 the user does not see it. The below script works but wish Pulseway had better run as user features built in. This script will map a drive letter for the logged in user, change server and share name to your info. you can change the /TR "any commoand you want to run as the user" $Taskname = "MapX" $lastlogon = (New-Object -ComObject WScript.Shell).RegRead("HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Authentication\LogonUI\LastLoggedOnUser") SCHTASKS /CREATE /sc ONCE /st 00:00 /TN $T…

    • 5 replies
    • 5.1k views
  19. I made a install script for Calibre to do a Silent install. UPDATED VERSION 2 With auto detect if Invoke-WebRequest exists Improvements are welcome! # Silent Install Calibre # https://calibre-ebook.com/download # Path for the workdir $workdir = "c:\installer\" # Check if work directory exists if not create it If (Test-Path -Path $workdir -PathType Container) { Write-Host "$workdir already exists" -ForegroundColor Red} ELSE { New-Item -Path $workdir -ItemType directory } # Download the installer $source = "https://calibre-ebook.com/dist/win32" $destination = "$workdir\calibre.msi" Invoke-WebRequest $source -OutFile $destination # Start the inst…

  20. Started by Christian Kiesel,

    I have added a powershel script to Pulseway and scheduled it. On the Server the script is running well, but with Pulseway it has a problem to send a mail with the PS command: Send-MailMessage. + Send-MailMessage -To $user.EmailAddress -BCC $MailSender -Fr ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidOperation: (System.Net.Mail.SmtpClient:Sm tpClient) [Send-MailMessage], SmtpException + FullyQualifiedErrorId : SmtpException,Microsoft.PowerShell.Commands.Send MailMessage The command is: Send-MailMessage -To $user.EmailAddress -From $MailSender -SmtpServer $SMTP…

    • 1 reply
    • 4.9k views
  21. Started by Keith,

    This is more of a general script question about Pulseway. There are a number of the built-in script that appear like they should return data. When I review the scripts they are PowerShell scripts that would return data to the screen. I don't understand where the data is returned when they are run remotely via Pulseway. Is there someplace that Pulseway returns the data from a script after it is run? This would be super convenient but I surely cannot find this. Examples: List Installed Hotfixes List System Restore Points List Computers in the Active Directory These are built in but I don't understand where the results are supposed to be r…

    • 4 replies
    • 4.8k views
  22. Started by Greg Weides,

    We noticed that all machines we had with Win 10 either via fresh install and or upgrade would not WOL from Pulseway. Through much troubleshooting and testing it came down to the fast startup option in the power settings preventing WOL from happening. We setup a PS script to change the regkey value for fast startup and set it to disabled. After a restart and processing of the registry the systems now wake when requested to via Pulseway RMM. PS script is below... Set-ItemProperty 'HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\Power' -Name HiberbootEnabled -Value 0

    • 1 reply
    • 4.7k views
  23. This will stop and restart EXPLORER.EXE for the currently logged in user. #By eDecisions $TasknameStop = "ExplorerStop" $TasknameStart = "ExplorerStart" $lastlogon = (New-Object -ComObject WScript.Shell).RegRead("HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Authentication\LogonUI\LastLoggedOnUser") SCHTASKS /CREATE /sc ONCE /st 00:00 /TN $TasknameStop /RU $lastlogon /TR "taskkill /f /im explorer.exe" SCHTASKS /CREATE /sc ONCE /st 00:00 /TN $TasknameStart /RU $lastlogon /TR "explorer.exe" start-sleep -s 1 schtasks /Run /TN $TasknameStop start-sleep -s 1 schtasks /Run /TN $TasknameStart start-sleep -s 1 schtasks /delete /tn …

    • 1 reply
    • 4.7k views
  24. I am looking to create an automated pop up message via powershell to alert users in a certain scope. Example: Systems will be under going maintenance, please ensure you leave the system on. However, I noticed due to powershell being in 'session 0' it won't show the pop up box for the user. How can I get around this or does anybody have another method? Side note: I did notice you can send group messages via Pulseway Group section, but I don't think I could automate that?

  25. Hi, Is it possible to continue a script after a reboot using Tasks? I build a PowerShell script where a reboot is required and needs to continue after te reboot.

    • 3 replies
    • 4.3k views