Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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?

share|improve this question
1  
Do you have %PATHEXT% set? (It should list at least .exe;.cmd;.bat) –  grawity Jan 26 '10 at 19:58
    
Adding %PATHEXT% got the default windows console programs to work, but not PSCP that I'm depending on. –  saturdayplace Feb 5 '10 at 16:52
    
Copying the pscp.exe file into the same directory as my ps1 file is working for now. –  saturdayplace Feb 5 '10 at 17:14

3 Answers 3

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:

invoke-expression -command "ipconfig"  

or:

invoke-expression -command "c:\windows\system32\ipconfig.exe"  

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):

[System.Diagnostics.Process]::Start("c:\windows\system32\ipconfig.exe")
share|improve this answer

Try running powershell -NoProfile and see if things work. If so. then your problem is the profile script, which you can edit with notepad $profile.

Try opening a CMD window and run ipconfig there. If it works in CMD but not in PowerShell, then compare the environment found in each. The easiest way is probably to run set in CMD and to run cmd.exe /C set in the PowerShell window and compare the results.

share|improve this answer

It's a little odd to see your PATH expressed in terms of other environment variables. I wonder if that could be making things wonky.

For instance, here's what I would expect to see in your PATH variable (assuming that C: is your primary install drive):

PATH=C:\Windows\System32;C:\Windows;C:\Windows\System32\Wbem;
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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