PowerShell Issue with Get-Content

Question:

I have an issue. When I run a command:

powershell -command “gc C:\Program Files\Microsoft SQLServer\MSSQL.1\MSSQL\LOG\ERRORLOG -totalcount 5

There is an error:

“Get-Content : A positional parameter cannot be found that accepts
argument ‘Files\Microsoft’. At line:1 char:3 + gc <<<< C:\Program
Files\Microsoft SQL Server\MSSQL.1\MSSQL\LOG\ERRORLOG -to talcount 5
+ CategoryInfo : InvalidArgument: (:) [Get-Content], ParameterBindingException
+FullyQualifiedErrorId:PositionalParameterNotFound,Microsoft.PowerShell.Commands.GetContentCommand”

Can you help me with that?

Answer:

Always put your path between quotes when it contains spaces.

Source:

PowerShell Issue with Get-Content by licensed under CC BY-SA | With most appropriate answer!

Leave a Reply