-4
PS C:\WINDOWS\system32> Push-Location
PS C:\WINDOWS\system32> Set-Location C:\
PS C:\> Set-Location HKLM:\Software\Wow6432Node\Microsoft\jet\4.0\Engines\Excel
PS HKLM:\Software\Wow6432Node\Microsoft\jet\4.0\Engines\Excel> Set-ItemProperty .          TypeGuessRows "0"
PS HKLM:\Software\Wow6432Node\Microsoft\jet\4.0\Engines\Excel>

Above is my code.It works manually. But how to run the above script on server. When save my script in myscript.ps1 and try to execute getting below error

PS C:\> .\myscript.ps1

Get-Process : A positional parameter cannot be found that accepts argument 'Push-Location'. At C:\myscript.ps1:1 char:3 + PS <<<< C:\WINDOWS\system32> Push-Location + CategoryInfo : InvalidArgument: (:) [Get-Process], ParameterBindingException + FullyQualifiedErrorId : PositionalParameterNotFound,Microsoft.PowerShell.Commands.GetProcessCommand

7
  • What is the exact content of your script file? Feb 17, 2014 at 21:38
  • My script file is in the code section
    – Priya
    Feb 17, 2014 at 21:42
  • Does your script file actually contain the PS C:\WINDOWS\system32> part and similar, or only the Push-Location and similar parts? Feb 17, 2014 at 21:44
  • I am newbie. I just copied my script from powershell. It does have PS...The script is similar to the above
    – Priya
    Feb 17, 2014 at 21:46
  • Your script should only have the commands you want it to run, i.e. Push-Location on the first line, `Set-Location C:` on the second line and so forth. Feb 17, 2014 at 21:47

1 Answer 1

0
Push-Location
Set-Location C:\
Set-Location HKLM:\Software\Wow6432Node\Microsoft\jet\4.0\Engines\Excel
Set-ItemProperty . TypeGuessRows "0"

It works with the above code...Robert thanks for your help...

Not the answer you're looking for? Browse other questions tagged or ask your own question.