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?
Always put your path between quotes when it contains spaces.
Get-Content -Path "C:\Program Files\Microsoft SQLServer\MSSQL.1\MSSQL\LOG\ERRORLOG" -TotalCount 5