• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 306
  • Last Modified:

C#. VB

Does anyone know of a way to convert the following PS code to C# or VB to create an exe file?

$password = get-content C:\cred1.txt | convertto-securestring

$credential = new-object -typename System.Management.Automation.PSCredential -argumentlist "admin",$password

#Use invoke-command to execute the operation#

Invoke-command –computername <computer>  -credential $credential –scriptblock {ftpuser}
  • 2
2 Solutions
Consider calling the PowerShell script from C# code, then package the C# code into an exe. Powershell will still be needed on the end user's computer though. This might help: http://www.eggheadcafe.com/software/aspnet/33581867/how-to-call-powershell-script-from-c.aspx
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now