TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
S Sakrigue
NA
1
925
Powershell to web
Jul 13 2016 10:16 AM
Hello guys,
I try to create a Web page for end users to change their own password alone in active directory.
I used Powershell script in C #. When I executed the code, the following error appears [Incomplete ParseException: The Terminator "is missing in the chain.]
help please!!
Thank you!!
NB :I have to work with Powershell.
using
System;
using
System.Management.Automation;
using
System.Text;
namespace
PowerShellExecution
{
public
partial
class
Default : System.Web.UI.Page
{
protected
void
Page_Load(
object
sender, EventArgs e)
{
}
protected
void
ExecuteCode_Click(
object
sender, EventArgs e)
{
// Clean the Result TextBox
ResultBox.Text =
string
.Empty;
// Validate the input
var usr = user.Text;
var op = oldpwd.Text;
var np = newpwd.Text;
var np1 = newpwd1.Text;
// Initialize PowerShell engine
using
(PowerShell shell = PowerShell.Create())
{
string
pwdScript =
"Set-ADAccountPassword -Identity \""
+ usr +
"\" -Oldpassword \""
+ op +
"\" -NewPassword \""
+ np ;
{
shell.AddScript(pwdScript);
// Execution du script
var results = shell.Invoke();
if
(results.Count > 0)
{
var builder =
new
StringBuilder();
foreach
(var psObject
in
results)
{
builder.Append(psObject.BaseObject.ToString() +
"\r\n"
);
}
ResultBox.Text = builder.ToString();
}
}
}
}
}
}
Reply
Answers (
1
)
How to make send sms to mobile use pc
c# Math Function: Calculating New Distance (Lat/Lon)