Jump to content
DigitalDentist

Powershell Scripts Not working

Recommended Posts

Can someone tell me why this script works locally from the server but not from Pulseway. I've tested running the script both with impersonation enabled and disabled. Both tests were done on server 2012 R2. One with default Powershell version and one with 5.1. This script runs perfectly fine from the server itself just not through pulseway. I have several scripts that give the same type of error. I'd appreciate any help so I can figure this out. It seems like Pulseway doesn't like certain characters? 

ForEach ($COMPUTER in (Get-ADComputer -Filter '*' | Select -ExpandProperty Name)) 

 {
  $key = “SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update\Results\Install” 
        $keytype = [Microsoft.Win32.RegistryHive]::LocalMachine 
        $RemoteBase = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey($keytype,$Server) 
        $regKey = $RemoteBase.OpenSubKey($key) 
        $KeyValue = $regkey.GetValue(”LastSuccessTime”) 
     
        $System = (Get-Date -Format "yyyy-MM-dd hh:mm:ss")  
             
        if    ($KeyValue -lt $System) 
        { 
            Write-Host " " 
            Write-Host $computer "Last time updates were installed was: " $KeyValue 
        } 
    }

Screenshot_20170721-132009.png

Screenshot_20170721-132017.png

This is what it looks like when ran from the server without involving pulseway

20170721_132729.jpg

Share this post


Link to post
Share on other sites

Hi,

At first you will need to get the PS session and then you will be able to run this script via Pulseway:

Get-PSSession -ComputerName "computer name"

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Similar Content

    • By ethorup
      This script will download the small online installer, generate the silent install cfg file and run the installer.  The timer near the end is set for 3 minutes as it has to download the full installer first and Java takes a while to install anyway.  If you want to get the latest version just go to https://java.com/en/download/win10.jsp and copy the link from the button that says "Agree and start free download".  Then past this link into the $source variable.  I find that this installer works on both windows 7 and windows 10.
       
      # Download and silent install Java Runtime Environement
      # working directory path
      $workd = "c:\temp"
      # Check if work directory exists if not create it
      If (!(Test-Path -Path $workd -PathType Container))

      New-Item -Path $workd  -ItemType directory 
      }
      #create config file for silent install
      $text = '
      INSTALL_SILENT=Enable
      AUTO_UPDATE=Enable
      SPONSORS=Disable
      REMOVEOUTOFDATEJRES=1
      '
      $text | Set-Content "$workd\jreinstall.cfg"
          
      #download executable, this is the small online installer
      $source = "http://javadl.oracle.com/webapps/download/AutoDL?BundleId=230511_2f38c3b165be4555a1fa6e98c45e0808"
      $destination = "$workd\jreInstall.exe"
      $client = New-Object System.Net.WebClient
      $client.DownloadFile($source, $destination)
      #install silently
      Start-Process -FilePath "$workd\jreInstall.exe" -ArgumentList INSTALLCFG="$workd\jreinstall.cfg"
      # Wait 120 Seconds for the installation to finish
      Start-Sleep -s 180
      # Remove the installer
      rm -Force $workd\jre*
    • By techtedg
      I can't seem to update any agent settings remotely anymore. I normally use Dashboard to edit an agent's config and change the computer name as needed (hire/term). As of about a week ago, this no longer works. The agent config screen comes up normally after right clicking in Dashboard and choosing edit computer settings, lets me make my changes, and then gives the standard "this may take 30 secs" message when saving. But nothing happens, no update. If I go back in and look at the settings again the modifications are not there. This also happens with Pulseway Manager under Manage Systems. I don't see a way to update agent settings using the WebApp.
       
      I have not updated my Dashboard to my knowledge, still using 5.1.2. Agent version is 5.4. Doesn't seem to matter what OS the computer is running, happening with all PCs And i've installed the Dashboard on a different PC, same results.
       
      The only way to make the changes stick is to login to the computer in question and make the changes on the agent locally.
       
      Help!
    • By Hugo
      How would I get a ticket status to change to "client responded" when a client responds to a "completed" ticket
    • By MattK
      Hi,
      This might be related to this topic, but over the last week I'm seeing notifications for all updates, not just Windows Defender.
      If I delete the notification it comes back again, checking the server shows "26 optional updates are available" (note "optional")
      Pulseway setting: Notifications > Status > "Send a notification when critical or important updates are available with priority" = Automatic
      My notification on my mobile is reading "26 important updates are available..."
      Clicking into the mobile app and checking the Windows Updates it's reporting them as "important" when they aren't.
      For example the server itself lists KB2386667 as recommended but it's listed as important in Pulseway.
       
       
    • By John Taylor
      When adding a new contract, it always gets created with the auto generated contract #, ignoring anything you've placed in the contract # field yourself. You have to edit the contract again to correct it.
×