Link to home
Start Free TrialLog in
Avatar of motioneye
motioneyeFlag for Singapore

asked on

error with my powershell scripts

Hi,
Someone in EE has sharing me on this scripts use to extract accounts services. but it return me below error.



PS F:\PowerShell_Myscripts> .\checkservices.ps1
Missing expression after unary operator '-'.
At F:\PowerShell_Myscripts\checkservices.ps1:5 char:10
+         - <<<< namespace root\Microsoft\SqlServer\ComputerManagement
PS F:\PowerShell_Myscripts>
$Instances = get-content "F:\PowerShell_Myscripts\AllServers.txt"
 
$Instances|%{
$sqlservice = Get-WmiObject     
        -namespace root\Microsoft\SqlServer\ComputerManagement
        -class SqlService
        -filter "ServiceName='MSSQL`$_'"
$sqlService
} >> F:\PowerShell_Myscripts\result.txt

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Chris Dent
Chris Dent
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial