Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

c# socket server for powershell strage behaviour

Status
Not open for further replies.

mskasu

Programmer
May 1, 2009
5
GB
I have a c# / powershell problem. Any help will be greatly appreciated.

My c# socket server listens on a port, listens for a TcpClient, creates a NetworkStream, GetBytes from the client, covert those bytes to string, passes that string to RunShell method which executes that string as a power shell command, coverts that string to bytes, sends it off to the client.

The problem is that all the "string" commands executed by the powershell method are not executed the way they are on a regular powershell prompt. for example get-command works fine but get-alias does:

get-alias on regular powershell prompt:

CommandType Name Definition
----------- ---- ----------
Alias ac Add-Content
Alias asnp Add-PSSnapin
Alias clc Clear-Content

get-alias from my c# prompt:

Sending parameters: 'get-alias'...<done
Welcome to power shell server ...
ac
asnp
clc


Best Regards,
sk
cli
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top