Jump to content

Error with Powershell Script


SilverAnt

Recommended Posts

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 string is missing the terminator: ".
At C:\Program 
Files\Pulseway\automation_a5487285_b624_4996_8bc3_3440ed567e5a.ps1:1 char:45
+ ... ice "PC Monitor" | Where {$_.status ƒ?"eq 'Stopped'} |  Start-Service
+                                         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Unexpected token 'ƒ?"eq 'Stopped'} |  Start-Service' in expression or 
statement.
At C:\Program 
Files\Pulseway\automation_a5487285_b624_4996_8bc3_3440ed567e5a.ps1:1 char:34
+ Get-Service "PC Monitor" | Where {$_.status ƒ?"eq 'Stopped'} |  Start ...
+                                  ~
Missing closing '}' in statement block or type definition.
    + CategoryInfo          : ParserError: (:) [], ParentContainsErrorRecordEx 
   ception
    + FullyQualifiedErrorId : TerminatorExpectedAtEndOfString

 

It appears that the -eq is somehow being changed to f?"eq 

Does anyone know why this is happening, or am I misinterpreting this? Any help would be appreciated.

Link to comment
Share on other sites

  • Administrators

Hi,

I just copied the '-eq' into the notepad and then wrote that the exact same thing into a new line and realized that the dash character wasn't the same as the one I just typed.

-Paul

Link to comment
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
×
×
  • Create New...