I've inherited a Windows Server 2003 r2 box. I've got a Powershell script that I'd need to get running on the machine, but something seems terribly wrong with the system. For example, opening a Powershell console and entering ipconfig
gets the following response:
The term 'ipconfig' is not recognized as a cmdlet, function, operable program, or script file. Verify the term and try again.
My Powershell script is trying to call pscp.exe (from the putty project), and it gets the same error as above.
My first suspicion was that it was a path issue, and sure enough, when I opened up the environment variables window, the PATH
variable didn't even exist. So I created it, and made sure the directory containing pscp
was listed there. Still no dice.
Running the same commands (ipconfig, or pscp) in cmd.exe works as expected once I added some basic entries to the PATH
variable (%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;).
$env:path
in Powershell returns the values of the PATH
variable, but powershell still won't execute programs that are in those directories. get-host | select version
returns 1.0.0.0.
Any hints?
Best Answer
It sounds like your environment is a little messed up. Here are a couple of extra troubleshooting steps, hopefully one of them will give more useful information:
Try to run the command using the full path: c:\windows\system32\ipconfig.exe
Try the invoke-expression cmdlet:
or:
Try using the .Net process provider (you won't be able to see the results of the call, but it will give you some information about it that might be useful):